From dfc7446d0b5b14e58e5d24d809579f1d924a3850 Mon Sep 17 00:00:00 2001 From: Robin Hahling Date: Tue, 14 Sep 2021 17:09:06 +0200 Subject: [PATCH] ci: use golangci-lint for static checks Signed-off-by: Robin Hahling --- .github/workflows/tests.yml | 19 ++++++------- .golangci.yml | 54 +++++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+), 11 deletions(-) create mode 100644 .golangci.yml diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 1a7de59..9e5c4fe 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -23,18 +23,15 @@ jobs: go-version: ${{ matrix.go-version }} - name: Checkout code uses: actions/checkout@v2 - - name: Format - if: matrix.go-version >= '1.17' - run: diff -u <(echo -n) <(gofmt -d .) + - name: Run static checks + uses: golangci/golangci-lint-action@v2 + with: + version: v1.42.1 + args: --config=.golangci.yml --verbose + skip-go-installation: true + skip-pkg-cache: true + skip-build-cache: true - name: Build run: go build - - name: Vet - run: go vet - - name: Install and run staticcheck - if: matrix.go-version >= '1.17' - run: | - go install honnef.co/go/tools/cmd/staticcheck@latest - staticcheck -version - staticcheck -- ./... - name: Run unit tests run: go test -v -race -cover diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 0000000..8dcba28 --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,54 @@ +# See https://golangci-lint.run/usage/configuration/ for available options. +# Also https://github.com/cilium/cilium/blob/master/.golangci.yaml as a +# reference. +linters: + disable-all: true + enable: + - asciicheck + - deadcode + - dogsled + - durationcheck + - errcheck + - errname + - errorlint + - exhaustive + - exportloopref + - forcetypeassert + - godot + - goerr113 + - gofmt + - goimports + - gosec + - gosimple + - govet + - ifshort + - ineffassign + - misspell + - nestif + - nilerr + - prealloc + - predeclared + - revive + - rowserrcheck + - staticcheck + - structcheck + - thelper + - typecheck + - unconvert + - unparam + - unused + - varcheck + +linters-settings: + gosimple: + go: "1.17" + govet: + enable-all: true + disable: + - fieldalignment + staticcheck: + go: "1.17" + stylecheck: + go: "1.17" + unused: + go: "1.17"