Skip to content
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

Action fails due to using incorrect binary install path #1090

Closed
3 tasks done
pgimalac opened this issue Aug 19, 2024 · 0 comments · Fixed by #1102
Closed
3 tasks done

Action fails due to using incorrect binary install path #1090

pgimalac opened this issue Aug 19, 2024 · 0 comments · Fixed by #1102
Assignees
Labels
bug Something isn't working

Comments

@pgimalac
Copy link

pgimalac commented Aug 19, 2024

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/golangci-lint@v1.60.1 requires go >= 1.22.1; switching to go1.22.6
  touch /home/runner/go/bin/golangci-lint
  
  Installed golangci-lint into github.com/golangci/golangci-lint@v1.60.1 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/golangci-lint@v1.60.1.

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
@ldez ldez added the bug Something isn't working label Aug 19, 2024
@ldez ldez self-assigned this Aug 19, 2024
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