Closed sk- closed 6 months ago
Similar issue for me.
If I run golangci-lint
locally, it reports the following errors:
scripts/sync_legacy_plans.go:20:2 staticcheck SA1019: "io/ioutil" has been deprecated since Go 1.16: As of Go 1.16, the same functionality is now provided by package io or package os, and those implementations should be preferred in new code. See the specific function documentation for details.
cmd/webhook.go:7:2 staticcheck SA1019: "io/ioutil" has been deprecated since Go 1.16: As of Go 1.16, the same functionality is now provided by package io or package os, and those implementations should be preferred in new code. See the specific function documentation for details.
However, the GitHub Action is NOT detecting these violations.
Both my local and GH actions are using the v1.49.0 of of golangci-lint.
@ldez what further information is required?
it can be a side effect of cache, so you have to disable the internal action cache.
@ldez we did disable the cache and the error still persists
We event tested it running with no cache and the issue still persists
I am encountering the same issue. Anyone has fix on this one?
Ran into the same issue, even when disabling caching completely, I still am missing violations that are shown on local runs.
I even ran just the raw bin, with a mostly clean env, CI is still missing violations.
golangci-2:
name: lint-2
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version-file: "go.mod"
cache: false
- name: test linter manually
shell: bash
env:
GH_TOKEN: ${{ github.token }}
run: |
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.54.2 && \
gh pr diff 10555 > pr.diff && env -i HOME="$HOME" PATH="$PATH" ./bin/golangci-lint run --out-format colored-line-number --new-from-patch=pr.diff
My issue ended up stemming from compilation errors that were silently ignored during the execution on the lint action. Running a go build ./...
beforehand caught some compilation errors i was hitting from missing a file dep in test files. Once that was resolved, golangci-lint is working fine now :)
In https://github.com/orgs/community/discussions/68471 @lisanna-dettwyler wrote:
According to https://github.com/orgs/community/discussions/26680, you can only have 10 warnings or errors per step, and 50 per job which feels extremely low and arbitrary. I can understand this being used to make sure other annotations from other steps don't get lost in the noise. Unfortunately, this breaks workflows which are intending to post warning annotations to specific lines in files, such as to indicate the results of static analysis checkers.
There is no user interface feedback indicating that warnings are being hidden, nor documentation about this at https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#setting-a-warning-message, so it just makes it look like the feature is broken.
In my case, I think that's ☝️ what prevents all the errors showing up in the GitHub UI. The workflow summary UI only reports 10 errors but the the CLI output in the job / step logs reports 24 lines of errors. This might be a different problem than was reported by the OP.
xref:
Hello,
I added a new option annotations
, which may be useful to some of you.
I added this option for several reasons:
colored-line-number
format.If you set annotations
to false
, the output format(s) will follow the golangci-lint configuration file (or CLI flags from args
) and use the same default as golangci-lint (i.e. colored-line-number
).
https://github.com/golangci/golangci-lint-action?tab=readme-ov-file#annotations
Since a couple of weeks we have been seeing repeatedly that the action does not report some violations while there are some in the code.
We event tested it running with no cache and the issue still persists? Do you have any idea?
In case it works the troubleshoot, the last error that was not detected was:
We are using the following configuration:
Github Action config
```yaml jobs: golangci: name: lint runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - uses: actions/setup-go@v2 with: go-version: '^1.18.2' - name: Install Go-Gen Avro run: go install github.com/actgardner/gogen-avro/v10/cmd/...@latest - name: Generate Avro run: make compile-avro - name: golangci-lint uses: golangci/golangci-lint-action@v3 with: # Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version. version: v1.46 # Optional: working directory, useful for monorepos # working-directory: somedir # Optional: golangci-lint command line arguments. # args: --issues-exit-code=0 args: --verbose # Optional: show only new issues if it's a pull request. The default value is `false`. # only-new-issues: true # Optional: if set to true then the action will use pre-installed Go. # skip-go-installation: true # Optional: if set to true then the action don't cache or restore ~/go/pkg. # skip-pkg-cache: true # Optional: if set to true then the action don't cache or restore ~/.cache/go-build. # skip-build-cache: true # skip-cache: true ```.golangci.yml
```yaml run: timeout: 3m issues: # List of regexps of issue texts to exclude, empty list by default. # But independently from this option we use default exclude patterns, # it can be disabled by `exclude-use-default: false`. To list all # excluded by default patterns execute `golangci-lint run --help` exclude: - tableName - AuthorizeUrl - "\\b(New)?Mock([A-Z][A-Za-z0-9]+)?" exclude-rules: - linters: - lll source: "// .*https?://" linters: enable: - gofmt - goimports - govet - lll - revive linters-settings: goimports: local-prefixes: github.com/Topsort govet: check-shadowing: false enable-all: true disable: - fieldalignment - shadow revive: enable-all-rules: true # Rules are described under # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#rule-name rules: - name: add-constant disabled: true - name: argument-limit disabled: true - name: banned-characters disabled: true - name: bare-return disabled: true - name: cognitive-complexity disabled: true - name: confusing-naming disabled: true - name: cyclomatic disabled: true - name: empty-lines disabled: true - name: early-return disabled: true - name: file-header disabled: true - name: flag-parameter disabled: true - name: function-length disabled: true - name: function-result-limit disabled: true - name: get-return disabled: true - name: import-shadowing disabled: true - name: line-length-limit disabled: true - name: max-public-structs disabled: true - name: modifies-parameter disabled: true - name: nested-structs disabled: true - name: unhandled-error disabled: true - name: unnecessary-stmt disabled: true - name: unused-parameter disabled: true - name: unused-receiver disabled: true ```Below is the output of the last run that did not find an issue.
Latest run output
``` Run golangci/golangci-lint-action@v3 with: version: v1.46 args: --verbose github-token: *** only-new-issues: false skip-cache: false skip-pkg-cache: false skip-build-cache: false env: ... GOROOT: /opt/hostedtoolcache/go/1.18.3/x6[4](https://github.com/Topsort/auction-engine/runs/6880843093?check_suite_focus=true#step:6:4) prepare environment Finding needed golangci-lint version... Requested golangci-lint 'v1.46', using 'v1.46.2', calculation took 60ms Installing golangci-lint v1.46.2... Downloading https://github.com/golangci/golangci-lint/releases/download/v1.46.2/golangci-lint-1.46.2-linux-amd64.tar.gz ... /usr/bin/tar xz --overwrite --warning=no-unknown-keyword --overwrite -C /home/runner -f /home/runner/work/_temp/a89a19c4-473e-404[5](https://github.com/Topsort/auction-engine/runs/6880843093?check_suite_focus=true#step:6:5)-a510-d4a4c[6](https://github.com/Topsort/auction-engine/runs/6880843093?check_suite_focus=true#step:6:6)62[7](https://github.com/Topsort/auction-engine/runs/6880843093?check_suite_focus=true#step:6:7)[8](https://github.com/Topsort/auction-engine/runs/6880843093?check_suite_focus=true#step:6:8)a8 Installed golangci-lint into /home/runner/golangci-lint-1.46.2-linux-amd64/golangci-lint in 586ms Received 41[9](https://github.com/Topsort/auction-engine/runs/6880843093?check_suite_focus=true#step:6:9)4304 of 342360575 (1.2%), 4.0 MBs/sec Received [10](https://github.com/Topsort/auction-engine/runs/6880843093?check_suite_focus=true#step:6:10)4857600 of 342360575 (30.6%), 50.0 MBs/sec Received 226492416 of 342360575 (66.2%), 72.0 MBs/sec Received 342360575 of 342360575 (100.0%), 78.1 MBs/sec Cache Size: ~327 MB (342360575 B) /usr/bin/tar --use-compress-program zstd -d -xf /home/runner/work/_temp/fee3137e-8d7e-4393-8938-4e398f130f49/cache.tzst -P -C /home/runner/work/auction-engine/auction-engine /usr/bin/tar: ../../../go/pkg/mod/github.com/actgardner/gogen-avro@v10.2.1+incompatible/CONTRIBUTING.md: Cannot open: File exists /usr/bin/tar: ../../../go/pkg/mod/github.com/actgardner/gogen-avro@v10.2.1+incompatible/.gitignore: Cannot open: File exists /usr/bin/tar: ../../../go/pkg/mod/github.com/actgardner/gogen-avro@v10.2.1+incompatible/LICENSE: Cannot open: File exists /usr/bin/tar: ../../../go/pkg/mod/github.com/actgardner/gogen-avro@v10.2.1+incompatible/.circleci/config.yml: Cannot open: File exists /usr/bin/tar: ../../../go/pkg/mod/github.com/actgardner/gogen-avro@v10.2.1+incompatible/README.md: Cannot open: File exists Error: /usr/bin/tar: ../../../go/pkg/mod/github.com/actgardner/gogen-avro/v10@v10.2.1/generic/primitive.go: Cannot open: File exists ... Error: /usr/bin/tar: ../../../go/pkg/mod/github.com/actgardner/gogen-avro/v10@v10.2.1/vm/instructions.go: Cannot open: File exists Error: /usr/bin/tar: ../../../go/pkg/mod/github.com/actgardner/gogen-avro/v10@v10.2.1/vm/eval.go: Cannot open: File exists Error: /usr/bin/tar: ../../../go/pkg/mod/github.com/actgardner/gogen-avro/v10@v10.2.1/vm/readers.go: Cannot open: File exists Error: /usr/bin/tar: ../../../go/pkg/mod/github.com/actgardner/gogen-avro/v10@v10.2.1/vm/writers.go: Cannot open: File exists /usr/bin/tar: ../../../go/pkg/mod/github.com/actgardner/gogen-avro/v10@v10.2.1/test.sh: Cannot open: File exists Error: /usr/bin/tar: ../../../go/pkg/mod/github.com/actgardner/gogen-avro/v10@v10.2.1/util/bytes.go: Cannot open: File exists /usr/bin/tar: ../../../go/pkg/mod/github.com/actgardner/gogen-avro/v10@v10.2.1/go.sum: Cannot open: File exists /usr/bin/tar: Exiting with failure status due to previous errors Warning: Tar failed with error: The process '/usr/bin/tar' failed with exit code 2 Prepared env in 8585ms run golangci-lint Running [/home/runner/golangci-lint-1.46.2-linux-amd64/golangci-lint run --out-format=github-actions --verbose] in [] ... level=info msg="[config_reader] Config search paths: [./ /home/runner/work/auction-engine/auction-engine /home/runner/work/auction-engine /home/runner/work /home/runner /home /]" level=info msg="[config_reader] Used config file .golangci.yml" level=info msg="[lintersdb] Active 14 linters: [deadcode errcheck gofmt goimports gosimple govet ineffassign lll revive staticcheck structcheck typecheck unused varcheck]" level=info msg="[loader] Go packages loading at mode 575 (deps|exports_file|name|compiled_files|files|imports|types_sizes) took 4.137036299s" level=info msg="[runner/filename_unadjuster] Pre-built 0 adjustments in 52.539995ms" level=info msg="[linters context/goanalysis] analyzers took 12.23512106s with top 10 stages: buildir: 3.475650926s, the_only_name: 2.694882894s, goimports: 1.241489404s, S1038: 406.080762ms, unused: 281.159412ms, gofmt: 192.843444ms, errorsas: 159.964101ms, deadcode: [11](https://github.com/Topsort/auction-engine/runs/6880843093?check_suite_focus=true#step:6:11)5.857334ms, SA10[12](https://github.com/Topsort/auction-engine/runs/6880843093?check_suite_focus=true#step:6:12): 107.770503ms, S1028: 100.249502ms" level=warning msg="[linters context] structcheck is disabled because of go1.18. You can track the evolution of the go1.18 support by following the https://github.com/golangci/golangci-lint/issues/2649." level=info msg="[runner] Issues before processing: 11462, after processing: 0" level=info msg="[runner] Processors filtering stat (out/in): skip_dirs: 11462/11462, exclude: 518/1[13](https://github.com/Topsort/auction-engine/runs/6880843093?check_suite_focus=true#step:6:13)95, cgo: 1[14](https://github.com/Topsort/auction-engine/runs/6880843093?check_suite_focus=true#step:6:14)62/11462, autogenerated_exclude: 11395/11462, path_prettifier: 11462/11462, skip_files: 11462/11462, identifier_marker: 11395/11395, exclude-rules: 0/518, filename_unadjuster: 11462/11462" level=info msg="[runner] processing took 232.484211ms with stages: identifier_marker: 169.995701ms, exclude: 25.817535ms, exclude-rules: 18.996946ms, path_prettifier: 10.293533ms, autogenerated_exclude: 3.279743ms, skip_dirs: 1.995826ms, filename_unadjuster: 1.429419ms, cgo: 667.908µs, max_same_issues: 1.9µs, nolint: 1.3µs, skip_files: 900ns, uniq_by_line: 800ns, diff: 700ns, severity-rules: 600ns, max_from_linter: 300ns, max_per_file_from_linter: 300ns, sort_results: 300ns, path_shortener: 200ns, source_code: 200ns, path_prefixer: 100ns" level=info msg="[runner] linters took 4.103025481s with stages: goanalysis_metalinter: 3.870247567s, structcheck: [15](https://github.com/Topsort/auction-engine/runs/6880843093?check_suite_focus=true#step:6:15)8.902µs" level=info msg="File cache stats: 2 entries of total size 9.2KiB" level=info msg="Memory: 84 samples, avg is 113.5MB, max is [24](https://github.com/Topsort/auction-engine/runs/6880843093?check_suite_focus=true#step:6:24)0.0MB" level=info msg="Execution took 8.29844[27](https://github.com/Topsort/auction-engine/runs/6880843093?check_suite_focus=true#step:6:27)53s" golangci-lint found no issues Ran golangci-lint in 90[33](https://github.com/Topsort/auction-engine/runs/6880843093?check_suite_focus=true#step:6:34)ms ```