From 162720438958f0dfd22c2550624918d221a14051 Mon Sep 17 00:00:00 2001 From: Jonathan Innis Date: Tue, 31 Oct 2023 11:12:14 -0700 Subject: [PATCH] Add GHA linting --- .github/actionlint-matcher.json | 17 +++++++++++++++++ .github/workflows/presubmit.yaml | 2 ++ .golangci.yaml | 8 ++++++++ Makefile | 1 + hack/toolchain.sh | 1 + 5 files changed, 29 insertions(+) create mode 100644 .github/actionlint-matcher.json diff --git a/.github/actionlint-matcher.json b/.github/actionlint-matcher.json new file mode 100644 index 0000000000..00c320db5f --- /dev/null +++ b/.github/actionlint-matcher.json @@ -0,0 +1,17 @@ +{ + "problemMatcher": [ + { + "owner": "actionlint", + "pattern": [ + { + "regexp": "^(?:\\x1b\\[\\d+m)?(.+?)(?:\\x1b\\[\\d+m)*:(?:\\x1b\\[\\d+m)*(\\d+)(?:\\x1b\\[\\d+m)*:(?:\\x1b\\[\\d+m)*(\\d+)(?:\\x1b\\[\\d+m)*: (?:\\x1b\\[\\d+m)*(.+?)(?:\\x1b\\[\\d+m)* \\[(.+?)\\]$", + "file": 1, + "line": 2, + "column": 3, + "message": 4, + "code": 5 + } + ] + } + ] +} \ No newline at end of file diff --git a/.github/workflows/presubmit.yaml b/.github/workflows/presubmit.yaml index 11c0a1aeeb..5ebf988b22 100644 --- a/.github/workflows/presubmit.yaml +++ b/.github/workflows/presubmit.yaml @@ -15,6 +15,8 @@ jobs: - uses: ./.github/actions/install-deps with: k8sVersion: ${{ matrix.k8sVersion }} + - name: Enable the actionlint matcher + run: echo "::add-matcher::.github/actionlint-matcher.json" - run: K8S_VERSION=${{ matrix.k8sVersion }} make presubmit - uses: shogo82148/actions-goveralls@v1 with: diff --git a/.golangci.yaml b/.golangci.yaml index 4d93316358..bd02a142db 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -40,6 +40,14 @@ linters-settings: min-complexity: 11 govet: check-shadowing: true + revive: + rules: + - name: dot-imports + disabled: true + stylecheck: + dot-import-whitelist: + - "github.com/onsi/ginkgo/v2" + - "github.com/onsi/gomega" misspell: locale: US ignore-words: [] diff --git a/Makefile b/Makefile index 3554066b22..7bde6d5890 100644 --- a/Makefile +++ b/Makefile @@ -47,6 +47,7 @@ verify: ## Verify code. Includes codegen, dependencies, linting, formatting, etc if [ "${CI}" = true ]; then\ exit 1;\ fi;} + actionlint -oneline download: ## Recursively "go mod download" on all directories where go.mod exists $(foreach dir,$(MOD_DIRS),cd $(dir) && go mod download $(newline)) diff --git a/hack/toolchain.sh b/hack/toolchain.sh index 9c426aade4..5b4a3e09e7 100755 --- a/hack/toolchain.sh +++ b/hack/toolchain.sh @@ -21,6 +21,7 @@ tools() { go install -tags extended github.com/gohugoio/hugo@v0.110.0 go install golang.org/x/vuln/cmd/govulncheck@latest go install github.com/onsi/ginkgo/v2/ginkgo@latest + go install github.com/rhysd/actionlint/cmd/actionlint@latest if ! echo "$PATH" | grep -q "${GOPATH:-undefined}/bin\|$HOME/go/bin"; then echo "Go workspace's \"bin\" directory is not in PATH. Run 'export PATH=\"\$PATH:\${GOPATH:-\$HOME/go}/bin\"'."