diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index b34d3f18..6b3275bd 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -25,6 +25,8 @@ jobs: uses: golangci/golangci-lint-action@a4f60bb28d35aeee14e6880718e0c85ff1882e64 # v6.0.1 with: version: v1.63.4 + - name: Install env-test + run: go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest - name: Build run: make build-bin - name: Test diff --git a/scripts/test.sh b/scripts/test.sh index f9143f72..14f7c8b7 100644 --- a/scripts/test.sh +++ b/scripts/test.sh @@ -1,3 +1,13 @@ #!/bin/bash -go test ./... \ No newline at end of file +if ! command -v setup-envtest; then + echo "setup-envtest is required for tests, but was not installed" + echo "see the 'Running Tests' section of the readme for install instructions" + exit 127 +fi + +minor=$(go mod graph | grep ' k8s.io/client-go@' | head -n1 | cut -d@ -f2 | cut -d '.' -f 2) +version="1.$minor.x" + +export KUBEBUILDER_ASSETS=$(setup-envtest use -p path "$version") +go test ./...