From 3446de3226e27f454a5d03adb800f91e1e27a103 Mon Sep 17 00:00:00 2001 From: Mateus Oliveira Date: Fri, 13 Dec 2024 11:40:33 -0300 Subject: [PATCH] fix: Check linter configuration Signed-off-by: Mateus Oliveira --- .github/workflows/lint-sample.yml | 3 +++ .github/workflows/lint.yml | 2 ++ .golangci.yml | 8 ++++++-- Makefile | 4 ++++ docs/book/src/cronjob-tutorial/testdata/project/Makefile | 4 ++++ docs/book/src/getting-started/testdata/project/Makefile | 4 ++++ .../src/multiversion-tutorial/testdata/project/Makefile | 4 ++++ .../golang/v4/scaffolds/internal/templates/makefile.go | 4 ++++ testdata/project-v4-multigroup/Makefile | 4 ++++ testdata/project-v4-with-plugins/Makefile | 4 ++++ testdata/project-v4/Makefile | 4 ++++ 11 files changed, 43 insertions(+), 2 deletions(-) diff --git a/.github/workflows/lint-sample.yml b/.github/workflows/lint-sample.yml index e7839eb8652..a28c23bbbea 100644 --- a/.github/workflows/lint-sample.yml +++ b/.github/workflows/lint-sample.yml @@ -29,6 +29,9 @@ jobs: - name: Prepare ${{ matrix.folder }} working-directory: ${{ matrix.folder }} run: go mod tidy + - name: Check linter configuration + working-directory: ${{ matrix.folder }} + run: make lint-config - name: Run linter uses: golangci/golangci-lint-action@v6 with: diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 8f84da91633..b041718c9fe 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -21,6 +21,8 @@ jobs: uses: actions/setup-go@v5 with: go-version-file: go.mod + - name: Check linter configuration + run: make lint-config - name: Run linter uses: golangci/golangci-lint-action@v6 with: diff --git a/.golangci.yml b/.golangci.yml index f768e89d686..8ddfd42b1c4 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -18,7 +18,11 @@ issues: linters-settings: govet: - enable=fieldalignment: true + enable-all: true + disable: + - fieldalignment + - nilness + - shadow revive: rules: # The following rules are recommended https://github.com/mgechev/revive#recommended-configuration @@ -28,7 +32,7 @@ linters-settings: - name: dot-imports arguments: # dot import should be ONLY allowed for ginkgo testing packages - allowedPackages: + - allowedPackages: - "github.com/onsi/ginkgo/v2" - "github.com/onsi/gomega" - name: error-return diff --git a/Makefile b/Makefile index acdc7fce14d..9974ce571bd 100644 --- a/Makefile +++ b/Makefile @@ -97,6 +97,10 @@ generate-charts: build ## Re-generate the helm chart testdata only check-docs: ## Run the script to ensure that the docs are updated ./hack/docs/check.sh +.PHONY: lint-config +lint-config: golangci-lint ## Verify golangci-lint linter configuration + $(GOLANGCI_LINT) config verify + .PHONY: lint lint: golangci-lint yamllint ## Run golangci-lint linter & yamllint $(GOLANGCI_LINT) run diff --git a/docs/book/src/cronjob-tutorial/testdata/project/Makefile b/docs/book/src/cronjob-tutorial/testdata/project/Makefile index b1c2661bc45..a78ffa34b45 100644 --- a/docs/book/src/cronjob-tutorial/testdata/project/Makefile +++ b/docs/book/src/cronjob-tutorial/testdata/project/Makefile @@ -82,6 +82,10 @@ test-e2e: manifests generate fmt vet ## Run the e2e tests. Expected an isolated } go test ./test/e2e/ -v -ginkgo.v +.PHONY: lint-config +lint-config: golangci-lint ## Verify golangci-lint linter configuration + $(GOLANGCI_LINT) config verify + .PHONY: lint lint: golangci-lint ## Run golangci-lint linter $(GOLANGCI_LINT) run diff --git a/docs/book/src/getting-started/testdata/project/Makefile b/docs/book/src/getting-started/testdata/project/Makefile index 221ae92d1fe..6110cae4da5 100644 --- a/docs/book/src/getting-started/testdata/project/Makefile +++ b/docs/book/src/getting-started/testdata/project/Makefile @@ -78,6 +78,10 @@ test-e2e: manifests generate fmt vet ## Run the e2e tests. Expected an isolated } go test ./test/e2e/ -v -ginkgo.v +.PHONY: lint-config +lint-config: golangci-lint ## Verify golangci-lint linter configuration + $(GOLANGCI_LINT) config verify + .PHONY: lint lint: golangci-lint ## Run golangci-lint linter $(GOLANGCI_LINT) run diff --git a/docs/book/src/multiversion-tutorial/testdata/project/Makefile b/docs/book/src/multiversion-tutorial/testdata/project/Makefile index b1c2661bc45..a78ffa34b45 100644 --- a/docs/book/src/multiversion-tutorial/testdata/project/Makefile +++ b/docs/book/src/multiversion-tutorial/testdata/project/Makefile @@ -82,6 +82,10 @@ test-e2e: manifests generate fmt vet ## Run the e2e tests. Expected an isolated } go test ./test/e2e/ -v -ginkgo.v +.PHONY: lint-config +lint-config: golangci-lint ## Verify golangci-lint linter configuration + $(GOLANGCI_LINT) config verify + .PHONY: lint lint: golangci-lint ## Run golangci-lint linter $(GOLANGCI_LINT) run diff --git a/pkg/plugins/golang/v4/scaffolds/internal/templates/makefile.go b/pkg/plugins/golang/v4/scaffolds/internal/templates/makefile.go index 13dd58ac4b9..05dbc3eb6b4 100644 --- a/pkg/plugins/golang/v4/scaffolds/internal/templates/makefile.go +++ b/pkg/plugins/golang/v4/scaffolds/internal/templates/makefile.go @@ -157,6 +157,10 @@ test-e2e: manifests generate fmt vet ## Run the e2e tests. Expected an isolated } go test ./test/e2e/ -v -ginkgo.v +.PHONY: lint-config +lint-config: golangci-lint ## Verify golangci-lint linter configuration + $(GOLANGCI_LINT) config verify + .PHONY: lint lint: golangci-lint ## Run golangci-lint linter $(GOLANGCI_LINT) run diff --git a/testdata/project-v4-multigroup/Makefile b/testdata/project-v4-multigroup/Makefile index 83b9bca464d..869e0fe70f1 100644 --- a/testdata/project-v4-multigroup/Makefile +++ b/testdata/project-v4-multigroup/Makefile @@ -78,6 +78,10 @@ test-e2e: manifests generate fmt vet ## Run the e2e tests. Expected an isolated } go test ./test/e2e/ -v -ginkgo.v +.PHONY: lint-config +lint-config: golangci-lint ## Verify golangci-lint linter configuration + $(GOLANGCI_LINT) config verify + .PHONY: lint lint: golangci-lint ## Run golangci-lint linter $(GOLANGCI_LINT) run diff --git a/testdata/project-v4-with-plugins/Makefile b/testdata/project-v4-with-plugins/Makefile index 27768e9f3ef..ccbfe803ab8 100644 --- a/testdata/project-v4-with-plugins/Makefile +++ b/testdata/project-v4-with-plugins/Makefile @@ -78,6 +78,10 @@ test-e2e: manifests generate fmt vet ## Run the e2e tests. Expected an isolated } go test ./test/e2e/ -v -ginkgo.v +.PHONY: lint-config +lint-config: golangci-lint ## Verify golangci-lint linter configuration + $(GOLANGCI_LINT) config verify + .PHONY: lint lint: golangci-lint ## Run golangci-lint linter $(GOLANGCI_LINT) run diff --git a/testdata/project-v4/Makefile b/testdata/project-v4/Makefile index 9b3ac1740de..9d04450c9b9 100644 --- a/testdata/project-v4/Makefile +++ b/testdata/project-v4/Makefile @@ -78,6 +78,10 @@ test-e2e: manifests generate fmt vet ## Run the e2e tests. Expected an isolated } go test ./test/e2e/ -v -ginkgo.v +.PHONY: lint-config +lint-config: golangci-lint ## Verify golangci-lint linter configuration + $(GOLANGCI_LINT) config verify + .PHONY: lint lint: golangci-lint ## Run golangci-lint linter $(GOLANGCI_LINT) run