Skip to content

Action fails due to using incorrect binary install path #1090

Closed
@pgimalac

Description

@pgimalac

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

It looks like some version of golangci-lint can require a specific version of Go, which adds a line to the output when installing it, which makes the action use the wrong install path.

Here is part of the install output:

  go: github.com/golangci/[email protected] requires go >= 1.22.1; switching to go1.22.6
  touch /home/runner/go/bin/golangci-lint
  
  Installed golangci-lint into github.com/golangci/[email protected] in 42821ms

Full job output if needed https://github.com/DataDog/test-infra-definitions/actions/runs/10450688362/job/28935553314.

It was installed in /home/runner/go/bin/golangci-lint but was detected as github.com/golangci/[email protected].

This is due to the logic not expecting the first line

// The output of `go install -n` when the binary is already installed is `touch <path_to_the_binary>`.
const lintPath = res.stderr.trimStart().trimEnd().split(` `, 2)[1]
core.info(`Installed golangci-lint into ${lintPath} in ${Date.now() - startedAt}ms`)

Changing the version in my go.mod file from 1.22.0 to 1.22 fixed it, but I believe the path should be correctly parsed by the action.

Version of golangci-lint

1.60.1

Version of the GitHub Action

v6 (latest)

Workflow file

``` jobs: lint-go: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 with: fetch-depth: '0' - uses: actions/setup-go@v5 with: go-version-file: go.mod # Using setup-go cache conflicts with golangci-lint action own cache management cache: false cache-dependency-path: go.sum - name: golangci-lint uses: golangci/golangci-lint-action@v6 with: # Require: The version of golangci-lint to use. # When `install-mode` is `binary` (default) the value can be v1.2 or v1.2.3 or `latest` to use the latest version. # When `install-mode` is `goinstall` the value can be v1.2.3, `latest`, or the hash of a commit. version: latest
      # Optional: golangci-lint command line arguments.
      args: --timeout=10m

      # Optional: show only new issues if it's a pull request. The default value is `false`.
      only-new-issues: true

      # Optional:The mode to install golangci-lint. It can be 'binary' or 'goinstall'.
      install-mode: "goinstall"
</details>

### Golangci-lint configuration

<details>

```yml
run: 
  timeout: 5m
linters:
  disable-all: true
  enable:
    - unused      # Finds unused code
    - unconvert   # Remove unnecessary type conversions
    - unused      # Checks Go code for unused constants, variables, functions and types
    - ineffassign # Detects when assignments to existing variables are not used
    - misspell    # Finds commonly misspelled English words in comments
    - gofmt       # Gofmt checks whether code was gofmt-ed
    - revive      # Revive is a replacement for golint, a coding style checker
    - errcheck    # errcheck is a program for checking for unchecked errors in go programs.
    - staticcheck # staticcheck is a go vet on steroids, applying a ton of static analysis checks
    - govet       # Vet examines Go source code and reports suspicious constructs, such as Printf calls whose arguments do not align with the format string
    - bodyclose   # checks whether HTTP response body is closed successfully
    - exhaustive  # check exhaustiveness of enum switch statements
    - stylecheck  # Stylecheck is a replacement for golint  
linters-settings:
  errcheck:
    # Disable warnings for `fmt` and `log` packages.
    exclude-functions:
    - fmt.Errorf
    - fmt.Print
    - fmt.Printf
    - fmt.Println
    - (github.com/pulumi/pulumi/sdk/v3/go/pulumi.Log).Debug
    - (github.com/pulumi/pulumi/sdk/v3/go/pulumi.Log).Info
    - (github.com/pulumi/pulumi/sdk/v3/go/pulumi.Log).Warn
    - (github.com/pulumi/pulumi/sdk/v3/go/pulumi.Log).Error
  staticcheck:
    checks: ["all"]

Go version

1.22.0

Code example or link to a public repository

// add your code here

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions