Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update setup env tests #239

Merged
merged 4 commits into from
Jun 16, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Setting SHELL to bash allows bash commands to be executed by recipes.
# This is a requirement for 'setup-envtest.sh' in the test target.
# This is a requirement for setup-envtest in the test target.
# Options are set to exit when a recipe line exits non-zero or a piped command fails.
SHELL = /usr/bin/env bash -o pipefail
.SHELLFLAGS = -ec
Expand Down Expand Up @@ -76,10 +76,14 @@ GOTESTS ?= ./...
# Use "-short" to skip long tests, or "-verbose" for more verbose reporting. Run
# go help testflags to see all options.
GOTESTFLAGS ?= ""
test: manifests generate vet mocks ${SIGNED_ARTIFACTS} ## 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.3/hack/setup-envtest.sh
source ${ENVTEST_ASSETS_DIR}/setup-envtest.sh; fetch_envtest_tools $(ENVTEST_ASSETS_DIR); setup_envtest_env $(ENVTEST_ASSETS_DIR); $(GO) test $(GOTESTFLAGS) `$(GO) list $(GOTESTS) | grep -v mocks` -coverprofile cover.out
test: manifests generate vet mocks ${SIGNED_ARTIFACTS} $(GOBIN)/setup-envtest ## Run tests.
source <(setup-envtest use -i -p env 1.23.x)
$(GO) test $(GOTESTFLAGS) `$(GO) list $(GOTESTS) | grep -v mocks` -coverprofile cover.out

$(GOBIN)/setup-envtest: ## Install setup-envtest
# While it's preferable not to use @latest here, we have no choice at the moment. Details at
# https://github.com/kubernetes-sigs/kubebuilder/issues/2480
go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd generally prefer not to use @latest here, so we don't get bitten by this updating unexpectedly on the build servers.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't work, I assume since it is a submodule there is some ongoing work to support this kubernetes-sigs/kubebuilder#2480

TerryHowe marked this conversation as resolved.
Show resolved Hide resolved
TerryHowe marked this conversation as resolved.
Show resolved Hide resolved

clean: ## Clean up resources created by make targets
rm -rf ./bin/*
Expand Down