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 is not detecting some violations #496

Closed
sk- opened this issue Jun 14, 2022 · 9 comments
Closed

Action is not detecting some violations #496

sk- opened this issue Jun 14, 2022 · 9 comments
Labels
question Further information is requested

Comments

@sk-
Copy link

sk- commented Jun 14, 2022

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.

$ golangci-lint --version
golangci-lint has version 1.46.2 built from a333689 on 2022-05-17T06:05:08Z

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:

unexported-naming: the symbol ID is local, its name should start with a lowercase letter (revive)

We are using the following configuration:

Github Action config
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
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
@ldez ldez added the question Further information is requested label Aug 7, 2022
@bhb603
Copy link

bhb603 commented Sep 7, 2022

Similar issue for me.
If I run golangci-lintlocally, 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.

Github Action config
jobs:
  build:
    name: Build
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-go@v2
        with:
          go-version: 1.18
      - name: Configure AWS credentials
        uses: aws-actions/configure-aws-credentials@v1
      - uses: actions/cache@v2
        with:
          path: |
            ~/.cache/go-build
            ~/go/pkg/mod
          key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
          restore-keys: |
            ${{ runner.os }}-go-
      - name: Deps
        env:
          NETRC: ${{ secrets.NETRC }}
          GOPRIVATE: "***"
        run: |
          echo "${NETRC}" > ~/.netrc
          go mod download
      - name: golangci-lint
        uses: golangci/golangci-lint-action@v3
        with:
          version: latest
          skip-pkg-cache: true
.golangci.yaml
output:
  format: tab
  print-issue-lines: true
  print-linter-name: true
linters-settings:
  errcheck:
    exclude-functions: []
issues:
  exclude-rules:
    path: _test\.go
    linters:
      - errcheck
Latest run output
2022-09-07T13:48:36.7393082Z ##[group]Run golangci/golangci-lint-action@v3
2022-09-07T13:48:36.7393419Z with:
2022-09-07T13:48:36.7393664Z   version: latest
2022-09-07T13:48:36.7393964Z   skip-pkg-cache: true
2022-09-07T13:48:36.7394401Z   github-token: ***
2022-09-07T13:48:36.7394700Z   only-new-issues: false
2022-09-07T13:48:36.7394981Z   skip-cache: false
2022-09-07T13:48:36.7395282Z   skip-build-cache: false
2022-09-07T13:48:36.7395557Z env:
2022-09-07T13:48:36.7395859Z   GOROOT: /opt/hostedtoolcache/go/1.18.5/x64
2022-09-07T13:48:36.7396190Z   AWS_DEFAULT_REGION: us-east-1
2022-09-07T13:48:36.7396489Z   AWS_REGION: us-east-1
2022-09-07T13:48:36.7396810Z   AWS_ACCESS_KEY_ID: ***
2022-09-07T13:48:36.7397191Z   AWS_SECRET_ACCESS_KEY: ***
2022-09-07T13:48:36.7402450Z   AWS_SESSION_TOKEN: ***
2022-09-07T13:48:36.7402723Z ##[endgroup]
2022-09-07T13:48:36.9127613Z ##[group]prepare environment
2022-09-07T13:48:36.9144699Z Finding needed golangci-lint version...
2022-09-07T13:48:36.9377342Z Omitting ~/go/pkg from cache directories
2022-09-07T13:48:36.9881573Z Requested golangci-lint 'latest', using 'v1.49.0', calculation took 73ms
2022-09-07T13:48:36.9883208Z Installing golangci-lint v1.49.0...
2022-09-07T13:48:36.9885846Z Downloading https://github.com/golangci/golangci-lint/releases/download/v1.49.0/golangci-lint-1.49.0-linux-amd64.tar.gz ...
2022-09-07T13:48:37.2698054Z [command]/usr/bin/tar xz --overwrite --warning=no-unknown-keyword --overwrite -C /home/runner -f /home/runner/work/_temp/03456d00-b3eb-47da-9a83-9c0bae01d978
2022-09-07T13:48:37.5024535Z Installed golangci-lint into /home/runner/golangci-lint-1.49.0-linux-amd64/golangci-lint in 514ms
2022-09-07T13:48:37.8346389Z Received 34901328 of 34901328 (100.0%), 50.0 MBs/sec
2022-09-07T13:48:37.8356103Z Cache Size: ~33 MB (34901328 B)
2022-09-07T13:48:37.8370980Z [command]/usr/bin/tar --use-compress-program zstd -d -xf /home/runner/work/_temp/c4fa61f6-10d7-4313-b09f-9fb4c3582725/cache.tzst -P -C /home/runner/work/pbs/pbs
2022-09-07T13:48:38.4794174Z Cache restored successfully
2022-09-07T13:48:38.4862999Z Restored cache for golangci-lint from key 'golangci-lint.cache-2748-f7ff56db048c85340e1334becaa586ee55bfa9d4' in 1571ms
2022-09-07T13:48:38.4863651Z Prepared env in 1572ms
2022-09-07T13:48:38.4864256Z ##[endgroup]
2022-09-07T13:48:38.4864956Z ##[group]run golangci-lint
2022-09-07T13:48:38.4867258Z Running [/home/runner/golangci-lint-1.49.0-linux-amd64/golangci-lint run --out-format=github-actions] in [] ...
2022-09-07T13:48:57.9625038Z golangci-lint found no issues
2022-09-07T13:48:57.9625735Z Ran golangci-lint in 19477ms
2022-09-07T13:48:57.9627883Z ##[endgroup]

@sk-
Copy link
Author

sk- commented Sep 8, 2022

@ldez what further information is required?

@ldez
Copy link
Member

ldez commented Sep 8, 2022

it can be a side effect of cache, so you have to disable the internal action cache.

@sk-
Copy link
Author

sk- commented Sep 8, 2022

@ldez we did disable the cache and the error still persists

We event tested it running with no cache and the issue still persists

@aldrin-coexservices
Copy link

I am encountering the same issue. Anyone has fix on this one?

@HenryNguyen5
Copy link

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

@HenryNguyen5
Copy link

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 :)

@wallrj
Copy link

wallrj commented Dec 7, 2023

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:

@ldez
Copy link
Member

ldez commented May 4, 2024

Hello,

I added a new option annotations, which may be useful to some of you.

I added this option for several reasons:

  • The number of annotations is limited.
  • Some people don't want to use annotations and just want the classic 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

@ldez ldez closed this as completed May 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

6 participants