|
60 | 60 | tidy: |
61 | 61 | go mod tidy |
62 | 62 |
|
63 | | -GOLANGCI_LINT=$(shell pwd)/bin/golangci-lint |
64 | | -golangci-lint: ## Download golangci-lint |
65 | | -ifneq ($(shell test -f $(GOLANGCI_LINT); echo $$?), 0) |
66 | | - @echo Getting golangci-lint... |
67 | | - @mkdir -p $(shell pwd)/bin |
68 | | - curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(shell pwd)/bin v1.46.2 |
69 | | -endif |
70 | | - |
71 | 63 | .PHONY: lint |
72 | 64 | lint: golangci-lint ## Run linter |
73 | 65 | $(GOLANGCI_LINT) run |
74 | 66 |
|
75 | 67 | .PHONY: goimports |
76 | | -goimports: ## run goimports updating files in place |
77 | | - goimports -w . |
| 68 | +goimports: goimports-bin ## run goimports updating files in place |
| 69 | + $(GOIMPORTS) -w . |
78 | 70 |
|
| 71 | +# Run tests |
79 | 72 | ENVTEST_ASSETS_DIR=$(shell pwd)/testbin |
80 | 73 | KUBEBUILDER_ASSETS?="$(shell $(ENVTEST) use -i $(ENVTEST_KUBERNETES_VERSION) --bin-dir=$(ENVTEST_ASSETS_DIR) -p path)" |
| 74 | + |
| 75 | +.PHONY: test |
81 | 76 | test: manifests generate generate-mocks fmt vet test-setup ## Run tests |
82 | 77 | KUBEBUILDER_ASSETS=$(KUBEBUILDER_ASSETS) go test ./... -coverprofile cover.out -covermode=atomic |
83 | 78 |
|
@@ -122,10 +117,10 @@ eks-test: |
122 | 117 | ##@ Build |
123 | 118 |
|
124 | 119 | .DEFAULT: build |
125 | | -build: manifests generate generate-mocks fmt vet goimports lint ## Build manager binary. |
| 120 | +build: test goimports lint ## Build manager binary. |
126 | 121 | go build -ldflags="-s -w -X ${PKG}.GitVersion=${GIT_TAG} -X ${PKG}.GitCommit=${GIT_COMMIT}" -o bin/manager main.go |
127 | 122 |
|
128 | | -run: manifests generate generate-mocks fmt vet ## Run a controller from your host. |
| 123 | +run: test ## Run a controller from your host. |
129 | 124 | go run -ldflags="-s -w -X ${PKG}.GitVersion=${GIT_TAG} -X ${PKG}.GitCommit=${GIT_COMMIT}" ./main.go --zap-devel=true $(ARGS) |
130 | 125 |
|
131 | 126 | docker-build: test ## Build docker image with the manager. |
@@ -186,6 +181,18 @@ MOCKGEN = $(shell pwd)/bin/mockgen |
186 | 181 | mockgen: ## Download mockgen |
187 | 182 | $(call go-get-tool,$(MOCKGEN),github.com/golang/mock/[email protected]) |
188 | 183 |
|
| 184 | +GOLANGCI_LINT=$(shell pwd)/bin/golangci-lint |
| 185 | +golangci-lint: ## Download golangci-lint |
| 186 | +ifneq ($(shell test -f $(GOLANGCI_LINT); echo $$?), 0) |
| 187 | + @echo Getting golangci-lint... |
| 188 | + @mkdir -p $(shell pwd)/bin |
| 189 | + curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(shell pwd)/bin v1.46.2 |
| 190 | +endif |
| 191 | + |
| 192 | +GOIMPORTS = $(shell pwd)/bin/goimports |
| 193 | +goimports-bin: ## Download mockgen |
| 194 | + $(call go-get-tool,$(GOIMPORTS),golang.org/x/tools/cmd/[email protected]) |
| 195 | + |
189 | 196 | KIND = $(shell pwd)/bin/kind |
190 | 197 | kind: ## Download kind |
191 | 198 | $(call go-get-tool,$(KIND),sigs.k8s.io/[email protected]) |
|
0 commit comments