Skip to content

Commit

Permalink
Add envtest support
Browse files Browse the repository at this point in the history
  • Loading branch information
tomleb committed Feb 3, 2025
1 parent d5ebd84 commit 6b7a9af
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 11 additions & 1 deletion scripts/test.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
#!/bin/bash

go test ./...
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 ./...

0 comments on commit 6b7a9af

Please sign in to comment.