Skip to content

Commit

Permalink
Merge pull request #72 from NVIDIA/upd-envtest
Browse files Browse the repository at this point in the history
use the latest iteration of the setup-envtest tool
  • Loading branch information
tariq1890 authored Jan 2, 2025
2 parents 0109ebe + 91bca5c commit fef35df
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ IMAGE_TAG ?= $(GOLANG_VERSION)
BUILDIMAGE ?= $(IMAGE):$(IMAGE_TAG)-devel

# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
ENVTEST_K8S_VERSION = 1.24.2
ENVTEST_ASSETS_DIR=$(shell pwd)/testbin
ENVTEST_K8S_VERSION = 1.32.x

TARGETS := all check lint go-check generate test cov-report controller-gen golangci-lint gcov2lcov
DOCKER_TARGETS := $(patsubst %, docker-%, $(TARGETS))
Expand All @@ -41,9 +40,11 @@ TOOLSDIR=$(CURDIR)/bin
GOLANGCILINT ?= $(TOOLSDIR)/golangci-lint
CONTROLLER_GEN ?= $(TOOLSDIR)/controller-gen
GCOV2LCOV ?= $(TOOLSDIR)/gcov2lcov
SETUP_ENVTEST ?= $(TOOLSDIR)/setup-envtest
GOLANGCILINT_VERSION ?= v1.62.2
CONTROLLER_GEN_VERSION ?= v0.16.5
GCOV2LCOV_VERSION ?= v1.1.1
SETUP_ENVTEST_RELEASE ?= release-0.19

# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
ifeq (,$(shell go env GOBIN))
Expand Down Expand Up @@ -72,11 +73,9 @@ generate: controller-gen ## Generate code
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./api/..."
go generate $(MODULE)/...

test: generate; $(info running $(NAME:%=% )tests...) @ ## Run tests
mkdir -p ${ENVTEST_ASSETS_DIR}
test -f ${ENVTEST_ASSETS_DIR}/setup-envtest.sh || curl -sSLo ${ENVTEST_ASSETS_DIR}/setup-envtest.sh https://raw.githubusercontent.com/kubernetes-sigs/controller-runtime/v0.8.0/hack/setup-envtest.sh
ENVTEST_K8S_VERSION=${ENVTEST_K8S_VERSION}; . ${ENVTEST_ASSETS_DIR}/setup-envtest.sh; \
fetch_envtest_tools $(ENVTEST_ASSETS_DIR); setup_envtest_env $(ENVTEST_ASSETS_DIR); go test ./... -coverprofile cover.out
test: setup-envtest generate; $(info running $(NAME:%=% )tests...) @ ## Run tests
export KUBEBUILDER_ASSETS="$(shell $(SETUP_ENVTEST) use -p path $(ENVTEST_K8S_VERSION))" && \
go test ./... -coverprofile cover.out

cov-report: gcov2lcov test ## Build test coverage report in lcov format
$(GCOV2LCOV) -infile cover.out -outfile lcov.info
Expand All @@ -90,6 +89,9 @@ golangci-lint: ## Download golangci-lint locally if necessary.
gcov2lcov: ## Download gcov2lcov locally if necessary.
$(call go-install-tool,$(GCOV2LCOV),github.com/jandelgado/gcov2lcov@$(GCOV2LCOV_VERSION))

setup-envtest: ## Download setup-envtest locally if necessary
$(call go-install-tool,$(SETUP_ENVTEST),sigs.k8s.io/controller-runtime/tools/setup-envtest@$(SETUP_ENVTEST_RELEASE))

# Generate an image for containerized builds
# Note: This image is local only
.PHONY: .build-image .pull-build-image .push-build-image
Expand Down

0 comments on commit fef35df

Please sign in to comment.