Repository navigation
Conversation
Bazel has no optional `bazel_dep`, and a dev dependency is invisible to dependents. While `helm/rules_img.bzl` was in `rules_helm`, every consumer resolved `rules_img`, `hermetic_launcher` and the `img_toolchain` hub repo, including those that never use `helm_oci_manifest`. `helm_oci_manifest` now lives in `modules/rules_helm_img`, a second module that is released from the same tag and has the same version. `rules_helm` has `rules_img` as a dev dependency only. A consumer adds `bazel_dep(name = "rules_helm_img")` and loads from `@rules_helm_img//:defs.bzl`. - The new module loads the private `helm_oci_parts` rule. `HELM_OCI_PARTS_API` in `oci_parts.bzl` makes a `rules_helm_img` that is paired with a different `rules_helm` fail with a clear message. - `.bazelignore` keeps the module out of `//...`, because Bazel does not skip a directory that has its own `MODULE.bazel`. The root uses the module through a dev dependency and `local_path_override`. - `.bcr/config.yml` lists both module roots. The new module reuses the `rules_helm` release archive with `strip_prefix = "modules/rules_helm_img"`. - `tests/bzl_version` also compares the new module's version and its `rules_helm` dependency with `version.bzl`, so a release that misses a bump fails on the pull request. `release_prep.sh` checks the same values as a backstop. - `rules_helm_img_smoke_build_test` builds the module's smoke target from the root. `//...` does not reach it, and a missing `bazel_dep(platforms)` in the module passed the root tests and failed a standalone build on Bazel 9.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on periareon#305, so the diff is one commit. It shows the first of the three options in my reply to the review question on periareon#305 ("Is there a way to avoid this being a mandatory dependency?", comment). It is opened on the fork because the base branch is there.
Problem
Bazel has no optional
bazel_dep, and a dev dependency is invisible to dependents. Whilehelm/rules_img.bzlis inrules_helm, a consumer that never useshelm_oci_manifeststill fetchesrules_img(about 1.3 MB of source),hermetic_launcher(164 KB) and theimg_toolchainhub repo (20 KB), and gets its module versions raised.Change
helm_oci_manifestmoves tomodules/rules_helm_img, a second module in this repository.rules_helmkeepsrules_imgas a dev dependency only.rules_helmrelease archive withstrip_prefix = "modules/rules_helm_img"and is listed in.bcr/config.ymlas a second module root. Both modules have one version and are released from one tag.helm_oci_partsrule.HELM_OCI_PARTS_APIinhelm/private/oci_parts.bzlmakes arules_helm_imgthat runs against arules_helmwith a different interface fail with a clear message.bazel_depversions are minimums, so nothing else detects that pairing.MODULE.bazel, so.bazelignorekeeps the module out of//.... The root uses it through a dev dependency andlocal_path_override.tests/bzl_versioncompares the module's version and itsrules_helmdependency withversion.bzl. A release that misses a bump now fails on the pull request.release_prep.shchecks the same values after the tag is pushed, as a backstop.rules_helm_img_smoke_build_testbuilds the module's smoke target from the root.//...does not reach the module, and a missingbazel_dep(platforms)in it passed the root tests and failed a standalone build on Bazel 9.Costs
helm_oci_manifestadds a secondbazel_dep, and the two versions have to match.version.bzl,MODULE.bazel,modules/rules_helm_img/MODULE.bazel). The test above checks them.rules_helmrule.HELM_OCI_PARTS_APIis the only guard, and whoever changes that rule's attributes or outputs has to raise it.helm_oci_manifestsorules_img'smulti_deploycan push a chart periareon/rules_helm#305 changes:rules_imgis no longer a non-dev dependency there, and the "Dependency change" section goes.Verification
On macOS, Bazel 9.x and 7.x:
bazel test //...: 69 pass, 3 skipped (the Linux-onlywith_image_deps_imgtests), plain on 9.x, and with--config=stricton 9.x and 7.x. Buildifier and gofmt pass, and//docs:bookbuilds.rules_helmfetches norules_img,hermetic_launcherorimg_toolchain, andbazel mod graphhas norules_img.multi_deployof a chart. Its--sinkoutput has the manifest digest thathelm_oci_digestgives.--override_module=rules_helm=<checkout>.release_prep.shbuilds the archive, and both modules resolve from it witharchive_overrideand thestrip_prefixabove. The version check exits 1 for a wrong module version, a wrongrules_helmdependency and a missing line, and passes with CRLF line endings, an extra argument on the dependency and a trailing comment.tests/bzl_versionon a mismatched version or dependency, the smoke test withoutbazel_dep(platforms)on Bazel 9, andhelm_oci_manifestwhenHELM_OCI_PARTS_APIdiffers.Not verified
publish-to-bcrwithattest: trueattaches the shared archive's attestation to both modules, and that the registry validator accepts aMODULE.bazelwith a dev dependency andlocal_path_overridefor a module that is published in the same pull request. Check the registry pull request for both modules after the first tag.