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
feat: support bzlmod usage of jq/yq #88
Conversation
This has to disable our docs generation due to bazelbuild/bazel#14140 It also has to remove our gazelle setup for maintaining the |
1cceab8
to
a838fdd
Compare
Reduced scope here, instead of trying to switch from WORKSPACE to MODULE.bazel for local development, just added an e2e folder that verifies users can use it as a bzlmod module. Needs some CI setup in a followup so the e2e is actually getting tested. I verified manually with |
MODULE.bazel
Outdated
ext = use_extension("@aspect_bazel_lib//lib:extensions.bzl", "lib") | ||
use_repo(ext, "jq_toolchains") | ||
use_repo(ext, "yq_toolchains") |
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.
Do consumers need this to be in our MODULE file? Wouldn't they just include it in theirs to use the toolchains?
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.
yes, it needs to be in our file in order for the new e2e to succeed, because we reference it above.
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.
Can we declare it a dev dependency?
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 it's a dev dependency, then the user gets
ERROR: /home/alexeagle/Projects/bazel-lib/e2e/bzlmod/BUILD.bazel:5:3: While resolving toolchains for target //:case_no_sources: invalid registered toolchain '@jq_toolchains//:all': @jq_toolchains is not visible from repository `@aspect_bazel_lib`
which I think makes sense, when the user evaluates this file it's like all the dev_dependency lines don't exist
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.
In this example, we use the toolchain under our jq
rule implementation.
If users want to reference the toolchain themselves, then yes they'd need this too.
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.
I see. So users are forced to download the toolchain even if they don't use jq
?
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.
great question, looking in the external/
folder under the e2e/bzlmod I see
aspect_bazel_lib.ext.jq_linux_amd64
aspect_bazel_lib.ext.jq_toolchains
aspect_bazel_lib.ext.yq_toolchains
aspect_bazel_lib.lib.jq_linux_amd64
aspect_bazel_lib.lib.jq_toolchains
aspect_bazel_lib.lib.yq_toolchains
Which is what I hoped - the yq toolchain wasn't used by this example, so Bazel never fetched the binary.
(lib and ext are duplicated just because I renamed the module extension, and the repos get namespaced this way, and I didnt' clean --expunge
)
I think you can just add a simple shell script under e2e that does a cd then calls bazel, then the ci will run it. |
Not for this PR, but I guess we'll need to publish sample MODULE.bazel snippets on release to show how to use the extensions. |
I think we're missing a bzlmod dependency on stardoc. EDIT: Oh, that isn't in the bcr.. EDIT: Yes it is, just under a different name. |
8608689
to
29494cf
Compare
No description provided.