@@ -24,6 +24,7 @@ ARTIFACTS ?= $(REPO_ROOT)/_artifacts
24
24
TOOLS_DIR := hack/tools
25
25
TOOLS_DIR_DEPS := $(TOOLS_DIR ) /go.sum $(TOOLS_DIR ) /go.mod $(TOOLS_DIR ) /Makefile
26
26
TOOLS_BIN_DIR := $(TOOLS_DIR ) /bin
27
+ GO_INSTALL := ./scripts/go_install.sh
27
28
28
29
API_DIRS := cmd/clusterawsadm/api api exp/api controlplane/eks/api bootstrap/eks/api iam/api
29
30
API_SRCS := $(foreach dir, $(API_DIRS ) , $(call rwildcard,../../$(dir ) ,* .go) )
@@ -129,6 +130,19 @@ E2E_SKIP_EKS_UPGRADE ?= "false"
129
130
# Set EKS_SOURCE_TEMPLATE to override the source template
130
131
EKS_SOURCE_TEMPLATE ?= eks/cluster-template-eks-control-plane-only.yaml
131
132
133
+ # set up `setup-envtest` to install kubebuilder dependency
134
+ export KUBEBUILDER_ENVTEST_KUBERNETES_VERSION ?= 1.23.3
135
+ SETUP_ENVTEST_VER := v0.0.0-20211110210527-619e6b92dab9
136
+ SETUP_ENVTEST_BIN := setup-envtest
137
+ SETUP_ENVTEST := $(abspath $(TOOLS_BIN_DIR ) /$(SETUP_ENVTEST_BIN ) -$(SETUP_ENVTEST_VER ) )
138
+ SETUP_ENVTEST_PKG := sigs.k8s.io/controller-runtime/tools/setup-envtest
139
+
140
+ ifeq ($(shell go env GOOS) ,darwin) # Use the darwin/amd64 binary until an arm64 version is available
141
+ KUBEBUILDER_ASSETS ?= $(shell $(SETUP_ENVTEST) use --use-env -p path --arch amd64 $(KUBEBUILDER_ENVTEST_KUBERNETES_VERSION))
142
+ else
143
+ KUBEBUILDER_ASSETS ?= $(shell $(SETUP_ENVTEST) use --use-env -p path $(KUBEBUILDER_ENVTEST_KUBERNETES_VERSION))
144
+ endif
145
+
132
146
# Enable Cluster API Framework tests for the purposes of running the PR blocking test
133
147
ifeq ($(findstring \[PR-Blocking\],$(E2E_FOCUS ) ) ,\[PR-Blocking\])
134
148
override undefine GINKGO_SKIP
@@ -305,7 +319,7 @@ verify-shellcheck: ## Verify shell files
305
319
306
320
.PHONY : verify-book-links
307
321
verify-book-links : # # Verify book links
308
- $(MAKE ) -C docs/book verify
322
+ $(MAKE ) -C docs/book verify
309
323
310
324
.PHONY : verify-gen
311
325
verify-gen : generate # # Verify generated files
@@ -366,13 +380,16 @@ generate-test-flavors: $(KUSTOMIZE) ## Generate test template flavors
366
380
e2e-image : docker-pull-prerequisites $(TOOLS_BIN_DIR ) /start.sh $(TOOLS_BIN_DIR ) /restart.sh # # Build an e2e test image
367
381
docker build -f Dockerfile --tag=" gcr.io/k8s-staging-cluster-api/capa-manager:e2e" .
368
382
383
+ $(SETUP_ENVTEST ) : # Build setup-envtest from tools folder.
384
+ GOBIN=$(abspath $(TOOLS_BIN_DIR ) ) $(GO_INSTALL ) $(SETUP_ENVTEST_PKG ) $(SETUP_ENVTEST_BIN ) $(SETUP_ENVTEST_VER )
385
+
369
386
.PHONY : test
370
- test : # # Run tests
371
- source ./scripts/fetch_ext_bins.sh ; fetch_tools ; setup_envs ; go test ./...
387
+ test : $( SETUP_ENVTEST ) # # Run tests
388
+ KUBEBUILDER_ASSETS= " $( KUBEBUILDER_ASSETS ) " go test ./...
372
389
373
390
.PHONY : test-verbose
374
- test-verbose : # # Run tests with verbose settings.
375
- source ./scripts/fetch_ext_bins.sh ; fetch_tools ; setup_envs ; go test -v ./...
391
+ test-verbose : $( SETUP_ENVTEST ) # # Run tests with verbose settings.
392
+ KUBEBUILDER_ASSETS= " $( KUBEBUILDER_ASSETS ) " go test -v ./...
376
393
377
394
.PHONY : test-e2e # # Run e2e tests using clusterctl
378
395
test-e2e : $(GINKGO ) $(KIND ) $(SSM_PLUGIN ) $(KUSTOMIZE ) generate-test-flavors e2e-image # # Run e2e tests
@@ -391,8 +408,8 @@ test-conformance: generate-test-flavors $(GINKGO) $(KIND) $(SSM_PLUGIN) $(KUSTOM
391
408
time $(GINKGO ) -tags=e2e -focus=" conformance" $(CONFORMANCE_GINKGO_ARGS ) ./test/e2e/suites/conformance/... -- -config-path=" $( E2E_CONF_PATH) " $(CONFORMANCE_E2E_ARGS )
392
409
393
410
.PHONY : test-cover
394
- test-cover : # # Run tests with code coverage and code generate reports
395
- source ./scripts/fetch_ext_bins.sh ; fetch_tools ; setup_envs ; go test -coverprofile=coverage.out ./... $(TEST_ARGS )
411
+ test-cover : $( SETUP_ENVTEST ) # # Run tests with code coverage and code generate reports
412
+ KUBEBUILDER_ASSETS= " $( KUBEBUILDER_ASSETS ) " go test -coverprofile=coverage.out ./... $(TEST_ARGS )
396
413
go tool cover -func=coverage.out -o coverage.txt
397
414
go tool cover -html=coverage.out -o coverage.html
398
415
@@ -533,7 +550,7 @@ release-manifests: ## Release manifest files
533
550
.PHONY : release-changelog
534
551
release-changelog : $(GH ) # # Generates release notes using Github release notes.
535
552
./hack/releasechangelog.sh -v $(VERSION ) -pv $(PREVIOUS_VERSION ) -gh $(GH ) -ghorg $(GH_ORG_NAME ) -ghrepo $(GH_REPO_NAME ) -cimg $(CORE_CONTROLLER_IMG ) > $(RELEASE_DIR ) /CHANGELOG.md
536
-
553
+
537
554
.PHONY : release-binaries
538
555
release-binaries : # # Builds the binaries to publish with a release
539
556
RELEASE_BINARY=./cmd/clusterawsadm GOOS=linux GOARCH=amd64 $(MAKE ) release-binary
0 commit comments