golangci-lint-action: github action log output doesn't print the affected file name & line
Please include the following information:
Version of golangci-lint
- id: golangci_configuration
uses: andstor/file-existence-action@v1
with:
files: .golangci.yaml
- name: Go Lint
if: steps.golangci_configuration.outputs.files_exists == 'true'
uses: golangci/golangci-lint-action@v2
with:
version: v1.30
Config file
run:
timeout: 5m
build-tags:
- e2e
skip-dirs:
- pkg/client
linters:
enable:
- asciicheck
- golint
- gosec
- prealloc
- stylecheck
- unconvert
- unparam
disable:
- errcheck
issues:
exclude-rules:
- path: test # Excludes /test, *_test.go etc.
linters:
- gosec
- unparam
Go environment
$ go version && go env
1.15
Verbose output of running
https://github.com/knative/networking/pull/233/checks?check_run_id=1275974348
I had to view the ‘files changed’ page to see the lints
About this issue
- Original URL
- State: open
- Created 4 years ago
- Reactions: 51
- Comments: 40 (10 by maintainers)
Commits related to this issue
- chore: disable linter on Windows temporarily Caused by https://github.com/golangci/golangci-lint-action/issues/119 — committed to panjf2000/gnet by panjf2000 3 years ago
- makefile: add target for running golangci-lint locally Apart from being generally useful, the golangci-lint Action enforces `--out-format=github-action` but doesn't print file names or line numbers. ... — committed to jarrpa/odf-operator by jarrpa 3 years ago
- makefile: add target for running golangci-lint locally Apart from being generally useful, the golangci-lint Action enforces `--out-format=github-action` but doesn't print file names or line numbers. ... — committed to jarrpa/odf-operator by jarrpa 3 years ago
- makefile: add target for running golangci-lint locally Apart from being generally useful, the golangci-lint Action enforces `--out-format=github-action` but doesn't print file names or line numbers. ... — committed to jarrpa/odf-operator by jarrpa 3 years ago
- makefile: add target for running golangci-lint locally Apart from being generally useful, the golangci-lint Action enforces `--out-format=github-action` but doesn't print file names or line numbers. ... — committed to jarrpa/odf-operator by jarrpa 3 years ago
- makefile: add target for running golangci-lint locally Apart from being generally useful, the golangci-lint Action enforces `--out-format=github-action` but doesn't print file names or line numbers. ... — committed to jarrpa/odf-operator by jarrpa 3 years ago
- makefile: add target for running golangci-lint locally Apart from being generally useful, the golangci-lint Action enforces `--out-format=github-action` but doesn't print file names or line numbers. ... — committed to jarrpa/odf-operator by jarrpa 3 years ago
- makefile: add target for running golangci-lint locally Apart from being generally useful, the golangci-lint Action enforces `--out-format=github-action` but doesn't print file names or line numbers. ... — committed to jarrpa/odf-operator by jarrpa 3 years ago
- makefile: add target for running golangci-lint locally Apart from being generally useful, the golangci-lint Action enforces `--out-format=github-action` but doesn't print file names or line numbers. ... — committed to jarrpa/odf-operator by jarrpa 3 years ago
- makefile: add target for running golangci-lint locally Apart from being generally useful, the golangci-lint Action enforces `--out-format=github-action` but doesn't print file names or line numbers. ... — committed to jarrpa/odf-operator by jarrpa 3 years ago
- makefile: add target for running golangci-lint locally Apart from being generally useful, the golangci-lint Action enforces `--out-format=github-action` but doesn't print file names or line numbers. ... — committed to jarrpa/odf-operator by jarrpa 3 years ago
- makefile: add target for running golangci-lint locally Apart from being generally useful, the golangci-lint Action enforces `--out-format=github-action` but doesn't print file names or line numbers. ... — committed to jarrpa/odf-operator by jarrpa 3 years ago
- makefile: add target for running golangci-lint locally Apart from being generally useful, the golangci-lint Action enforces `--out-format=github-action` but doesn't print file names or line numbers. ... — committed to jarrpa/odf-operator by jarrpa 3 years ago
- makefile: add target for running golangci-lint locally Apart from being generally useful, the golangci-lint Action enforces `--out-format=github-action` but doesn't print file names or line numbers. ... — committed to jarrpa/odf-operator by jarrpa 3 years ago
- makefile: add target for running golangci-lint locally Apart from being generally useful, the golangci-lint Action enforces `--out-format=github-action` but doesn't print file names or line numbers. ... — committed to jarrpa/odf-operator by jarrpa 3 years ago
- makefile: add target for running golangci-lint locally Apart from being generally useful, the golangci-lint Action enforces `--out-format=github-action` but doesn't print file names or line numbers. ... — committed to jarrpa/odf-operator by jarrpa 3 years ago
- makefile: add target for running golangci-lint locally Apart from being generally useful, the golangci-lint Action enforces `--out-format=github-action` but doesn't print file names or line numbers. ... — committed to jarrpa/odf-operator by jarrpa 3 years ago
- Improve golangci-lint action output See https://github.com/golangci/golangci-lint-action/issues/119 — committed to isimluk/xsd2go by isimluk 3 years ago
- Improve golangci-lint action output See https://github.com/golangci/golangci-lint-action/issues/119 — committed to isimluk/xsd2go by isimluk 3 years ago
- Improve golangci-lint action output See https://github.com/golangci/golangci-lint-action/issues/119 — committed to isimluk/xsd2go by isimluk 3 years ago
I guess to clarify I was just hoping the file names would be displayed inline with the
run golangci-lintsteps logs in addition to the github annotationsie. I marked the location in the logs with
///- when I run the action locally I see them appearWorkaround
Explainer
I tried to override output format with
Spplying multiple
--out-formatarguments to the linter works locally, unfortunately the github action has future proofing protection in place that saysSo in order to make the output useful in present you have to fool the future-proof protection like:
Friendly bump
With the new version of the action (v3.6.0) you can now provide extra args to add extra output format.
Example:
https://golangci-lint.run/usage/configuration/#output-configuration
Related to #769
Friendly bump.
I believe that showing file/line info in build log is absolutely a must. In cases when already existing project adds golangci-lint-action (microsoft/hcsshim#975 as an example), none of reported errors are in diff. Instead, they are in files that already exist. The same will happen for repos that update to a newer version of golangci-lint.
the action creates the comments, open the pull request changes page and you will see all issues. also the action does not allow overriding the format. If you want to see the list of issues in the jobs log, I would recommend you to add one more step:
don’t worry about the running time, the second run will reuse the cache. In my case the action takes around 10 minutes, but the additional step takes 10 seconds
Friendly bump…
Is there any news about this? i am currently trying to implement this in a github repo and not seeing which file and line an error belongs to in a direct way (having to check the full text based logs) is pretty annoying.
This doesn’t guarantee that files with violations were changed by that push or pull request. Trivial counter-example: initial pull request that adds golangci-lint-action to the repo.
As well as if one to run the linter as a workflow_dispatch against a certain branch (not as a pull request run), then annotations are useless, as there are no files to browse to check them.
So having line numbers in the action run log is very much awaited
Kindly ping. I have this issue too - annotation links are not working.
The problem will be fixed with golangci-lint v1.58: the file information (path, position) will be displayed.
https://github.com/golangci/golangci-lint/pull/4685
I just saw this again using 3.7.0 of the action in a private repo.
Should have included:
@stevenh glad you found a workaround!
Please note however that GitHub announced a while ago that the default shell was going to become PowerShell (
shell: pwsh) on Windows runners. Apparently yours is still usingshell: cmd, that’s why my suggested workaround didn’t work for you.cmdandpwshhave totally different syntaxes and behaviours regarding variables.Still, I would advise paying attention to deprecation notices and switch to
shell: pwshASAP to avoid surprises in the future.Splitting per OS with the following fixed the unknown flag failure on windows.
It doesn’t follow the same pattern as Linux etc as blank variables on Windows doesn’t expand.
If the solution is simply to pass the
--out-formattwice (which is technically what happens when the workaround described in https://github.com/golangci/golangci-lint-action/issues/119#issuecomment-981090648 is implemented), what prevents this format from becoming the default? Everybody gets the best of both worlds, right?@isimluk Thank you for the fix, using
I can now see the line and file names 👍🏻
@thebeline @SVilgelm sorry if this is something obvious that I’ve missed but in our case the annotations are actually on the wrong areas … what is the specific technical reason that this action can’t just print the lines to the output? Developers are used to looking at the output of failed actions and they know how to parse the output of
golangci-lint. If they don’t want to take the extra click to go look at the GitHub annotations, why should they have to? What is stopping us from both providing the annotations and the simple log output?I can confirm that in the event of an initial pull request that adds this to the repo, if configured with
only-new-issues: true, it will only run on a patch of the modified files in the PR.All of that being said, you are not wrong, the Action as it is currently implemented can be run in any context, however the output is only tailored for two specific contexts. I am working on a PR to resolve this.
That being said, while my above suggestion of
tabwould likely resolve your issue in your specific use-case, I apologize for just submitting a PR that fixes the bug that allowed settingout-format.For what it is worth, I am also going to be submitting a PR that will then address your use-case (as well as some others), so please keep an eye out and support it if it behaves as you desire.
Sure would be nice to see the affected filenames in the output on the GitHub website. It’s not even visible when I click “View raw logs”.
But I can repro the results by running golangci locally:
… and see the filenames that way. Not great, but that unblocks me 👍
yes. we can also move file line and col variables out of
::syntax and add probrem matcher file.https://github.com/actions/toolkit/blob/main/docs/problem-matchers.md
Because file name and line number is written in
::syntax, github is not show this information in github actions logs.I confirmed that.
link