From d231a2364f50fa7c85014b994acef9d0a80c106c Mon Sep 17 00:00:00 2001 From: Dominic Evans Date: Mon, 3 Feb 2025 09:59:11 +0000 Subject: [PATCH] feat(ci): add dedicated staticcheck run As we've noted that a standlone run of staticcheck can find different issues compared with running it from golangci-lint, add a standalone run to github actions and remove it from the golangci-lint config Signed-off-by: Dominic Evans --- .github/actions/staticcheck-matchers.json | 16 ++++++++++++++++ .github/workflows/ci.yml | 9 +++++++++ .pre-commit-config.yaml | 4 ++-- 3 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 .github/actions/staticcheck-matchers.json diff --git a/.github/actions/staticcheck-matchers.json b/.github/actions/staticcheck-matchers.json new file mode 100644 index 000000000..6852bade4 --- /dev/null +++ b/.github/actions/staticcheck-matchers.json @@ -0,0 +1,16 @@ +{ + "problemMatcher": [ + { + "owner": "staticcheck", + "pattern": [ + { + "regexp": "^\\s*(.+\\.go):(?:(\\d+):(\\d+):)? (.*)", + "file": 1, + "line": 2, + "column": 3, + "message": 4 + } + ] + } + ] +} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8a2872373..e3b035958 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -34,6 +34,15 @@ jobs: uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 # v5.3.0 with: go-version: ${{ matrix.go-version }} + - name: Staticcheck + shell: bash + env: + BUILDTAGS: "functional" + VERSION: "v0.5.1" + run: | + go install "honnef.co/go/tools/cmd/staticcheck@${VERSION}" + echo "::add-matcher::./.github/actions/staticcheck-matchers.json" + $(go env GOPATH)/bin/staticcheck -tags "${BUILDTAGS}" ./... - name: golangci-lint env: GOFLAGS: -tags=functional diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1e64cc0d8..2aa1fcb1a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -32,10 +32,10 @@ repos: files: \.go$ args: [] - repo: https://github.com/gitleaks/gitleaks - rev: v8.21.2 + rev: v8.23.3 hooks: - id: gitleaks - repo: https://github.com/golangci/golangci-lint - rev: v1.61.0 + rev: v1.63.4 hooks: - id: golangci-lint