Skip to content

Commit 0fe9004

Browse files
authored
Merge pull request kubernetes-sigs#256 from prometherion/chore/declarative-golangci-lint
chore(golangci-lint): v1.54.2 pinning and config file
2 parents 7e3af80 + d9065fa commit 0fe9004

File tree

3 files changed

+42
-7
lines changed

3 files changed

+42
-7
lines changed

.github/workflows/test.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,9 @@ jobs:
5252
go-version-file: go.mod
5353
- name: golangci-lint
5454
uses: golangci/golangci-lint-action@v3
55-
with: # TODO: remove this when the deprecated function will be removed (issue #85)
56-
args: --exclude SA1019 --timeout=5m -E ginkgolinter
55+
with:
56+
args: --timeout=5m -v
57+
version: v1.54.2
5758

5859
check-gen:
5960
runs-on: ubuntu-latest

.golangci.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
linters-settings:
2+
ginkgolinter:
3+
forbid-focus-container: true
4+
5+
linters:
6+
enable:
7+
- deadcode
8+
- errcheck
9+
- ginkgolinter
10+
- gosimple
11+
- govet
12+
- ineffassign
13+
- staticcheck
14+
- structcheck
15+
- typecheck
16+
- unused
17+
- varcheck
18+
disable: []
19+
20+
issues:
21+
exclude:
22+
- SA1019 # todo remove the exclude parameter when issue #85 is resolved

Makefile

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,16 @@ all: test manager
6969
help: ## Display this help
7070
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
7171

72+
# go-install-tool will 'go install' any package $2 and install it to $1.
73+
PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))
74+
define go-install-tool
75+
@[ -f $(1) ] || { \
76+
set -e ;\
77+
echo "Installing $(2)" ;\
78+
GOBIN=$(PROJECT_DIR)/bin go install $(2) ;\
79+
}
80+
endef
81+
7282
## --------------------------------------
7383
## Testing
7484
## --------------------------------------
@@ -205,7 +215,7 @@ modules: ## Runs go mod to ensure modules are up to date.
205215
.PHONY: docker-pull-prerequisites
206216
docker-pull-prerequisites:
207217
docker pull docker.io/docker/dockerfile:1.4
208-
docker pull docker.io/library/golang:1.20
218+
docker pull docker.io/library/golang:1.20.2
209219
docker pull gcr.io/distroless/static:latest
210220

211221
.PHONY: docker-build
@@ -329,11 +339,13 @@ goimports:
329339
go install golang.org/x/tools/cmd/goimports@latest
330340
goimports -w -local="sigs.k8s.io/cluster-api-provider-kubevirt" $(shell find . -type f -name '*.go' ! -path "*/vendor/*" ! -path "./_kubevirtci/*" ! -path "*zz_generated*" )
331341

342+
GOLANGCI_LINT = $(shell pwd)/bin/golangci-lint
343+
golangci-lint: ## Download golangci-lint locally if necessary.
344+
$(call go-install-tool,$(GOLANGCI_LINT),github.com/golangci/golangci-lint/cmd/[email protected])
345+
332346
.PHONY: linter
333-
linter:
334-
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
335-
# todo remove the exclude parameter when issue #85 is resolved
336-
golangci-lint run --timeout=5m -E ginkgolinter --exclude SA1019
347+
linter: golangci-lint
348+
$(GOLANGCI_LINT) run --timeout=5m -v
337349

338350
.PHONY: sanity
339351
sanity: linter goimports test

0 commit comments

Comments
 (0)