Skip to content

Commit bb56ff2

Browse files
authored
install envtest if not present and use it in integration tests (#636)
1 parent 1cc75ac commit bb56ff2

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

Makefile

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,9 @@ vet: ## Run go vet against code.
9494
go vet ./...
9595

9696
.PHONY: test
97-
test: manifests generate fmt vet ## Run tests. Use WHAT=unit or WHAT=integration
97+
test: manifests generate fmt vet envtest ## Run tests. Use WHAT=unit or WHAT=integration
9898
ifeq ($(WHAT),integration)
99-
go test -v ./test/integration/suites/... -coverprofile integration-cover.out
99+
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_VERSION) --bin-dir $(LOCALBIN) -p path)" go test -v ./test/integration/suites/... -coverprofile integration-cover.out
100100
else ifeq ($(WHAT),unit)
101101
go test -v ./pkg/... -coverprofile unit-cover.out
102102
else
@@ -190,6 +190,7 @@ $(CHAINSAW): $(LOCALBIN)
190190
fi
191191
test -s $(LOCALBIN)/chainsaw || GOBIN=$(LOCALBIN) GO111MODULE=on go install github.com/kyverno/chainsaw@$(CHAINSAW_VERSION)
192192

193+
ENVTEST_VERSION ?= 1.31.x
193194

194195
.PHONY: ko
195196
ko: $(KO) ## Download ko locally if necessary. If wrong version is installed, it will be removed before downloading.
@@ -215,6 +216,12 @@ $(CONTROLLER_GEN): $(LOCALBIN)
215216
test -s $(LOCALBIN)/controller-gen && $(LOCALBIN)/controller-gen --version | grep -q $(CONTROLLER_TOOLS_VERSION) || \
216217
GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-tools/cmd/controller-gen@$(CONTROLLER_TOOLS_VERSION)
217218

219+
.PHONY: envtest
220+
envtest: $(ENVTEST) ## Download envtest-setup locally if necessary.
221+
$(ENVTEST): $(LOCALBIN)
222+
test -s $(LOCALBIN)/setup-envtest || GOBIN=$(LOCALBIN) $(GOPREFIX) go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest
223+
224+
218225
.PHONY: image
219226
build-image: ko ## Build the kro controller images using ko build
220227
echo "Building kro image $(RELEASE_VERSION).."

0 commit comments

Comments
 (0)