Repository navigation
chore(bazel): commit MODULE.bazel.lock and keep it up to date in CI - #12175
Merged
Merged
Conversation
Commit MODULE.bazel.lock again and drop `common --lockfile_mode=off`, so
Bazel's default --lockfile_mode=update applies everywhere.
The new reusable workflow .github/workflows/bazel-lockfile.yml regenerates
the lockfile with `bazel mod deps` on amd64-linux (Namespace):
- update mode, from CI PR Only: when a PR changes an input of the
lockfile, push the regenerated file onto the head branch (forks get the
diff and an artifact);
- check mode, from CI Main: fail when the lockfile isn't what Bazel
generates, which keeps an outdated one out of the merge queue.
Every module extension records a platform-independent result today, so a
new last step of Bazel Test arm64-{linux,darwin} only checks that Bazel
leaves the file unchanged there.
Also: workspace_status.sh ignores MODULE.bazel.lock in its dirty check,
Autofix doesn't stage it, Lock Generate tolerates a malformed one, the
cargo jobs don't trigger on it, targets.py treats it like MODULE.bazel,
and the buildifier pre-commit hook no longer matches it.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Contributor
There was a problem hiding this comment.
🔵 Needs a closer look
The new bot-push workflow crosses credential and runner-cache trust boundaries, and its untested fork/no-cache path requires maintainer-led end-to-end CI validation.
No open issues 🎉
What changed in this PR
Restores Bazel lockfile usage and adds CI automation to keep MODULE.bazel.lock current, reducing repeated module-extension evaluation and network dependency during builds.
Changes:
- Adds a reusable workflow to regenerate PR lockfiles, push updates for same-repository branches, and check consistency in CI Main.
- Adds arm64 consistency checks and adjusts formatting, target selection, Cargo triggers, and build stamping for the lockfile.
- Documents lockfile updates, merge-conflict resolution, platform handling, and troubleshooting.
| File | Description |
|---|---|
ci/scripts/targets.py |
Treats lockfile changes as affecting Bazel targets. |
bazel/workspace_status.sh |
Excludes lockfile changes from dirty-version stamping. |
bazel/README.md |
Documents lockfile maintenance and CI behavior. |
bazel/conf/.bazelrc.build |
Restores Bazel’s default lockfile update mode. |
.pre-commit-config.yaml |
Prevents buildifier from matching the lockfile. |
.github/workflows/ci-pr-only.yml |
Calls lockfile automation and separates it from existing autofixes. |
.github/workflows/ci-main.yml |
Adds lockfile checks and narrows Cargo lockfile triggers. |
.github/workflows/bazel-lockfile.yml |
Implements regeneration, validation, artifact upload, and isolated bot pushes. |
.claude/skills/check-bazel-files/SKILL.md |
Adds lockfile regeneration to Bazel-edit guidance. |
Review effort: Balanced
rzakrzyk
approved these changes
Nov 18, 2026
basvandijk
enabled auto-merge
November 18, 2026 16:52
basvandijk
added a commit
that referenced
this pull request
Nov 18, 2026
Brings in the committed MODULE.bazel.lock (#12175), which records the apt extension's facts and generated repositories, and the other bazel_dep upgrades of this batch. No conflicts. Co-Authored-By: Claude Opus 5.5 <[email protected]>
AleDema
pushed a commit
to AleDema/ic
that referenced
this pull request
Nov 18, 2026
…2153) Upgrades `rules_distroless` from 0.8.0 to [0.9.4](https://github.com/bazel-contrib/rules_distroless/releases/tag/v0.9.4), its latest version on the BCR. GitHub has releases up to v0.11.2 that aren't on the BCR yet. 0.9.4 doesn't fix anything we hit. 0.9.0 replaced the `apt` extension's API ([bazel-contrib/rules_distroless#222](bazel-contrib/rules_distroless#222)). Packages are now declared in MODULE.bazel with `apt.sources_list` and `apt.install(dependency_set, packages)` instead of in a YAML manifest. The extension resolves them against the snapshot's package indices, and `MODULE.bazel.lock` records the result instead of `bazel/resolute.lock.json`. The resolved package set doesn't change. Neither does anything built from it, except the mode of two files in the system-test runtime image. The IC-OS and publish bundles don't depend on rules_distroless. The released Rosetta images use its `passwd` rule and are byte-identical. An evaluation of the extension fetches the snapshot's `Packages.xz` indices (18 MB) and parses the 84 MB of text in them. That takes 4.8 s with the indices in the repository cache, and took 6.5-8 s when it downloaded them from snapshot.ubuntu.com. Without a lockfile, every new Bazel server that needed `@resolute` did that again and needed snapshot.ubuntu.com to be up, which was this PR's main cost. Since dfinity#12175 committed `MODULE.bazel.lock`, Bazel reuses the recorded result and evaluates the extension only when its inputs change, and in CI's Bazel Lockfile jobs (see below). Since the last review, this branch merged that master, added the extension's result to `MODULE.bazel.lock` and updated the comments in MODULE.bazel to match. It also no longer rewords the OVMF comments. ## `MODULE.bazel.lock` `bazel mod deps` adds the `apt` extension to `MODULE.bazel.lock`, which grows from 0.39 MB (2,947 lines) to 0.96 MB (9,436 lines): - **Its result.** The `@resolute` hub, whose `lock_content` holds the resolved package set (one 163 KB line), and two repositories per resolved package (165 `deb_import`, 165 `deb_filemap`). Each `deb_import` entry lists the package's `.deb` URL, sha256 and `depends_on`. A snapshot bump rewrites all 165 URLs, since they contain the timestamp; the entries whose name or sha256 changes show which packages changed. - **Its facts.** The sha256 of each channel's `Packages.xz`, and which variant of each index to fetch (`.xz` for `Packages`, "unavailable" for `Contents`). `resolute-security` and `resolute-updates` have the same sha256 because both indices are empty in this snapshot. - The registry hashes move from 0.8.0 to 0.9.4. The `yq` extension's entry changes only in its usages digest, which changes with rules_distroless's version: rules_distroless makes the same `yq` calls in both versions, and the generated repositories stay the same. The package list is the manifest's, unchanged. Four of the requested packages (`apt`, `dpkg`, `perl` and `libvirt0`) are in no image: `//rs/tests:PACKAGES` doesn't list them, and none of the packages it lists depends on them. 57 of the 165 resolved packages are there only for these four. 41 are there only for `libvirt0`, which has been unused since dfinity#10642. Dropping them is left for a follow-up, so that the resolved set stays the same here. Bazel reuses the recorded result as long as the extension's usages (the `apt` tags), the `.bzl` files it loads (its own and a few of `bazel_lib` and `bazel_tools`), its recorded repository mappings and the lockfile format stay the same. So a new Bazel server evaluates no module extension and downloads nothing to load `@resolute`. Measured in the dev container, three runs each: | On a new Bazel server | 0.8.0 (master) | 0.9.4 | | --- | --- | --- | | `bazel query '@resolute//...'` | 3.4-3.5 s | 3.3 s | | `bazel query //rs/tests:BUILD.bazel` (doesn't load `@resolute`) | 3.3-3.4 s | 3.3-3.5 s | None of these profiles evaluates a module extension. With 0.9.4 they show one lockfile check, of `apt` against `MODULE.bazel.lock`. 0.8.0's `apt` is reproducible, so Bazel keeps its result only in the output base's hidden lockfile. With snapshot.ubuntu.com blocked (a downloader config, and no remote downloader), `bazel query '@resolute//...'` still succeeds. It also does in a new output base, where Bazel has no hidden lockfile to fall back on. In CI run 44362279786 (on fce258f), the arm64-darwin job prints none of the 24 `404 NOT FOUND` warnings, 24 `Remote Cache: NOT_FOUND` warnings and 4 `Could not fetch Contents index` lines that the evaluation printed in that job before the merge. Bazel evaluates the extension again when one of those inputs changes, for example on a snapshot bump or a rules_distroless upgrade. CI's two Bazel Lockfile jobs, CI PR Only's update and CI Main's check (which also runs in the merge queue), do it on every pull request that changes an input of `MODULE.bazel.lock`, even when the `apt` inputs don't change: they remove the recorded results first, but keep the facts. With the facts, the extension downloads only the four `Packages.xz` files, by checksum, so the repository cache and the remote downloader can serve them; only when neither has them does it need snapshot.ubuntu.com. It also doesn't try the index variants that don't exist. I ran what those jobs do in a new output base: remove the results, then `bazel mod deps` with only `bazel/conf/.bazelrc.build` (without CI's Namespace cache). The shared repository cache served the four indices. It took 8.0 s and wrote the same bytes, without download warnings or DEBUG lines. The other 62 module extensions were done after 4.2 s; `apt` took 4.8 s and finished 3.5 s later, so it makes each of those jobs about 3.5 s slower. In CI run 44362279786, `bazel mod deps` took 24 s and 22 s in the two jobs. After a snapshot bump, the facts don't cover the new indices: that evaluation downloads them without checksums, tries every index variant (24 of them return 404 and print warnings), and records new facts. What remains: - Nothing verifies the indices that the first evaluation of a new snapshot downloads; later evaluations check them against the facts. Signature verification of the `Release` files arrives in 0.11.0 ([bazel-contrib/rules_distroless#255](bazel-contrib/rules_distroless#255)), which isn't on the BCR. - `MODULE.bazel.lock` falls under the `*.lock` No-Approvals rule in `.github/CODEOWNERS`, while the deleted `bazel/resolute.lock.json` was owned by `@dfinity/infra` through `/bazel/`. CI re-derives the `apt` result on every pull request that touches the lockfile. As for go_sdk and pip (see dfinity#12175), it uses the recorded facts, the index checksums, as they are. - 0.9.4's package repositories aren't reproducible, so Bazel's repo contents cache doesn't keep them. A new output base extracts them again, even with a warm repository cache like the one CI's Bazel Test All keeps. Analyzing `//rs/tests:ubuntu_test_runtime_image_src` in one creates 199 repository directories (46 MB), where 0.8.0 links 108 from the contents cache (3.8 MB). It took the same time, 6.9-7.2 s against 7.0 s; the `.deb` downloads come from the repository cache either way. - The resolver changes again after 0.9.4 ([bazel-contrib/rules_distroless#273](bazel-contrib/rules_distroless#273) in 0.11.0, [bazel-contrib/rules_distroless#281](bazel-contrib/rules_distroless#281) in 0.11.2). The comment in MODULE.bazel says to review the `apt` entry of `MODULE.bazel.lock` when bumping the snapshot or rules_distroless. ## Changes - **`MODULE.bazel`**: version bump. The `apt.install(name, lock, manifest)` call becomes two `apt.sources_list` calls and one `apt.install(dependency_set = "resolute", ...)`. The `apt.sources_list` calls carry the old manifest's four channels: `resolute` main and universe, `resolute-security` main and `resolute-updates` main, all from snapshot `20260422T000000Z`, amd64 only. The `apt.install` call lists the manifest's 22 packages with their comments, unchanged. New comments explain: - that the package set is used by the system-test runtime image, that the resolved packages depend on both the snapshot timestamp and the rules_distroless version, and that `MODULE.bazel.lock` records them, so Bazel evaluates the extension again only when its inputs change; - how to update the packages (bump the timestamp in both `apt.sources_list` calls and run `bazel mod deps`, which replaces `bazel run @resolute//:lock`), and what to review in the diff of `MODULE.bazel.lock` when bumping the snapshot or rules_distroless; - that `@resolute//<package>/<arch>` targets now exist only for the listed packages, under the provider's name when another package `Provides:` a listed name. - **`MODULE.bazel.lock`**: regenerated with `bazel mod deps`, see above. - **`bazel/resolute.yaml`, `bazel/resolute.lock.json`**: deleted. 0.9.4 has no manifest input. It reads a lock file (through an `apt.lock` tag) only on Bazel versions without `module_ctx.facts`, and it rejects the version 1 format that `bazel/resolute.lock.json` uses. - **`rs/tests/BUILD.bazel`**: the comment above `PACKAGES` pointed at the manifest; it now points at the `resolute` package set in MODULE.bazel. ## Upstream changes that touch our setup - **New API** ([bazel-contrib/rules_distroless#222](bazel-contrib/rules_distroless#222), 0.9.0). The `@resolute` hub now has `//<package>/<arch>` targets only for the requested packages, not for all 165 resolved ones. The 18 in `//rs/tests:PACKAGES` are all requested packages, except `coreutils-from-uutils`, which is what the requested `coreutils` resolves to. `coreutils` and `libvirt0` are real packages, but when another package `Provides:` a requested name, rules_distroless prefers that provider (apt would install the real package). So `coreutils` resolves to `coreutils-from-uutils` and `libvirt0` to `libvirt0-hwe`, as with 0.8.0. - **`deb_import`** (dfinity#222). In 0.8.0 a macro around `http_archive`, it is now a repository rule of its own, which doesn't mark its repositories reproducible (see above). The BUILD file it generates also declares C++ targets (`so_library`, `cc_deb_library` and `cc_library`, and `cc_import` for packages with pkg-config files). It always loads `@rules_cc//cc/private/rules_impl:cc_import.bzl`, `@rules_cc//cc:cc_library.bzl` and `@bazel_skylib//rules/directory:directory.bzl`, and its `deb_export` rule loads `@aspect_bazel_lib//lib:tar.bzl`. All of them exist in our rules_cc 0.2.28, bazel_skylib 1.9.2 and aspect_bazel_lib 2.22.5. The C++ targets have no headers or libraries for any of the 108 packages we fetch, and nothing here uses them: `deb_import` only lists the files of a `data.tar.xz`, and 107 of them ship `data.tar.zst` (the other one, `passwd`, has no libraries or headers). The package's data layer is renamed from `layer.tar.gz` to `content.tar.gz`, with the same bytes. - **New module dependencies.** The module now also depends on `aspect_bazel_lib` 2.14.0 and `rules_cc` 0.2.8. Both are below our versions, so the module graph doesn't change otherwise. - **Resolver changes.** When several different packages provide a name the resolver looks up (a requested package or one of its dependencies) and none of them has `Priority: required`, 0.9.x picks the provider with the highest version, where 0.8.0 fell back to a real package of that name. It also expands `Architecture: all` packages per architecture ([bazel-contrib/rules_distroless#235](bazel-contrib/rules_distroless#235)) and leaves foreign-architecture dependencies out ([bazel-contrib/rules_distroless#241](bazel-contrib/rules_distroless#241)). Our package set resolves the same (see Verification). - **`cacerts` file modes** ([bazel-contrib/rules_distroless#225](bazel-contrib/rules_distroless#225), 0.9.0). `cacerts` now writes `/etc/ssl/certs/ca-certificates.crt` and `/usr/share/doc/ca-certificates/copyright` with mode 0644 instead of 0555; directories stay 0755. This is the only difference in `//rs/tests:ca_certificates`. It is therefore also the only difference in the system-test runtime image `//rs/tests:ubuntu_test_runtime_image_src` and in the httpbin image built from it. `//rs/tests:colocate_uvm_config_image` contains the runtime image's tarball and also records that file's mtime (see Verification). The bundle stays world-readable. - **`flatten`** ([bazel-contrib/rules_distroless#228](bazel-contrib/rules_distroless#228), 0.9.1). `flatten` now takes `rm` from `bazel_lib`'s coreutils toolchain. `//rs/tests:ubuntu_packages_tar` is byte-identical. ## Verification All of this ran in the dev container on this branch, which has master at 195b444 merged in. 0.8.0 is that master commit, built in the same output base. - **`MODULE.bazel.lock`**: - `bazel mod deps` generates it. A second run on a new server leaves it unchanged, and so does `bazel build //... --nobuild`. - What CI's Bazel Lockfile jobs do gives the same bytes in a new output base (see above). - In CI run 44362279786 (on fce258f), CI PR Only's Bazel Lockfile job found nothing to update, CI Main's check of the merge with master passed, and so did the `Check MODULE.bazel.lock` steps of Bazel Test arm64-linux and arm64-darwin. - The last commit, cd02db0, changes only comments in MODULE.bazel. With it, `bazel mod deps` leaves `MODULE.bazel.lock` unchanged. - **`bazel mod graph`**: only `rules_distroless` changes. All other modules resolve to the same versions, and there are no new warnings. - **Resolution.** The lock content recorded in `MODULE.bazel.lock` (`bazel mod show_repo @resolute`) has the same 165 packages, versions, sha256s and URLs as the deleted lock file. Each of the 22 requested packages has the same dependency closure, in the same order. - **`bazel build //... --nobuild`**: all 3375 targets analyze. - **Builds, compared with 0.8.0.** - I built every target that uses a rules_distroless rule (four `passwd`, `cacerts`, `dpkg_status`, `flatten`), and the 18 `@resolute` packages we use with their `:control` targets. - I also built the images that contain them: `//rs/tests:ubuntu_test_runtime_image_src`, `//rs/tests:ubuntu_test_runtime.tar`, `//rs/tests:colocate_uvm_config_image`, `//rs/tests/httpbin-rs:httpbin.tar`, `//rs/rosetta-api/icp:rosetta_image.tar` and `//rs/rosetta-api/icrc1:icrc_rosetta_image.tar`. - 44 of these 49 targets are byte-identical with 0.8.0. They include `//rs/tests:ubuntu_packages_tar` (163 MB), `:dpkg_status`, the four `passwd` layers and both Rosetta images. - The other 5 are `//rs/tests:ca_certificates` and the images and tarballs that contain it. 7 of the 142 distinct files these targets output differ: - `ca_certificates` differs only in the file modes above; the file contents are the same. - In the image tarballs, only that layer and the config and manifest that reference it differ. - The FAT image `//rs/tests:colocate_uvm_config_image` holds the runtime tarball and also records that file's time, because `mcopy -m` keeps the tarball's mtime, which is when Bazel wrote it. - Matched package by package, the 108 per-package data layers among these outputs are byte-identical too. - **Release artifacts**: not rebuilt. The unconfigured `bazel query 'deps(...)'` of the IC-OS bundles, `//publish/binaries:bundle` and `//publish/canisters:bundle` has 57,438 labels. It contains no `rules_distroless` or `@resolute` label, and none of the targets above. The Rosetta images, which `rosetta-release.yml` pushes, are among the byte-identical builds above. - **CI's lint checks** pass: `shfmt-check`, `ruff-check`, `buf-check`, `DFINITY-capitalization-check`, `do-not-merge-check`, `buildifier-check`, `gazelle-check` and `buf-breaking-check`. The autofixes (buildifier, shfmt, ruff and gazelle) change nothing. These and `bazel build //... --nobuild` ran on the final MODULE.bazel. CI's Autofix job, which also runs rustfmt, passed on fce258f. - **System tests**: none run locally. - All 452 tests that depend on these targets are system tests under `//rs/tests/...`: 413 Farm variants and 39 `_local` variants. - This PR's CI selects 2 of them, `//rs/tests/networking:canister_http_non_replicated_test_local` and `//rs/tests/node:root_tests_local`. Both reach `//rs/tests:ca_certificates` through the runtime image, and both passed before the merge with master. - CI Main on master also runs 32 more `_local` dependents, which are tagged `long_test`; so does a PR with the `CI_ALL_BAZEL_TARGETS` label. The other 5 `_local` dependents have tags that CI Main excludes. - Of the Farm variants, CI Main runs none. `release-testing.yml` and the nightly workflows run those of `system_test_large` tests and of nightly- or benchmark-tagged tests. They also run two `manual` ones by name: `//rs/tests/dre:guest_os_qualification_farm_colocate` and `//rs/tests/nested/nns_recovery:nr_large_with_mainnet_state_farm_colocate`. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
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.
Commits
MODULE.bazel.lockagain (it was removed in #1990) and adds CI that keeps it current.Why
With
--lockfile_mode=off, every new Bazel server:metadata.jsonfor every module, so an upstream yank can break the build;rules_distroless 0.9.x about 84 MB of apt indices (this blocks chore(bazel): upgrade rules_distroless from 0.8.0 to 0.9.4 #12153).
What changes
MODULE.bazel.lock(Bazel 9.3.2, lockFileVersion 28, 0.39 MB) is committed, andcommon --lockfile_mode=offisgone, so Bazel's default
updatemode applies everywhere..github/workflows/bazel-lockfile.yml. It runs on Namespace (namespace-profile-rbe-driver-amd64-linux-16x32,or its
-no-cachecopy for reviewed fork code) and has two modes:bazel mod deps. If it changed,a separate push job commits "Automatically updated MODULE.bazel.lock" onto the head branch. Fork PRs get the diff and an artifact
instead. The push job is the only job that holds the bot's key, and it runs no Bazel.
queue, where
ci-pr-only-statusis always green.general) result today. A new last step ofBazel Test arm64-{linux,darwin} fails when Bazel rewrites the file on those platforms. On pushes that step only reports, so it can't
block artifact uploads.
bazel/workspace_status.shignoresMODULE.bazel.lockin its dirty check, so a stale lockfile on a release branch can't produce-dirtyartifacts.targets.pytreats it likeMODULE.bazel.bazel/README.md, and the check-bazel-files skill.For developers
MODULE.bazel,bazel/*.MODULE.bazel, a module override patch,.bazelversionorrequirements.txt, runbazel mod deps >/dev/nulland commit the lockfile. On a PR from a branch in this repository the bot also does it.MODULE.bazel.lockleft over from earlier experiments.bazel_depbumps will often conflict in the lockfile. The recipe is inbazel/README.md.Notes for review
CODEOWNERS is unchanged.
MODULE.bazel.lockfalls under the*.lockNo-Approvals rule. What CI does with each part of the file:Requiring infra approval would take a
/MODULE.bazel.lock @dfinity/infraline after the No-Approvals block.Exercised in CI so far:
arm64-darwin passed. The darwin leg builds all of
//rs/...and//packages/....byte for byte, and the run for the bot's commit was green.
dev-gh-bazel-lockfile: the plain check passed for this commit. For a commit with one registry hash deleted, it failedwith the expected annotation and uploaded the repaired file as
bazel-lockfile-check.Not exercised yet: the fork path through CI Kickoff Manual, to be tried after merge.
Verified locally
These all produced identical bytes in the dev container:
bazel build //... --nobuildleaves the file unchanged.🤖 Generated with Claude Code