Use golangci-lint GitHub action.
- Rather than manually downloading and invoking golangci-lint, use the GitHub action provided by the developers. - Configure golangci with a config file rather than passing command line args. This enables the same config to be used locally and on CI without introducing duplication. It also allows much more flexibililty in configuration than using CLI args alone.
This commit is contained in:
parent
00b26f8b0a
commit
2d67a35ba5
10
.github/workflows/go.yml
vendored
10
.github/workflows/go.yml
vendored
@ -14,10 +14,12 @@ jobs:
|
||||
go-version: ${{ matrix.go }}
|
||||
- name: Check out source
|
||||
uses: actions/checkout@v2
|
||||
- name: Install Linters
|
||||
run: "curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(go env GOPATH)/bin v1.43.0"
|
||||
- name: Build
|
||||
run: go build ./...
|
||||
- name: Test
|
||||
run: |
|
||||
./run_tests.sh
|
||||
run: env GORACE="halt_on_error=1" go test -race ./...
|
||||
- name: Lint
|
||||
uses: golangci/golangci-lint-action@v2
|
||||
with:
|
||||
version: v1.44
|
||||
|
||||
|
||||
20
.golangci.yml
Normal file
20
.golangci.yml
Normal file
@ -0,0 +1,20 @@
|
||||
run:
|
||||
deadline: 10m
|
||||
|
||||
linters:
|
||||
disable-all: true
|
||||
enable:
|
||||
- asciicheck
|
||||
- deadcode
|
||||
- errcheck
|
||||
- gofmt
|
||||
- goimports
|
||||
- gosimple
|
||||
- govet
|
||||
- ineffassign
|
||||
- misspell
|
||||
- revive
|
||||
- structcheck
|
||||
- unconvert
|
||||
- unparam
|
||||
- unused
|
||||
25
run_tests.sh
25
run_tests.sh
@ -14,28 +14,5 @@ go version
|
||||
# run tests
|
||||
env GORACE="halt_on_error=1" go test -race ./...
|
||||
|
||||
# set output format for linter
|
||||
if [[ -v CI ]]; then
|
||||
OUT_FORMAT="github-actions"
|
||||
else
|
||||
OUT_FORMAT="colored-line-number"
|
||||
fi
|
||||
|
||||
# run linter
|
||||
golangci-lint run --disable-all --deadline=10m \
|
||||
--out-format=$OUT_FORMAT \
|
||||
--enable=gofmt \
|
||||
--enable=revive \
|
||||
--enable=govet \
|
||||
--enable=gosimple \
|
||||
--enable=unconvert \
|
||||
--enable=ineffassign \
|
||||
--enable=structcheck \
|
||||
--enable=goimports \
|
||||
--enable=misspell \
|
||||
--enable=unparam \
|
||||
--enable=deadcode \
|
||||
--enable=unused \
|
||||
--enable=errcheck \
|
||||
--enable=asciicheck
|
||||
|
||||
golangci-lint run
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user