golangci / golangci-lint-action Goto Github PK
View Code? Open in Web Editor NEWOfficial GitHub Action for golangci-lint from its authors
Home Page: https://github.com/marketplace/actions/golangci-lint
License: MIT License
Official GitHub Action for golangci-lint from its authors
Home Page: https://github.com/marketplace/actions/golangci-lint
License: MIT License
Recently, GitHub has deprecated the set-env
and add-path
commands that can be printed to stdout by an action, refer to https://github.blog/changelog/2020-10-01-github-actions-deprecating-set-env-and-add-path-commands/
golangci-lint-action
is making use of these in a couple of places, thus causing deprecation warnings in the action's annotations (and probably will stop working some day).
The deprecated commands should be replaced by using newly introduced environment files
See golangci/golangci-lint#1072.
The issue is that secrets are not passed to workflows that are triggered by a pull request from a fork.
Currently this action uses github token to find the latest patch version of specified minor release.
My idea is to generate version-maps.json
in golangci-lint
repository and download it for detecting a last patch version. Using GitHub API without tokens can fail because of 60 req/hour rate limit.
I'm using the linter action in https://github.com/andig/evcc/pull/497/checks?check_run_id=1474850871:
Go artefacts are already cached:
steps:
- name: Setup
uses: actions/setup-go@v2
with:
go-version: ^1.14
id: go
- uses: actions/cache@v2
with:
path: |
~/go/pkg/mod
**/node_modules
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-go-
...
- name: Lint
uses: golangci/golangci-lint-action@v2
with:
version: v1.33
This leads to large amount of errors in the action log:
Installed Go in 79ms
Requested golangci-lint 'v1.33', using 'v1.33.0', calculation took 226ms
Installing golangci-lint v1.33.0...
Downloading https://github.com/golangci/golangci-lint/releases/download/v1.33.0/golangci-lint-1.33.0-linux-amd64.tar.gz ...
Received 92009212 of 92009212 (100.0%), 146.0 MBs/sec
Cache Size: ~88 MB (92009212 B)
/bin/tar --use-compress-program zstd -d -xf /home/runner/work/_temp/1fe13742-cdde-4fcd-88d4-a1bcad1244b3/cache.tzst -P -C /home/runner/work/evcc/evcc
/bin/tar xz --warning=no-unknown-keyword -C /home/runner -f /home/runner/work/_temp/11aa6afa-628a-4b5d-94a5-40d55abea5bd
Error: /bin/tar: ../../../go/pkg/mod/gopkg.in/[email protected]/ini.go: Cannot open: File exists
Error: /bin/tar: ../../../go/pkg/mod/gopkg.in/[email protected]/bench_test.go: Cannot open: File exists
...
Error: /bin/tar: ../../../go/pkg/mod/golang.org/x/[email protected]/modfile/rule.go: Cannot open: File exists
Error: /bin/tar: ../../../go/pkg/mod/golang.org/x/[email protected]/modfile/print.go: Cannot open: File exists
/bin/tar: Exiting with failure status due to previous errors
Warning: Tar failed with error: The process '/bin/tar' failed with exit code 2
Prepared env in 3125ms
The last release (#34) brakes all the projects using golangci-lint-action@v1
and version = v1.27
(easy fix -> bump at v1.28
).
Example: moul/golang-repo-template#62
What do you think about adding a more explicit warning when the user's version
is older than a minimal_supported_version
constant you keep updated internally in this repo?
Here is the text output:
Run golangci/golangci-lint-action@v1
prepare environment
go env
Installed Go in 1208ms
Primary analysis cache key is 'golangci-lint.cache-2654-238be49be180c14210a559dba9299a95664cd7c1', restore keys are 'golangci-lint.cache-2654- | golangci-lint.cache-'
Requested golangci-lint 'v1.27', using 'v1.27.0', calculation took 1272ms
Installing golangci-lint v1.27.0...
Downloading https://github.com/golangci/golangci-lint/releases/download/v1.27.0/golangci-lint-1.27.0-linux-amd64.tar.gz ...
/bin/tar xz --warning=no-unknown-keyword -C /home/runner -f /home/runner/work/_temp/af26c6ab-4e05-4501-81c9-58aa87b6ab18
Installed golangci-lint into /home/runner/golangci-lint-1.27.0-linux-amd64/golangci-lint in 1486ms
Cache Size: ~69 MB (72365947 B)
/bin/tar -xz -f /home/runner/work/_temp/cebe5e9d-2ff8-424c-855a-9a2e7b58476d/cache.tgz -P -C /home/runner/work/draughthub-daemon/draughthub-daemon
Cache restored from key: golangci-lint.cache-2654-238be49be180c14210a559dba9299a95664cd7c1
Restored cache for golangci-lint from key 'golangci-lint.cache-2654-238be49be180c14210a559dba9299a95664cd7c1' in 8392ms
Prepared env in 8392ms
run golangci-lint
Running [/home/runner/golangci-lint-1.27.0-linux-amd64/golangci-lint run --out-format=github-actions] in [] ...
golangci-lint found no issues
Ran golangci-lint in 30615ms
Do you have any idea what is going on?
Thanks in advance for the help!
It seems there's a limit of 10 annotations per run currently, even when I set max-issues-per-linter
and max-same-issues
to 0.
I have a feeling this also causes problem with the detection of new
items in PRs, as that doesn't seem to work reliably for me.
Tag v2
wasn't updated after v2.4.0
was tagged. It should be moved for golangci/golangci-lint-action@v2
to use 2.4.0.
How can I make use of only-new-issues
, in case when PR is merged to master. Any way can I use this?
It works fine with PR tests but throws error on merge
I have this use case and want to run in github action. Can someone please help?
golangci-lint run --new-from-rev=$$(git merge-base origin/master HEAD) ./...
Like golangci.com has worked.
They look similar to comments, but they don't appear in the comments list and on main page of a pull request.
The current builder for a list of userArgNames
removes all -
characters, and therefore does not prevent any of the userArg
settings it continues to check for, including out-format
.
const userArgNames = new Set<string>()
userArgs
.split(/\s/)
.map((arg) => arg.split(`=`)[0])
.filter((arg) => arg.startsWith(`-`))
.forEach((arg) => {
userArgNames.add(arg.replace(`-`, ``))
})
if (userArgNames.has(`out-format`)) {
throw new Error(`please, don't change out-format for golangci-lint: it can be broken in a future`)
}
On one hand this is a bug. On the other hand, fixing this to do what it is supposed to may break many installations of this action...
I manage my changelog by hand and wrote a custom tool for my project to extract the appropriate section from the changelog and add that as release notes. But the solution proposed in the documentation doesn't work with the action. It works locally, so I guess the issue is related to the action.
This is the workflow step:
- name: Release
uses: goreleaser/goreleaser-action@v2
with:
args: release --rm-dist --release-notes <(./bin/changelog-extractor -f=CHANGELOG.md -t=${{ steps.tagName.outputs.tag }})
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
This results in the following output:
๐ Running GoReleaser...
/opt/hostedtoolcache/goreleaser-action/0.145.0/x64/goreleaser release --rm-dist --release-notes <(./bin/changelog-extractor -f=CHANGELOG.md -t=v0.1.0)
โจฏ command failed error=unknown shorthand flag: 't' in -t=v0.1.0)
Error: The process '/opt/hostedtoolcache/goreleaser-action/0.145.0/x64/goreleaser' failed with exit code 1
Look's like with golangci-lint-action I can't use golangci-lint with minor patches, for example, version: v1.28.3
is not working. Is this behavior expected?
Really appreciating this action, and it's ability to annotate PRs.
For many of the lint / vet rules, I think there are somewhat straightforward fixes. It would be awesome if this action could make suggested changes when possible (https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/incorporating-feedback-in-your-pull-request). Is this at all feasible?
Generate version-maps.json in golangci-lint repository and download it for detecting a last patch version. Using GitHub API without tokens can fail because of 60 req/hour rate limit.
But maybe we will need it again for leaving comments instead of annotations in #5. Need to research.
Even if we need it - we can make it optional only when comments are needed.
Config
- uses: golangci/golangci-lint-action@v2
with:
version: v1.37.0
skip-go-installation: true
skip-pkg-cache: true
skip-build-cache: true
Results with:
Warning: Unexpected input(s) 'skip-go-installation', 'skip-pkg-cache', 'skip-build-cache', valid inputs are ['version', 'args', 'working-directory', 'github-token', 'only-new-issues']
Greetings,
Thanks for the excellent tool.
I am using golangci-lint-action for the first time and my files are being linted correctly.
However, after every run, it says the following in the "Post Run actions/checkout@v2" step:
Post job cleanup.
Cache hit occurred on the primary key golangci-lint.cache-2656-nogomod, not saving cache.
Is this normal?
For reference, this is the code that I am using to call golangci-lint-action.
yeah, we need to investigate how to automate this as well. The main entry point is coming from this line https://github.com/golangci/golangci-lint-action/blob/master/action.yml#L27
Originally posted by @sayboras in #54 (comment)
I am interested in using this Github Action along with a private linter but this isn't possible at the moment because the release builds use CGO_ENABLED=0, while CGO_ENABLED=1 is required to use plugins (related issue: golangci/golangci-lint#1276)
The best solution I can come up with is to make the download URL configurable, where if a custom URL is set that is what the function getAssestURL returns. This would let users build and deploy a version of golangci-lint with CGO_ENABLED=1 and host it somewhere, and still use this github action.
I'd be happy to make a pr to address this, but would like feedback to make sure this is the correct approach? because from the issue linked above it seems this is currently a blocker to use private linters.
Currently, the version parameter must be set to vx.y
, but golangci-lint releases minor versions pretty rapidly, so for side projects this means the version used on CI is quickly outdated, or one has to babysit the CI very frequently. In fact, the README example is already out of date.
IMO CI is mostly a set-and-forget thing for most people's side projects, and I can't really see the benefit the pinning golangci-lint to a minor release, so this restriction seems to do a disservice.
Would it be possible to support version: latest
or version: ^v1.27
or something to that effect?
How can I use private git repositories as go modules dependencies?
For Go projects, I use tools.go
to specify the tools the project depends on and pin the version in the go.mod
file. This is pretty convenient. It would be awesome to have the action infer the version from the go.mod
file. When upgrading, this makes it one file less to update the golangci-lint
version.
With some guidance, I can probably tackle this. I'm just completely new to GitHub Actions.
I'm always frustrated when a new update of golangci-lint is available, I need to find it out by myself.
I want the GitHub action to create an issue or PR when an update is available. A issue is enough to let me know that there's an update of golangci-lint
is available. A PR would be great though.
I didn't consider a solution by myself yet.But I have subscribed to release notification on GitHub. But I almost always forget which of the repositories I have updated or not.
Thank you!
Please include the following information:
- 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
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 version && go env
1.15
https://github.com/knative/networking/pull/233/checks?check_run_id=1275974348
I had to view the 'files changed' page to see the lints
Hi. We are using golangci-lint-action v2.5.1 with golangci-lint v1.38.0
When running golangci-lint in the Github actions it returns weird errors https://github.com/iotaledger/goshimmer/runs/2174488190
Running [/home/runner/golangci-lint-1.38.0-linux-amd64/golangci-lint run --out-format=github-actions --timeout=10m] in [] ...
Error: unlambda: replace `func(c echo.Context) error {
return ledgerstateAPI.GetTransaction(c)
}` with `ledgerstateAPI.GetTransaction` (gocritic)
Error: unlambda: replace `func(c echo.Context) error {
return ledgerstateAPI.GetTransactionMetadata(c)
}` with `ledgerstateAPI.GetTransactionMetadata` (gocritic)
Error: unlambda: replace `func(c echo.Context) error {
return ledgerstateAPI.GetTransactionAttachments(c)
}` with `ledgerstateAPI.GetTransactionAttachments` (gocritic)
Error: unlambda: replace `func(c echo.Context) error {
return ledgerstateAPI.GetOutput(c)
}` with `ledgerstateAPI.GetOutput` (gocritic)
Error: issues found
Ran golangci-lint in 24151ms
The problem is that the code from the alerts doesn't exist in the repository. And when I run golangci-lint locally I don't see any alerts as expected.
I tried to disable the cache in actions with skip-pkg-cache
parameter, but it didn't help I see the same errors in the Github actions log, see https://github.com/iotaledger/goshimmer/runs/2174517258
I need to run some code generation before executing the action (go generate ./...
). How can I do that? It seems it's not possible to do this right now because the action is expected to run without any previous go commands:
/bin/tar: ../../../go/pkg/mod/github.com/takuoki/[email protected]/.circleci/config.yml: Cannot open: File exists
61
##[error]/bin/tar: ../../../go/pkg/mod/github.com/takuoki/[email protected]/gocase_test.go: Cannot open: File exists
62
/bin/tar: ../../../go/pkg/mod/github.com/takuoki/[email protected]/LICENSE: Cannot open: File exists
63
/bin/tar: ../../../go/pkg/mod/github.com/takuoki/[email protected]/README.md: Cannot open: File exists
64
##[error]/bin/tar: ../../../go/pkg/mod/github.com/takuoki/[email protected]/gocase.go: Cannot open: File exists
65
##[error]/bin/tar: ../../../go/pkg/mod/github.com/takuoki/[email protected]/example_test.go: Cannot open: File exists
66
/bin/tar: ../../../go/pkg/mod/github.com/takuoki/[email protected]/go.mod: Cannot open: File exists
67
##[error]/bin/tar: ../../../go/pkg/mod/github.com/iancoleman/[email protected]/doc.go: Cannot open: File exists
68
##[error]/bin/tar: ../../../go/pkg/mod/github.com/iancoleman/[email protected]/camel_test.go: Cannot open: File exists
69
##[error]/bin/tar: ../../../go/pkg/mod/github.com/iancoleman/[email protected]/snake_test.go: Cannot open: File exists
70
##[error]/bin/tar: ../../../go/pkg/mod/github.com/iancoleman/[email protected]/camel.go: Cannot open: File exists
71
##[error]/bin/tar: ../../../go/pkg/mod/github.com/iancoleman/[email protected]/snake.go: Cannot open: File exists
72
/bin/tar: ../../../go/pkg/mod/github.com/iancoleman/[email protected]/LICENSE: Cannot open: File exists
73
/bin/tar: ../../../go/pkg/mod/github.com/iancoleman/[email protected]/README.md: Cannot open: File exists
74
/bin/tar: ../../../go/pkg/mod/github.com/iancoleman/[email protected]/.travis.yml: Cannot open: File exists
75
##[error]/bin/tar: ../../../go/pkg/mod/github.com/iancoleman/[email protected]/numbers.go: Cannot open: File exists
It seems the action itself works, but the errors don't look very good
.yaml file
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-latest, ubuntu-latest]
include:
- os: windows-latest
PACKAGE: windows
- os: ubuntu-latest
PACKAGE: ubuntu
steps:
- name: Set up Go 1.13
uses: actions/setup-go@v1
with:
go-version: 1.13
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@v2
- name: golangci-lint
uses: golangci/golangci-lint-action@v1
with:
version: v1.27
On windows I get following error
Running [D:\a\_temp\746ef7d1-0c3f-4a2d-8be1-22d2958a64cc\golangci-lint-1.27.0-linux-amd64\golangci-lint run --out-format=github-actions] ...
'D:\a\_temp\746ef7d1-0c3f-4a2d-8be1-22d2958a64cc\golangci-lint-1.27.0-linux-amd64\golangci-lint' is not recognized as an internal or external command,
operable program or batch file.
We run this in some of our projects, and thank you all for the tool; it's fantastic!
I am noticing that the issues.new-from-rev: master
setting in our .golangci.yml
configuration file isn't effective, and this warning is in our GH Actions log:
level=warning msg="[runner] Can't process result by diff processor: can't prepare diff by revgrep: could not read git repo: error executing git diff \"master\" \"\": exit status 128"
Does it seem like the Action can't find the current revision hash to diff against master
?
I know that annotations don't support markdown
, and I have no experience with developing actions, but I do know that in Pull Requests there is a "Review" process, maybe if the action could detect that it is inside a PR, it could "start" a "Review" adding comments to the effected lines of the PR? That would provide a lot more flexibility.
There may be good reason for not letting this task restore, cache or download modules. E.g. in our case, we have private dependencies that require setting the GOPRIVATE
environment variable in order to resolve all dependencies. Besides, as we already save and restore the module cache for tests, why not reuse it for lint.
Therefore, having a way to turn off module cache, in the same way you can configure to not install go, would be very handy.
The linter github action doesn't allow specifying a Go version. It overwrtes it to 1
in https://github.com/golangci/golangci-lint-action/blob/1d3f25b/src/install.ts#L60.
It would be very useful if the linter picked the Go version specified in go.mod or at least had an action parameter. I made a working PoC in https://github.com/x1ddos/golangci-lint-action/commit/6f8897f but it's for the action version 1.2.2.
We have a project which can't upgrade to the latest go1.15 and had to remove the action in BitBoxSwiss/bitbox-wallet-app#982.
This used to exist in the golangci.com default configuration, but it's entirely unclear how to achieve this with the GitHub action. I've tried using the .golangci.yml configuration adapted from the YAML here, to no avail; I'd like to just leave it as default except for this.
issues:
new: true
Using the following configuration:
name: golangci-lint
on:
push:
tags:
- v*
branches:
- master
pull_request:
jobs:
golangci:
name: lint
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-latest, windows-latest]
steps:
- uses: actions/checkout@v2
- name: golangci-lint
uses: golangci/golangci-lint-action@v1
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.29
It will fail, as it tries to use the linux compiled binary. The reason this won't work for our project is that we have OS
specific files, such as foo_darwin.go
and foo_windows.go
. I tested golangci-lint locally, and it will only lint files on that operating system, not all files (which makes sense).
Here is an example of my output locally:
$ golangci-lint run
greet/foo_darwin.go:11:1: receiver name k should be consistent with previous receiver name g for Greeter (golint)
func (k Greeter) By() {
^
corylanou@Corys-MacBook-Pro-Primary:~/tmp/go-lint
$ GOOS=windows golangci-lint run
greet/foo_windows.go:11:1: receiver name k should be consistent with previous receiver name g for Greeter (golint)
func (k Greeter) By() {
^
How do we go about specifying an action that knows to bring down the proper pre-compiled binary?
Hello,
I have a simplified mono-repo with a Github action, all bellow.
I took the example from the How to use section and modified:
runs-on: ubuntu-20.04
with.version: v1.36
(currently installed in my system)skip-go-installation: true
because I want to control the Go version I'm usingThen I get the following warning:
Any suggestions:
.
โโโ modlinterabs
โโโ go.mod
โโโ greeterabs
โ โโโ logic.go
โโโ main.go
name: golangci-lint
on:
push:
tags:
- v*
branches:
- master
- main
pull_request:
jobs:
golangci:
name: lint
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.15
- name: golangci-lint
uses: golangci/golangci-lint-action@v2
with:
version: v1.36
working-directory: modlinterabs
args: -v
skip-go-installation: true
as can be seen in https://github.com/go-hep/hep/runs/734154654
golangci-lint-action
is failing to properly analyze my PR:
run golangci-lint
Running [/home/runner/golangci-lint-1.27.0-linux-amd64/golangci-lint run --out-format=github-actions] in [] ...
level=warning msg="[linters context/goanalysis] Failed to get persisted facts: failed to get data from low-level cache by key buildir/facts for package syscall: failed to stat file /home/runner/.cache/golangci-lint/c6/c6625a8d36bd5174cd58930f729ee0622b0b8c594cd3bb7d16bba626c689c221-d: stat /home/runner/.cache/golangci-lint/c6/c6625a8d36bd5174cd58930f729ee0622b0b8c594cd3bb7d16bba626c689c221-d: no such file or directory"
[...]
package vgeps: failed to stat file /home/runner/.cache/golangci-lint/fd/fde1c0f5fc87bde035ce63a319d9f36c4b3e9367c96b58916b8ae329cd2b2c9e-d: stat /home/runner/.cache/golangci-lint/fd/fde1c0f5fc87bde035ce63a319d9f36c4b3e9367c96b58916b8ae329cd2b2c9e-d: no such file or directory"
level=error msg="Timeout exceeded: try increasing it by passing --timeout option"
could this be addressed?
thanks.
Can be useful for monorepos. Example where it's need - https://github.com/ironPeakServices/iron-redis.
Hello! I have updated my project code to Go 1.16, including the methods moving away from ioutil
to os
/io
packages.
And now our Github Action is failing with what makes me believe is a mismatch in Go versions.
Locally I am able to successfully execute with docker run ... golangci/golangci-lint:v1.38.0 golangci-lint run -v
- 1.38 works on my Go 1.16 updated code.
Now under CI using this action I am getting: https://github.com/kool-dev/kool/pull/288/checks?check_run_id=2088452091
I am leaned to think it can be some issue due to caching...
I am gonna continue my own investigation trying to fix it, but since didn't find a report here on the matter decided to open the ticket already in case someone can help or be helped afterward.
Context:
We have a repository which has a structure similar to
- root module
-- pkgA submodule
-- pkgB submodule
-- etc...
root
module has no go files.
Each pkg{A,B,...}
module has code+tests and separate go.mod+go.sum+vendor files.
Issue:
On every PR we are running
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-go@v1
with:
go-version: '1.15.x'
- name: Run tests
# Go into each folder in the repo and run tests 10 times with the race detector
run: for d in ./*/ ; do (cd "$d" && go test -race -count 10 ./...); done
golangci:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install golangci-lint
uses: golangci/[email protected]
with:
version: v1.26
args: --modules-download-mode vendor --config ./.golangci.yml ./...
But it fails with ERRO Running error: context loading failed: no go files to analyze
Question:
Is there a way to use this action to run linter in all the folders but without creating separate jobs with a matrix?
Hi,
I tried setting both working-directory
and only-new-issues
but got: Error: options working-directory and only-new-issues aren't compatible
I am working on a monorepo and would like to be able to get only new issues from the linter. How hard would be to allow it?
I have a project that supports multiple languages, and all of the go code is in a well-behaved subdirectory:
- frontend
- proto
- secrets
- gocode
- go.mod
- go.sum
- cmd
- server
- main.go
I configured the golangci-lint-action
as such:
jobs:
lint:
name: "Lint"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
# Runs a set of commands using the runners shell
- name: Lint
uses: golangci/golangci-lint-action@v1
with:
version: v1.26
working-directory: gocode
I am using the default .golangci.yml
configuration file. I tested a change that should fail the linter and I get the error correctly in the GitHub actions format:
##[error]func `unused` is unused (unused)
However, the error doesn't show up as an annotation on the pull request. Upon further investigation, it seems like the real out (from running locally) is this:
~/Projects/shepherd/gocode
.venv โฏ ~/go/bin/golangci-lint run --out-format github-actions
::error file=cmd/server/main.go,line=5,col=6::`unused` is unused (deadcode)
The problem appears to be that the file is outputted relative to the working directory and not the root of the GitHub repository (i.e. the path should be gocode/cmd/server/main.go
) which seems to be preventing GitHub from correctly handling this.
This appear to be a bug. Can this be fixed with an option of some kind? Or is there an existing option that handles this case?
Failed to run: Error: ENOENT: no such file or directory, open 'go.mod', Error: ENOENT: no such file or directory, open 'go.mod'
at Object.openSync (fs.js:440:3)
at Object.readFileSync (fs.js:342:35)
at getRequestedLintVersion (/home/runner/work/_actions/golangci/golangci-lint-action/v2/dist/run/index.js:2286:28)
at Object.<anonymous> (/home/runner/work/_actions/golangci/golangci-lint-action/v2/dist/run/index.js:2323:32)
at Generator.next (<anonymous>)
at /home/runner/work/_actions/golangci/golangci-lint-action/v2/dist/run/index.js:2233:71
at new Promise (<anonymous>)
at module.exports.__awaiter (/home/runner/work/_actions/golangci/golangci-lint-action/v2/dist/run/index.js:2229:12)
at Object.findLintVersion (/home/runner/work/_actions/golangci/golangci-lint-action/v2/dist/run/index.js:2321:12)
at /home/runner/work/_actions/golangci/golangci-lint-action/v2/dist/run/index.js:6724:47
Error: ENOENT: no such file or directory, open 'go.mod'
It was working yesterday but now is broken on changed repos.
Github actions setup:
# LINTING STARTS HERE
- name: Run golangci-lint Code Performance
uses: golangci/golangci-lint-action@v2
with:
working-directory: ${{ matrix.lintfolder }}
args: --issues-exit-code=0 --tests=false --skip-dirs=test -E=exportloopref -E=interfacer -E=maligned -E=prealloc
The description for input field is as per below:
https://github.com/golangci/golangci-lint-action/blob/master/action.yml#L7
version:
description: 'version of golangci-lint to use in form of v1.2.3'
required: true
However, passing the value v1.27.0 returns below error
Failed to run: Error: requested golangci-lint version 'v1.27.0' was specified with the patch version, need specify only minor version, Error: requested golangci-lint version 'v1.27.0' was specified with the patch version, need specify only minor version
For example:
lint-go:
name: Lint Go code
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Run golangci-lint for dice
uses: golangci/golangci-lint-action@v1
with:
version: v1.26
working-directory: ./dice
args: --timeout 5m
Output err:
Running [/home/runner/golangci-lint-1.26.0-linux-amd64/golangci-lint run --out-format=github-actions --path-prefix=./dice --timeout 5m] in [/home/runner/work/aws-solutions-assembler/aws-solutions-assembler/dice] ...
level=error msg="Can't get config for command line: can't parse args: unknown flag: --path-prefix"
Question
How do I pass the .golangci-lint.yml
the configuration file in the following action?
Currently, the action uses the set-env
and add-path
commands which have recently been deprecated by Github as remediation to $SUBJECT. They have already been replaced with new mechanisms which offer the same functionality. Please refer to:
When running the action users get warnings about the deprecated actions.
Instead of the forked one, see actions/cache#293
https://github.com/silenceper/gowatch/pull/18/checks?check_run_id=722754687
ERROR:
Installed Go in 77ms
Primary analysis cache key is 'golangci-lint.cache-2630-859920e3b25ff717a0784f9487e35cf40a5fdc1f', restore keys are 'golangci-lint.cache-2630- | golangci-lint.cache-'
Requested golangci-lint 'v1.26', using 'v1.26.0', calculation took 152ms
Installing golangci-lint v1.26.0...
Downloading https://github.com/golangci/golangci-lint/releases/download/v1.26.0/golangci-lint-1.26.0-linux-amd64.tar.gz ...
/bin/tar xz --warning=no-unknown-keyword -C /home/runner -f /home/runner/work/_temp/896dbb3b-38ba-4b3a-80ae-948886b0a1ea
Cache Size: ~11 MB (11729781 B)
/bin/tar -xz -f /home/runner/work/_temp/c9eac72e-6931-4b7d-9a02-499333b10684/cache.tgz -P -C /home/runner/work/gowatch/gowatch
/bin/tar: ../../../go/pkg/mod/github.com/howeyc/[email protected]/CONTRIBUTING.md: Cannot open: File exists
##[error]/bin/tar: ../../../go/pkg/mod/github.com/howeyc/[email protected]/fsnotify_test.go: Cannot open: File exists
##[error]/bin/tar: ../../../go/pkg/mod/github.com/howeyc/[email protected]/example_test.go: Cannot open: File exists
/bin/tar: ../../../go/pkg/mod/github.com/howeyc/[email protected]/.gitignore: Cannot open: File exists
##[error]/bin/tar: ../../../go/pkg/mod/github.com/howeyc/[email protected]/fsnotify_open_darwin.go: Cannot open: File exists
/bin/tar: ../../../go/pkg/mod/github.com/howeyc/[email protected]/CHANGELOG.md: Cannot open: File exists
/bin/tar: ../../../go/pkg/mod/github.com/howeyc/[email protected]/LICENSE: Cannot open: File exists
actions config:
name: Go
on: [push,pull_request]
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
go-version: ^1.13
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@v2
- name: Get dependencies
run: |
go get -v -t -d ./...
if [ -f Gopkg.toml ]; then
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
dep ensure
fi
- name: Lint Go Code
run: |
export PATH=$PATH:$(go env GOPATH)/bin # temporary fix. See https://github.com/actions/setup-go/issues/14
go get -u golang.org/x/lint/golint
go vet ./...
golint -set_exit_status $(go list ./...)
- name: Build
run: go build -v .
It is no problem to run the golangci-lint run
command locally, is my github action configuration wrong?
Currently, only version X.Y is supported, it is internally derive the last patch version of golangci-lint. However, sometimes, I would love to have some experience with my local dev and CI.
Propose: Support X.Y.Z version in config.
Not sure is you can do anything about this or it should be reported somewhere at GH marketplace, opened issue here just to let you know.
Is there an option equivalent to the --enable
flag?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.