golangci/golangci-lint-action

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

YOwatari opened this issue · 3 comments

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

This issue is probably related.
#106

ldez commented

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 commented

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