@@ -136,12 +136,6 @@ SETUP_ENVTEST_BIN := setup-envtest
136
136
SETUP_ENVTEST := $(abspath $(TOOLS_BIN_DIR ) /$(SETUP_ENVTEST_BIN ) -$(SETUP_ENVTEST_VER ) )
137
137
SETUP_ENVTEST_PKG := sigs.k8s.io/controller-runtime/tools/setup-envtest
138
138
139
- ifeq ($(shell go env GOOS) ,darwin) # Use the darwin/amd64 binary until an arm64 version is available
140
- KUBEBUILDER_ASSETS ?= $(shell $(SETUP_ENVTEST) use --use-env -p path --arch amd64 $(KUBEBUILDER_ENVTEST_KUBERNETES_VERSION))
141
- else
142
- KUBEBUILDER_ASSETS ?= $(shell $(SETUP_ENVTEST) use --use-env -p path $(KUBEBUILDER_ENVTEST_KUBERNETES_VERSION))
143
- endif
144
-
145
139
# Enable Cluster API Framework tests for the purposes of running the PR blocking test
146
140
ifeq ($(findstring \[PR-Blocking\],$(E2E_FOCUS ) ) ,\[PR-Blocking\])
147
141
override undefine GINKGO_SKIP
@@ -381,15 +375,26 @@ generate-test-flavors: $(KUSTOMIZE) ## Generate test template flavors
381
375
e2e-image : docker-pull-prerequisites $(TOOLS_BIN_DIR ) /start.sh $(TOOLS_BIN_DIR ) /restart.sh # # Build an e2e test image
382
376
docker build -f Dockerfile --tag=" gcr.io/k8s-staging-cluster-api/capa-manager:e2e" .
383
377
384
- $(SETUP_ENVTEST ) : # Build setup-envtest from tools folder.
378
+ .PHONY : install-setup-envtest
379
+ install-setup-envtest : # Install setup-envtest so that setup-envtest's eval is executed after the tool has been installed.
385
380
GOBIN=$(abspath $(TOOLS_BIN_DIR ) ) $(GO_INSTALL ) $(SETUP_ENVTEST_PKG ) $(SETUP_ENVTEST_BIN ) $(SETUP_ENVTEST_VER )
386
381
382
+ .PHONY : setup-envtest
383
+ setup-envtest : install-setup-envtest # Build setup-envtest from tools folder.
384
+ @if [ $( shell go env GOOS) == " darwin" ]; then \
385
+ $(eval KUBEBUILDER_ASSETS := $(shell $(SETUP_ENVTEST ) use --use-env -p path --arch amd64 $(KUBEBUILDER_ENVTEST_KUBERNETES_VERSION ) ) ) \
386
+ echo " kube-builder assets set using darwin OS" ; \
387
+ else \
388
+ $(eval KUBEBUILDER_ASSETS := $(shell $(SETUP_ENVTEST ) use --use-env -p path $(KUBEBUILDER_ENVTEST_KUBERNETES_VERSION ) ) ) \
389
+ echo " kube-builder assets set using other OS" ; \
390
+ fi
391
+
387
392
.PHONY : test
388
- test : $( SETUP_ENVTEST ) # # Run tests
393
+ test : setup-envtest # # Run tests
389
394
KUBEBUILDER_ASSETS=" $( KUBEBUILDER_ASSETS) " go test ./...
390
395
391
396
.PHONY : test-verbose
392
- test-verbose : $( SETUP_ENVTEST ) # # Run tests with verbose settings.
397
+ test-verbose : setup-envtest # # Run tests with verbose settings.
393
398
KUBEBUILDER_ASSETS=" $( KUBEBUILDER_ASSETS) " go test -v ./...
394
399
395
400
.PHONY : test-e2e # # Run e2e tests using clusterctl
@@ -409,7 +414,7 @@ test-conformance: generate-test-flavors $(GINKGO) $(KIND) $(SSM_PLUGIN) $(KUSTOM
409
414
time $(GINKGO ) -tags=e2e -focus=" conformance" $(CONFORMANCE_GINKGO_ARGS ) ./test/e2e/suites/conformance/... -- -config-path=" $( E2E_CONF_PATH) " $(CONFORMANCE_E2E_ARGS )
410
415
411
416
.PHONY : test-cover
412
- test-cover : $( SETUP_ENVTEST ) # # Run tests with code coverage and code generate reports
417
+ test-cover : setup-envtest # # Run tests with code coverage and code generate reports
413
418
KUBEBUILDER_ASSETS=" $( KUBEBUILDER_ASSETS) " go test -coverprofile=coverage.out ./... $(TEST_ARGS )
414
419
go tool cover -func=coverage.out -o coverage.txt
415
420
go tool cover -html=coverage.out -o coverage.html
0 commit comments