Skip to content

chore(IDX): remove bazel lockfile - #1990

Merged
nmattia merged 1 commit into
masterfrom
nm-no-bazel-lockfile
Oct 11, 2024
Merged

nmattia merged 1 commit into
masterfrom
nm-no-bazel-lockfile

Conversation

@nmattia

@nmattia nmattia commented Oct 11, 2024

Copy link
Copy Markdown
Contributor

This removes the MODULE.bazel.lock bazel lockfile. The lockfile format is still in flux and creates some friction, both through PR noise and extra infrastructure needed to keep it up to date (see now removed bazel-lockfile.yml).

For that reason we disable the lockfile with bazel build --lockfile_mode=off and will revisit in the future. We still use bzlmod.

This removes the `MODULE.bazel.lock` bazel lockfile. The lockfile format
is still in flux and creates some friction, both through PR noise and
extra infrastructure needed to keep it up to date (see now removed
`bazel-lockfile.yml`).

For that reason we disable the lockfile with `bazel build
--lockfile_mode=off` and will revisit in the future. We still use
bzlmod.
@nmattia
nmattia requested a review from a team as a code owner October 11, 2024 10:03
@github-actions github-actions Bot added the chore label Oct 11, 2024
@nmattia
nmattia enabled auto-merge October 11, 2024 10:05
@nmattia
nmattia added this pull request to the merge queue Oct 11, 2024
Merged via the queue into master with commit 261ec1b Oct 11, 2024
@nmattia
nmattia deleted the nm-no-bazel-lockfile branch October 11, 2024 10:30
marko-k0 pushed a commit that referenced this pull request Oct 11, 2024
This removes the `MODULE.bazel.lock` bazel lockfile. The lockfile format
is still in flux and creates some friction, both through PR noise and
extra infrastructure needed to keep it up to date (see now removed
`bazel-lockfile.yml`).

For that reason we disable the lockfile with `bazel build
--lockfile_mode=off` and will revisit in the future. We still use
bzlmod.
nikolay-komarevskiy pushed a commit that referenced this pull request Oct 11, 2024
This removes the `MODULE.bazel.lock` bazel lockfile. The lockfile format
is still in flux and creates some friction, both through PR noise and
extra infrastructure needed to keep it up to date (see now removed
`bazel-lockfile.yml`).

For that reason we disable the lockfile with `bazel build
--lockfile_mode=off` and will revisit in the future. We still use
bzlmod.
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.

2 participants