-
Notifications
You must be signed in to change notification settings - Fork 55
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
🌱 Configure ENVTEST Binaries for IDE Debugging #1454
🌱 Configure ENVTEST Binaries for IDE Debugging #1454
Conversation
✅ Deploy Preview for olmv1 ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
6ccb706
to
bec5b49
Compare
ff5d402
to
94cd7d3
Compare
703e583
to
9ba4f50
Compare
9ba4f50
to
3563506
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1454 +/- ##
==========================================
- Coverage 74.87% 74.68% -0.19%
==========================================
Files 42 42
Lines 3271 3271
==========================================
- Hits 2449 2443 -6
- Misses 648 652 +4
- Partials 174 176 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
3563506
to
ba71f8b
Compare
Hi @m1kola, Thank you for catching that—really good observation! 🙌 Your comment highlights an additional motivation for this change: addressing scenarios like those outlined in kubernetes-sigs/controller-runtime#2744 and kubernetes-sigs/controller-runtime#2646. The required changes have been addressed, and we no longer use bingo here as intended. Please feel free to review this one. |
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
70048e4
to
038669f
Compare
Hi @joelanford, @m1kola, @perdasilva, @bentito, Apologies for the confusion earlier! This PR is NOT about Bingo. The main goal is to make debugging ENVTEST-based tests in the IDE simpler and more straightforward.
I’ve addressed all comments, closed all as done or outdated to avoid confusion, reverted the BINGO changes, and kept the suggestions. @m1kola, could you please revert your block? Thanks in advance! 😊 |
038669f
to
c5cdc3d
Compare
// | ||
// To ensure the binaries are in the expected path without manual configuration, run: | ||
// `make setup-envtest` | ||
if getFirstFoundEnvTestBinaryDir() != "" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @perdasilva,
You added this comment, and I deviated—sorry about that!
Would it be cleaner if we just used an environment variable like
ENV_TEST_BINARY_DIR
or something like that?
Then, it doesn't really matter where the binaries are placed.
We already have an environment variable (KUBEBUILDER_ASSETS
) that can be used, but it’s not very convenient and involves a steep learning curve:
- Know that ENVTEST requires binaries.
- Then, by default, ENVTEST is expected to find the bins in
local/...
. - We can override this using the
KUBEBUILDER_ASSETS
environment variable. - Note that those bins never was in the
$GOPATH/bin
because they are placed via the setup-invest in the global place (see here) which indeed cause issues for those which have restrictive envs. - Then, there’s the added challenge of knowing how to configure the tests properly in an IDE.
This PR simplifies the process so everything “just works” without extra setup or deep knowledge.
Making tests and debugging smoother and hassle-free.
I’ve also updated the code comments to clarify things further.
Hope this clears everything up! 😊
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might also be nice to update the developer docs: https://github.com/operator-framework/operator-controller/blob/main/docs/contribute/developer.md
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both are done 👍
Thank you 🥇
test-unit: $(SETUP_ENVTEST) #HELP Run the unit tests | ||
rm -rf $(COVERAGE_UNIT_DIR) && mkdir -p $(COVERAGE_UNIT_DIR) | ||
eval $$($(SETUP_ENVTEST) use -p env $(ENVTEST_VERSION) $(SETUP_ENVTEST_BIN_DIR_OVERRIDE)) && \ | ||
KUBEBUILDER_ASSETS="$(shell $(SETUP_ENVTEST) use -p path $(ENVTEST_VERSION) $(SETUP_ENVTEST_BIN_DIR_OVERRIDE))" \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @m1kola,
Just to clarify, the binaries installed by envtest-setup are no longer placed in the HOME/global directory. See the default behavior here:
https://github.com/kubernetes-sigs/controller-runtime/blob/e3347b5405cdd0da5bff527af3d406117938ba6b/tools/setup-envtest/README.md?plain=1#L57-L70
This change ensures binaries are placed locally, avoiding the conflicts and clutter caused by global installations.
To clarify, I’m referring to the binaries required for ENVTEST (not those managed by BINGO).
Hope this clears things up! 😊
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@perdasilva ^ That might clarify better.
Hi @m1kola Thank you. Regards #1454 (comment) see : #1454 (comment) That is not the goal of the PR, and this point can be addressed in a follow-up. |
c5cdc3d
to
7f4439e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me overall.
Just one question about $(SETUP_ENVTEST)
and setup-envtest
targets.
Makefile
Outdated
$(SETUP_ENVTEST) use -p env $(ENVTEST_VERSION) $(SETUP_ENVTEST_BIN_DIR_OVERRIDE) | ||
|
||
.PHONY: test-unit | ||
test-unit: $(SETUP_ENVTEST) setup-envtest #HELP Run the unit tests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A bit strange to have $(SETUP_ENVTEST)
and setup-envtest
targets.
Is it beneficial to have a separate setup-envtest
target here?
Maybe we can just do this?
test-unit: $(SETUP_ENVTEST) setup-envtest #HELP Run the unit tests | |
test-unit: $(SETUP_ENVTEST) #HELP Run the unit tests | |
mkdir -p $(ROOT_DIR)/bin | |
$(SETUP_ENVTEST) use -p env $(ENVTEST_VERSION) $(SETUP_ENVTEST_BIN_DIR_OVERRIDE) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- $(SETUP_ENVTEST) -> Downloads the binary for setting up envtest.
- setup-envtest -> Downloads the Kubernetes binaries and actually sets up envtest.
If we make the suggested change where we are not calling setup-envtest and we do not have an option to do only that, it would allow us to have the required binaries to run the IDE without running the WHOLE unit tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we make the suggested change where we are not calling setup-envtest and we do not have an option to do only that, it would allow us to have the required binaries to run the IDE without running the WHOLE unit tests.
Got it. I still don't like the naming, but I don't think we should block on this. And I can't come up with a meaningful alternative name for setup-envtest
as well :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe we could call the target: setup-local-env
or something like that. Then, it could be a generic target for developers to bootstrap their local development environment. Right now, that may only be the envtest binaries, but there could me more in the future. Maybe we could also add an @echo
"adding envtest binaries to bin/ - see [link to developer docs] for more details"?
7f4439e
to
18fa9ac
Compare
Makefile
Outdated
$(SETUP_ENVTEST) use -p env $(ENVTEST_VERSION) $(SETUP_ENVTEST_BIN_DIR_OVERRIDE) | ||
|
||
.PHONY: test-unit | ||
test-unit: $(SETUP_ENVTEST) setup-envtest #HELP Run the unit tests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we make the suggested change where we are not calling setup-envtest and we do not have an option to do only that, it would allow us to have the required binaries to run the IDE without running the WHOLE unit tests.
Got it. I still don't like the naming, but I don't think we should block on this. And I can't come up with a meaningful alternative name for setup-envtest
as well :)
Hi @m1kola Thank you very much for the very detailed review. Again, thank you a lot for your review 🥇 |
This change introduces downloading the specific binaries required to run ENVTEST-based tests into the project/bin directory. This setup makes it easier to configure tests for debugging directly in an IDE. Furthermore, no longer install binaries required for ENVTEST based tests on the project/bin instead of global path.
18fa9ac
to
450d120
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm - thank you <3
Thank you @perdasilva and @m1kola I am moving forward with this one However, we can always to push enhancements in a follow-up as well. |
d3f267a
This change introduces downloading the specific binaries required to run ENVTEST-based tests into the project/bin directory. This setup makes configuring tests for debugging directly in an IDE easier.
Motivation
BinaryAssetsDirectory
dynamically, contributors can debug tests in their preferred IDEs (e.g., GoLand, VSCode) without requiring additional environment configuration such as settingKUBEBUILDER_ASSETS
.Installing binaries inside the project avoids conflicts with other projects or system-wide installations, particularly useful for contributors with restricted environments (e.g., corporate laptops).
The binaries installed by envtest-setup are no longer placed in the HOME/global directory. See the default behavior here:
https://github.com/kubernetes-sigs/controller-runtime/blob/e3347b5405cdd0da5bff527af3d406117938ba6b/tools/setup-envtest/README.md?plain=1#L57-L70
This change ensures binaries are placed locally, avoiding the conflicts and clutter caused by global installations.
I’m referring to the binaries required for ENVTEST (not those managed by BINGO).
Before this PR those are placed for example in a Mac OS at:
/Users/camilam/Library/Application Support/io.kubebuilder.envtest/k8s/1.31.0-darwin-arm64
KUBEBUILDER_ASSETS
manually.While setting
KUBEBUILDER_ASSETS
is sufficient for experienced contributors, this change makes it easier for newcomers and supports debugging directly in IDEs without additional configuration.