Skip to content

Commit 5a7dc20

Browse files
authored
Fixing the 'lint' makefile target. (kubernetes-sigs#87)
Also renamed the `test` target to `unit-test` target. Signed-off-by: Yoni Bettan <[email protected]>
1 parent 5e4f7c2 commit 5a7dc20

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

.github/workflows/test-build.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
fi
3131
3232
- name: Run tests
33-
run: make test
33+
run: make unit-test
3434

3535
- name: Build
3636
run: make
@@ -58,4 +58,4 @@ jobs:
5858
- name: golangci-lint
5959
uses: golangci/golangci-lint-action@v3
6060
with:
61-
args: --timeout 3m
61+
args: --timeout 3m

Makefile

+10-4
Original file line numberDiff line numberDiff line change
@@ -108,15 +108,16 @@ vet: ## Run go vet against code.
108108
go vet ./...
109109

110110
.PHONY: test
111-
test: manifests generate lint vet envtest ## Run tests.
111+
unit-test: manifests generate lint vet envtest ## Run tests.
112112
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) -p path)" go test ./... -coverprofile cover.out
113113

114114
.PHONY: lint
115-
lint: ## Uses gofmt to determine if some files do not follow the recommended format.
116-
if [ `gofmt -l . | wc -l` -ne 0 ]; then \
115+
lint: golangci-lint ## Run golangci-lint against code.
116+
@if [ `gofmt -l . | wc -l` -ne 0 ]; then \
117117
echo There are some malformed files, please make sure to run \'make fmt\'; \
118118
exit 1; \
119119
fi
120+
$(GOLANGCI_LINT) run -v --timeout 5m0s
120121

121122
##@ Build
122123

@@ -129,7 +130,7 @@ run: manifests generate fmt vet ## Run a controller from your host.
129130
go run ./main.go
130131

131132
.PHONY: docker-build
132-
docker-build: test ## Build docker image with the manager.
133+
docker-build: unit-test ## Build docker image with the manager.
133134
docker build -t ${IMG} .
134135

135136
.PHONY: docker-push
@@ -166,6 +167,11 @@ CONTROLLER_GEN = $(shell pwd)/bin/controller-gen
166167
controller-gen: ## Download controller-gen locally if necessary.
167168
$(call go-get-tool,$(CONTROLLER_GEN),sigs.k8s.io/controller-tools/cmd/[email protected])
168169

170+
GOLANGCI_LINT = $(shell pwd)/bin/golangci-lint
171+
.PHONY: golangci-lint
172+
golangci-lint: ## Download golangci-lint locally if necessary.
173+
$(call go-get-tool,$(GOLANGCI_LINT),github.com/golangci/golangci-lint/cmd/[email protected])
174+
169175
.PHONY: mockgen
170176
mockgen: ## Install mockgen locally.
171177
go install github.com/golang/mock/[email protected]

0 commit comments

Comments
 (0)