golangci / golangci-lint-action

Official GitHub Action for golangci-lint from its authors
https://github.com/marketplace/actions/golangci-lint
MIT License
1.07k stars 147 forks source link

Killed Error: golangci-lint exit with code 137 #1094

Closed YakDriver closed 3 weeks ago

YakDriver commented 3 weeks ago

Welcome

Description of the problem

Relates #552

How important is it that the Go version used to run golangci-lint is the same as the Go version used by the project?

When attempting to upgrade to Go v1.23.0:

Killed

Error: golangci-lint exit with code 137

Version of golangci-lint

v1.59.1

Version of the GitHub Action

v6.1.0

Workflow file

```yml name: golangci-lint Checks on: push: branches: - main - 'release/**' pull_request: paths: - .github/workflows/golangci-lint.yml - .ci/.golangci*.yml - .ci/tools/** - internal/** - go.sum - main.go - names/** - tools/** jobs: golangci-lintb: name: 2 of 3 runs-on: custom-linux-xl steps: - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2 with: go-version-file: go.mod cache: false - id: golangci-lint-version working-directory: .ci/tools run: >- echo "version=$( go list -m all | grep github.com/golangci/golangci-lint | awk '{print $2}' )" >> $GITHUB_OUTPUT - name: golangci-lint uses: golangci/golangci-lint-action@aaa42aa0628b4ae2578232a66b541047968fac86 # v6.1.0 with: version: "${{ steps.golangci-lint-version.outputs.version }}" args: --config .ci/.golangci2.yml env: GOGC: "200" # tried values between 5 and 3000 and same result ```

Golangci-lint configuration

```yml issues: max-per-linter: 10 # attempt at reducing memory max-same-issues: 2 # attempt at reducing memory concurrency: 4 # attempt at reducing memory go: 1.23 linters: disable-all: true enable: - asasalint - asciicheck - containedctx - contextcheck - copyloopvar - dogsled - durationcheck - errcheck - errname - errorlint - goconst - gocritic - gofmt - gosimple - govet - ineffassign - makezero - misspell - mnd linters-settings: copyloopvar: check-alias: true dogsled: max-blank-identifiers: 3 errcheck: ignore: github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema:ForceNew|Set # "ignore" is deprecated but "exclude-functions" doesn't seem to work or the syntax is non-obvious. # https://github.com/kisielk/errcheck#excluding-functions # Under exclude-functions are the various attempts at getting it to work, all of which result in d.Set being linted everywhere. # exclude-functions: # - github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*ResourceData).Set # - github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.ResourceData.Set # - github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema:ForceNew|Set,io:Close # - (github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.ResourceData).Set # - github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema:ForceNew|Set # - github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema:ForceNew # - github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema:Set # - github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.Set errorlint: errorf: false goconst: ignore-tests: true min-occurrences: 6 gocritic: enabled-tags: - diagnostic disabled-tags: - experimental - opinionated - performance - style mnd: checks: - argument ignored-functions: - aws.Int32 - aws.Int64 - request.ConstantWaiterDelay - request.WithWaiterMaxAttempts - nullable.* - tfresource.Retry* - tfresource.With* - retry.RetryContext - schema.DefaultTimeout - validation.* - int64validator.* - listvalidator.* - setvalidator.* - stringvalidator.* - SetDefaultCreateTimeout - SetDefaultReadTimeout - SetDefaultUpdateTimeout - SetDefaultDeleteTimeout - make - strconv.FormatFloat - strconv.FormatInt - strconv.ParseFloat - strconv.ParseInt - strings.SplitN run: timeout: 75m ```

Go version

v1.23.0

Code example or link to a public repository

[HashiCorp Terraform AWS Provider](https://github.com/hashicorp/terraform-provider-aws)
YakDriver commented 3 weeks ago

Unfortunately, upgrading golangci-lint to v1.60.3 did not fix the issue and I still get:

  Killed

  Error: golangci-lint exit with code 137
  Ran golangci-lint in 296885ms

This is confusing because locally I had updated golangci-lint to v1.60.3 and it ran fine. However, in the GitHub workflow, we rely on go.mod for the .ci module and it was still set to v1.59.1. But, even after upgrading it to v1.60.3, which supports Go v1.23.0, I get the same unhelpful message, "Killed."

Update: Solution found!

Fixing this required two pieces:

  1. Upgrading to golangci-lint v1.60.0+
  2. Playing with GOGC in the workflow file -- too high and I get "Killed", too low and it runs really slow
      - name: golangci-lint
        uses: golangci/golangci-lint-action@aaa42aa0628b4ae2578232a66b541047968fac86 # v6.1.0
        with:
          version: "1.60.3"
          args: --config .ci/.golangci3.yml
        env:
          GOGC: "100" # default
ozancaglayan commented 3 weeks ago

Hi.

Same here. Its not only the action, I also get the memory issues locally on my computer. My golangci-lint is 1.60.3 compiled with go 1.23.

golangci-lint has version v1.60.3 built with go1.23.0 from (unknown, modified: ?, mod sum: "h1:l38A5de24ZeDlcFF+EB7m3W5joPD99/hS5SIHJPyZa0=") on (unknown)

Is there a solution that I'm missing?

Thanks!

ldez commented 3 weeks ago

You are on the Github Action repo.

If you have a reproducible context, please open an issue on the golangci-lint repo.