Skip to content

Add setup-envtest to tools.go for vendoring#516

Merged
mergify[bot] merged 3 commits into
bpfman:mainfrom
alebedev87:add-setup-envtest-tools
May 6, 2026
Merged

Add setup-envtest to tools.go for vendoring#516
mergify[bot] merged 3 commits into
bpfman:mainfrom
alebedev87:add-setup-envtest-tools

Conversation

@alebedev87
Copy link
Copy Markdown
Contributor

@alebedev87 alebedev87 commented May 5, 2026

Add tools/tools.go with a blank import of setup-envtest so the tool is included in the vendor directory. Uses the release-0.22 branch pseudo-version (v0.0.0-20260125163108-a19ec76a3c5d) which requires Go 1.24 (compatible with the project's Go 1.25). The only tagged semver release (v0.24.0) requires Go 1.26 and is not usable yet.

Replace the go install/binary invocation of setup-envtest in the Makefile with go run, removing the envtest target and ENVTEST variable. Since the tool is now vendored, go run picks it up directly without needing a separate install step.

Also includes the vendor drift CI check from #517: run go mod tidy && go mod vendor and assert with git status --porcelain that no tracked modifications or untracked entries remain under vendor/, go.mod or go.sum.

Add `tools/tools.go` with a blank import of `setup-envtest` so the
tool is pulled into the vendor directory. Uses the `release-0.22`
branch pseudo-version which requires Go 1.24 (compatible with the
project's Go 1.25).

Replace `go install` invocation of `setup-envtest` in the Makefile
with `go run`, removing the `envtest` target and `ENVTEST` variable.

Co-Authored-By: Claude
Signed-off-by: Andrey Lebedev <alebedev@redhat.com>
@alebedev87 alebedev87 force-pushed the add-setup-envtest-tools branch from ab24401 to d6740b0 Compare May 5, 2026 12:12
@frobware
Copy link
Copy Markdown
Contributor

frobware commented May 5, 2026

Two observations from comparing against #518.

1. Makefile $(shell ...) still masks setup-envtest failures

KUBEBUILDER_ASSETS="$(shell go run sigs.k8s.io/controller-runtime/tools/setup-envtest use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" go test ./... -coverprofile cover.out

$(shell ...) captures stdout but discards the exit code, so if go run fails (e.g. cannot find module providing package ... import lookup disabled by -mod=vendor) the variable expands to "" and go test proceeds. No test currently consumes KUBEBUILDER_ASSETS, so it passes silently. The vendor-cleanliness check from 66171cec would catch this specific drift but not other setup-envtest failures that leave vendor clean. Moving the substitution into the recipe shell and asserting KUBEBUILDER_ASSETS is non-empty closes that gap -- see 04c7abc7 on #518.

2. Commit message for 66171cec could note why git diff --exit-code is not sufficient

It ignores untracked files -- which is exactly the failure mode here (newly materialised vendor dirs that were never git added). Worth a line in the body so future git blame answers itself.

Run `go mod tidy` and `go mod vendor`, then assert with
`git status --porcelain` that no tracked modifications and no
untracked entries remain. `git diff --exit-code` alone is
insufficient because it ignores untracked files.

Co-Authored-By: Claude
Signed-off-by: Andrey Lebedev <alebedev@redhat.com>
@alebedev87 alebedev87 force-pushed the add-setup-envtest-tools branch from 66171ce to d00624f Compare May 5, 2026 14:36
@alebedev87
Copy link
Copy Markdown
Contributor Author

Force pushed to retest the bundle deployment on KIND.

The previous recipe used `KUBEBUILDER_ASSETS="$(shell go run
sigs.k8s.io/...setup-envtest ...)"` to compute the assets path.  GNU
Make's `$(shell ...)` captures stdout only and silently discards the
exit code, so when `go run` failed (for example with `cannot find
module providing package ... import lookup disabled by -mod=vendor`)
the variable expanded to the empty string and tests proceeded with
`KUBEBUILDER_ASSETS=""`.  Tests that do not currently consume the
assets path then passed regardless, masking the real failure.

Move the substitution into the recipe shell.  After `go run`, assert
that `KUBEBUILDER_ASSETS` is non-empty and exit with a clear message
otherwise.  Echo the resolved invocation before running it so the
build log records the exact `go test` command, mirroring the
readability of the previous one-liner.

Signed-off-by: Andrew McDermott <amcdermo@redhat.com>
Copy link
Copy Markdown
Contributor

@frobware frobware left a comment

Choose a reason for hiding this comment

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

LGTM
Thanks!

Copy link
Copy Markdown
Contributor

@frobware frobware left a comment

Choose a reason for hiding this comment

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

LGTM
Thanks!

Copy link
Copy Markdown
Contributor

@frobware frobware left a comment

Choose a reason for hiding this comment

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

LGTM
Thanks!

@mergify mergify Bot merged commit 2ad9167 into bpfman:main May 6, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants