Skip to content

chore(bazel): test that CI repairs a hand-edited MODULE.bazel.lock (do not merge) - #12176

Closed
basvandijk wants to merge 2 commits into
bas/module-bazel-lockfrom
bas/module-bazel-lock-push-test
Closed

basvandijk wants to merge 2 commits into
bas/module-bazel-lockfrom
bas/module-bazel-lock-push-test

Conversation

@basvandijk

Copy link
Copy Markdown
Collaborator

Throwaway test for #12175. Do not merge; I'll close it once the run has finished.

It hand-edits one recorded module extension result in MODULE.bazel.lock: the version of the yq_darwin_amd64 repository in the yq
extension's entry. The entry's digests are unchanged, so Bazel's update mode alone would keep the edit.

Expected:

  1. The Bazel Lockfile job of CI PR Only re-derives the entry and its push job commits "Automatically updated MODULE.bazel.lock".
  2. CI Main's Bazel Lockfile check fails on this first run.
  3. The run for the bot's commit is green on both.

🤖 Generated with Claude Code

…ck (do not merge)

Changes the version of the yq_darwin_amd64 repository that the yq module
extension's entry records, keeping the entry's digests, to check that the
Bazel Lockfile job of CI PR Only (bazel-lockfile.yml) re-derives the entry
and that its push job commits the repaired file.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot added the chore label Nov 18, 2026
@basvandijk

Copy link
Copy Markdown
Collaborator Author

Worked as expected, closing:

  • Run 1: the Bazel Lockfile job of CI PR Only found the hand-edited entry. Its push job committed "Automatically updated MODULE.bazel.lock" (e2c3e85), which restores the file byte for byte, and the push started a new run.
  • Run 2, on the bot's commit: both the update job and CI Main's Bazel Lockfile check passed, with nothing to push. I cancelled the rest of that run.

🤖 Generated with Claude Code

@basvandijk basvandijk closed this Nov 18, 2026
@basvandijk
basvandijk deleted the bas/module-bazel-lock-push-test branch November 18, 2026 16:44
AleDema pushed a commit to AleDema/ic that referenced this pull request Nov 18, 2026
…finity#12175)

Commits `MODULE.bazel.lock` again (it was removed in dfinity#1990) and adds CI
that keeps it current.

## Why

With `--lockfile_mode=off`, every new Bazel server:
- re-evaluates every module extension;
- fetches registry files without checksums;
- fetches `metadata.json` for every module, so an upstream yank can
break the build;
- refetches what the extensions look up on the network: the PyPI index
for pip (dfinity#12041), go.dev for go_sdk, and for
rules_distroless 0.9.x about 84 MB of apt indices (this blocks dfinity#12153).

## What changes

- **The lockfile.** `MODULE.bazel.lock` (Bazel 9.3.2, lockFileVersion
28, 0.39 MB) is committed, and `common --lockfile_mode=off` is
  gone, so Bazel's default `update` mode applies everywhere.
- **New reusable workflow `.github/workflows/bazel-lockfile.yml`.** It
runs on Namespace (`namespace-profile-rbe-driver-amd64-linux-16x32`,
  or its `-no-cache` copy for reviewed fork code) and has two modes:
- **update**, called from CI PR Only: when a PR changes an input of the
lockfile, regenerate it with `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.
- **check**, called from CI Main: fail when the lockfile isn't what
Bazel generates. This keeps an outdated lockfile out of the merge
    queue, where `ci-pr-only-status` is always green.
- On PRs and merge groups that touch an input, it re-derives the module
extension results, which catches bad merges.
    - On pushes it does a plain update.
- **Generated on amd64-linux only.** Every module extension records a
platform-independent (`general`) result today. A new last step of
Bazel 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.
- **Small adjustments.**
- `bazel/workspace_status.sh` ignores `MODULE.bazel.lock` in its dirty
check, so a stale lockfile on a release branch can't produce
    `-dirty` artifacts.
- Autofix doesn't stage the file, and Lock Generate tolerates a
malformed one.
- The cargo jobs no longer trigger on it, and `targets.py` treats it
like `MODULE.bazel`.
  - The buildifier pre-commit regex no longer matches it.
- **Docs.** A new "MODULE.bazel.lock" section in `bazel/README.md`, and
the check-bazel-files skill.

## For developers

- After changing `MODULE.bazel`, `bazel/*.MODULE.bazel`, a module
override patch, `.bazelversion` or `requirements.txt`, run
`bazel mod deps >/dev/null` and commit the lockfile. On a PR from a
branch in this repository the bot also does it.
- Before pulling this change, delete any untracked `MODULE.bazel.lock`
left over from earlier experiments.
- Parallel `bazel_dep` bumps will often conflict in the lockfile. The
recipe is in `bazel/README.md`.

## Notes for review

- **CODEOWNERS is unchanged.** `MODULE.bazel.lock` falls under the
`*.lock` No-Approvals rule. What CI does with each part of the file:
- it re-derives the module extension results on every PR that touches an
input;
  - registry hashes are checked against what Bazel downloads;
  - facts (go_sdk, pip, msvc_runtime) are used as recorded.

Requiring infra approval would take a `/MODULE.bazel.lock
@dfinity/infra` line after the No-Approvals block.
- **Exercised in CI so far:**
- This PR: the update job found nothing to push, CI Main's check passed,
and the new step of Bazel Test arm64-linux and
arm64-darwin passed. The darwin leg builds all of `//rs/...` and
`//packages/...`.
- Throwaway dfinity#12176 hand-edited a recorded extension result. The update
job re-derived it, the push job committed the repaired file
    byte for byte, and the run for the bot's commit was green.
- Pushes to `dev-gh-bazel-lockfile`: the plain check passed for this
commit. For a commit with one registry hash deleted, it failed
with 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:
- two from-scratch generations;
- a generation with CI's rc set;
- the check job's strip and regeneration;
- a plain update.

`bazel build //... --nobuild` leaves the file unchanged.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant