Skip to content

Commit

Permalink
prerequisites for running the unit tests
Browse files Browse the repository at this point in the history
Signed-off-by: Prajyot-Parab <[email protected]>
  • Loading branch information
Prajyot-Parab committed May 9, 2022
1 parent fa6136c commit 5a264f1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
14 changes: 3 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ ENVSUBST := $(TOOLS_BIN_DIR)/envsubst
MOCKGEN := $(TOOLS_BIN_DIR)/mockgen
CONTROLLER_GEN := $(TOOLS_BIN_DIR)/controller-gen
CONVERSION_VERIFIER := $(TOOLS_BIN_DIR)/conversion-verifier
SETUP_ENVTEST := $(TOOLS_BIN_DIR)/setup-envtest

STAGING_REGISTRY ?= gcr.io/k8s-staging-capi-ibmcloud
STAGING_BUCKET ?= artifacts.k8s-staging-capi-ibmcloud.appspot.com
Expand All @@ -54,12 +55,7 @@ ARCH ?= amd64
ALL_ARCH ?= amd64 ppc64le
PULL_POLICY ?= Always

# set up `setup-envtest` to install kubebuilder dependency
export KUBEBUILDER_ENVTEST_KUBERNETES_VERSION ?= 1.23.3
SETUP_ENVTEST_VER := v0.0.0-20211110210527-619e6b92dab9
SETUP_ENVTEST_BIN := setup-envtest
SETUP_ENVTEST := $(abspath $(TOOLS_BIN_DIR)/$(SETUP_ENVTEST_BIN)-$(SETUP_ENVTEST_VER))
SETUP_ENVTEST_PKG := sigs.k8s.io/controller-runtime/tools/setup-envtest
KUBEBUILDER_ENVTEST_KUBERNETES_VERSION ?= 1.23.3

# main controller
CORE_IMAGE_NAME ?= cluster-api-ibmcloud-controller
Expand Down Expand Up @@ -167,12 +163,8 @@ lint-fix: $(GOLANGCI_LINT) ## Lint the codebase and run auto-fixers if supported
## Testing
## --------------------------------------

.PHONY: install-setup-envtest
install-setup-envtest: # Install setup-envtest so that setup-envtest's eval is executed after the tool has been installed.
GOBIN=$(abspath $(TOOLS_BIN_DIR)) $(GO_INSTALL) $(SETUP_ENVTEST_PKG) $(SETUP_ENVTEST_BIN) $(SETUP_ENVTEST_VER)

.PHONY: setup-envtest
setup-envtest: install-setup-envtest # Build setup-envtest from tools folder.
setup-envtest: $(SETUP_ENVTEST) # Build setup-envtest from tools folder.
@if [ $(shell go env GOOS) == "darwin" ]; then \
$(eval KUBEBUILDER_ASSETS := $(shell $(SETUP_ENVTEST) use --use-env -p path --arch amd64 $(KUBEBUILDER_ENVTEST_KUBERNETES_VERSION))) \
echo "kube-builder assets set using darwin OS"; \
Expand Down
4 changes: 4 additions & 0 deletions hack/tools/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,7 @@ $(CONTROLLER_GEN): $(BIN_DIR) go.mod go.sum
CONVERSION_VERIFIER := $(BIN_DIR)/conversion-verifier
$(CONVERSION_VERIFIER): $(BIN_DIR) go.mod go.sum
go build -tags=tools -o $@ sigs.k8s.io/cluster-api/hack/tools/conversion-verifier

SETUP_ENVTEST := $(BIN_DIR)/setup-envtest
$(SETUP_ENVTEST): $(BIN_DIR) go.mod go.sum
go build -tags=tools -o $@ sigs.k8s.io/controller-runtime/tools/setup-envtest

0 comments on commit 5a264f1

Please sign in to comment.