@@ -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
@@ -379,15 +373,26 @@ generate-test-flavors: $(KUSTOMIZE) ## Generate test template flavors
379
373
e2e-image : docker-pull-prerequisites $(TOOLS_BIN_DIR ) /start.sh $(TOOLS_BIN_DIR ) /restart.sh # # Build an e2e test image
380
374
docker build -f Dockerfile --tag=" gcr.io/k8s-staging-cluster-api/capa-manager:e2e" .
381
375
382
- $(SETUP_ENVTEST ) : # Build setup-envtest from tools folder.
376
+ .PHONY : install-setup-envtest
377
+ install-setup-envtest : # Install setup-envtest so that setup-envtest's eval is executed after the tool has been installed.
383
378
GOBIN=$(abspath $(TOOLS_BIN_DIR ) ) $(GO_INSTALL ) $(SETUP_ENVTEST_PKG ) $(SETUP_ENVTEST_BIN ) $(SETUP_ENVTEST_VER )
384
379
380
+ .PHONY : setup-envtest
381
+ setup-envtest : install-setup-envtest # Build setup-envtest from tools folder.
382
+ @if [ $( shell go env GOOS) == " darwin" ]; then \
383
+ $(eval KUBEBUILDER_ASSETS := $(shell $(SETUP_ENVTEST ) use --use-env -p path --arch amd64 $(KUBEBUILDER_ENVTEST_KUBERNETES_VERSION ) ) ) \
384
+ echo " kube-builder assets set using darwin OS" ; \
385
+ else \
386
+ $(eval KUBEBUILDER_ASSETS := $(shell $(SETUP_ENVTEST ) use --use-env -p path $(KUBEBUILDER_ENVTEST_KUBERNETES_VERSION ) ) ) \
387
+ echo " kube-builder assets set using other OS" ; \
388
+ fi
389
+
385
390
.PHONY : test
386
- test : $( SETUP_ENVTEST ) # # Run tests
391
+ test : setup-envtest # # Run tests
387
392
KUBEBUILDER_ASSETS=" $( KUBEBUILDER_ASSETS) " go test ./...
388
393
389
394
.PHONY : test-verbose
390
- test-verbose : $( SETUP_ENVTEST ) # # Run tests with verbose settings.
395
+ test-verbose : setup-envtest # # Run tests with verbose settings.
391
396
KUBEBUILDER_ASSETS=" $( KUBEBUILDER_ASSETS) " go test -v ./...
392
397
393
398
.PHONY : test-e2e # # Run e2e tests using clusterctl
@@ -407,7 +412,7 @@ test-conformance: generate-test-flavors $(GINKGO) $(KIND) $(SSM_PLUGIN) $(KUSTOM
407
412
time $(GINKGO ) -tags=e2e -focus=" conformance" $(CONFORMANCE_GINKGO_ARGS ) ./test/e2e/suites/conformance/... -- -config-path=" $( E2E_CONF_PATH) " $(CONFORMANCE_E2E_ARGS )
408
413
409
414
.PHONY : test-cover
410
- test-cover : $( SETUP_ENVTEST ) # # Run tests with code coverage and code generate reports
415
+ test-cover : setup-envtest # # Run tests with code coverage and code generate reports
411
416
KUBEBUILDER_ASSETS=" $( KUBEBUILDER_ASSETS) " go test -coverprofile=coverage.out ./... $(TEST_ARGS )
412
417
go tool cover -func=coverage.out -o coverage.txt
413
418
go tool cover -html=coverage.out -o coverage.html
0 commit comments