Skip to content

Failure of golangci-lint-action with go tool Installation Due to go.mod Version Inference #1164

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
3 tasks done
YOwatari opened this issue Feb 13, 2025 · 3 comments · Fixed by #1165
Closed
3 tasks done
Labels
bug Something isn't working

Comments

@YOwatari
Copy link

Welcome

  • Yes, I understand that the GitHub action repository is not the repository of golangci-lint itself.
  • Yes, I've searched similar issues on GitHub and didn't find any.
  • Yes, I've included all information below (version, config, etc).

Description of the problem

When using Go 1.24.0's new feature to install golangci-lint, golangci-lint-action fails during execution. The failure is caused by an issue in the version inference mechanism that relies on the go.mod file, leading to incorrect version detection.

Steps to Reproduce:

  1. Set up a GitHub Actions workflow with Go 1.24.0.
  2. Install golangci-lint using the new installation method (e.g., go get -tool).
  3. Run golangci-lint-action.
  4. Observe that the action fails due to an error in inferring the version from the go.mod file.

Expected Behavior:

golangci-lint-action should accurately determine the installed golangci-lint version even when installed with Go 1.24.0's new installation approach, allowing the action to execute successfully.

Suggestion:

By revising the version inference logic in golangci-lint-action to accommodate Go 1.24.0's new installation method, the issue with incorrect version detection can be resolved. This adjustment would prevent execution failures in workflows using this Go version.

Reference Information:

Sample reproducing the issue: golangci-lint-action-124-gomod-tool-directive
Example of a failed GitHub Actions job: Failed Actions Job

Version of golangci-lint

1.64.4

Version of the GitHub Action

6.3.2

Workflow file

name: golangci-lint
on:
  push:
    branches:
      - main
      - master
  pull_request:

permissions:
  contents: read
  # Optional: allow read access to pull request. Use with `only-new-issues` option.
  # pull-requests: read

jobs:
  golangci:
    name: lint
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-go@v5
        with:
          go-version-file: go.mod
      - name: golangci-lint
        uses: golangci/golangci-lint-action@v6
        with:
          args: --timeout 5m
          skip-pkg-cache: true
          skip-build-cache: true

Golangci-lint configuration

nothing

Go version

1.24.0

Code example or link to a public repository

nothing

@YOwatari
Copy link
Author

This issue is probably related.
#106

@ldez ldez added question Further information is requested bug Something isn't working and removed question Further information is requested labels Feb 13, 2025
@ldez
Copy link
Member

ldez commented Feb 13, 2025

Hello,

First using go tool to install golangci-lint is highly discouraged.

https://golangci-lint.run/welcome/install/#install-from-sources

The problem is due to the detection of the golangci-lint version inside the go.mod due to the indirect comment related to the usage of tool directive.

@ldez ldez changed the title Failure of golangci-lint-action with Go 1.24.0 Installation Due to go.mod Version Inference Failure of golangci-lint-action with go tool Installation Due to go.mod Version Inference Feb 13, 2025
@ldez
Copy link
Member

ldez commented Feb 13, 2025

I fixed the problem but I would like to enforce the recommendation of not using go tool to install golangci-lint.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants