Skip to content

chore(bazel): upgrade gazelle from 0.51.3 to 0.54.0 - #12149

Merged
basvandijk merged 2 commits into
masterfrom
bas/gazelle-0.54.0
Nov 18, 2026
Merged

basvandijk merged 2 commits into
masterfrom
bas/gazelle-0.54.0

Conversation

@basvandijk

@basvandijk basvandijk commented Nov 17, 2026 •

Copy link
Copy Markdown
Collaborator

Upgrades gazelle from 0.51.3 to 0.54.0, its latest release. The BCR's 1.0.0-beta.1 and 2.0.0-beta.* are pre-releases.

The repository has no Go sources. We use gazelle in two places:

  • //:gazelle, which CI's Linter job runs as //pre-commit:gazelle-check and again as an autofix. This PR moves its definition to //bazel/gazelle and keeps //:gazelle as an alias (see Changes).
  • The go_deps extension, which creates the go.mod repos (@com_github_fatih_color, ...). It also writes the config that @rules_go//go (our //:gobin) reads.

Nothing gazelle builds ends up in what we ship.

Changes

  • MODULE.bazel: version bump. The BCR entry of 0.54.0 adds two dependencies. One is platforms 1.1.0, which we already resolve; the other, rules_testing, is dev-only. Its only BCR patch sets the module version. gazelle is also required by rules_go 0.62.0 (0.51.3) and rules_buf 0.5.2 (0.34.0), so the root module's requirement decides the version. No other module's resolved version changes.
  • BUILD.bazel and the new bazel/gazelle/BUILD.bazel: the gazelle and gazelle-update-repos targets move from the root package to //bazel/gazelle. With 0.54.0, loading @gazelle//:def.bzl fetches the Go SDK, and every build on Linux loads the root package (see the go_deps item below). The root package keeps //:gazelle and //:gazelle-update-repos as aliases, so bazel run //:gazelle, //pre-commit:gazelle-check, CI's Autofix step and bazel/README.md work unchanged. It also keeps the # gazelle:prefix and # gazelle:proto disable directives, which apply to the whole repository. Gazelle takes its working directory from BUILD_WORKSPACE_DIRECTORY, so the package that defines the target doesn't change what it processes.

#12151 (rules_buf 0.6.1, which requires gazelle 0.54.0) is stacked on this PR. #12148 (rules_go 0.65.0) rewrites the comment and the rules_go line right above the gazelle bazel_dep in MODULE.bazel, so git reports a merge conflict between the two: whichever lands second needs master merged in, keeping both new lines.

Upstream changes that touch our setup

  • The Gazelle binary is now a plain go_binary (bazel-contrib/bazel-gazelle#2386). Its update command now drives the built-in (v1) language extensions through v2 compatibility wrappers (#2423), and the directory walk moved to the v2 packages (#2330). CI's gazelle-check and Autofix steps run this binary. With 0.54.0, bazel run //:gazelle builds and leaves the tree unchanged, as it did with 0.51.3, so the upgrade causes no Autofix commit.
  • go_deps now computes the Go environment itself (#2392), and records GOROOT as a label (#2374, #2385). This has two effects for us:
    • The go_env.bzl and config.json of @bazel_gazelle_go_repository_config used to hold an empty environment. They now hold GOROOT = "@@rules_go++go_sdk+go_default_sdk//:ROOT" and GOTOOLCHAIN = "local". Both places where we use them replace that GOROOT with the SDK's path. The //:gazelle runner script does it in its set_goroot. rules_go's go_bin_runner, behind //:gobin, appends GOROOT=<sdk path> after the config values. bazel run //:gobin -- env GOROOT GOTOOLCHAIN GOMOD prints the SDK path, local and our go.mod.
    • Evaluating go_deps now fetches rules_go's Go SDK: go1.25.0, a 57 MiB archive that takes 242 MiB on disk once extracted. Its compute_env resolves the SDK's ROOT file, and go_deps.bzl now loads @bazel_gazelle_go_repository_cache//:def.bzl. @gazelle//:def.bzl loads the go_env.bzl that go_deps generates, so loading def.bzl evaluates go_deps. The root BUILD.bazel loaded it, and on Linux every bazel build, test, run, cquery and aquery loads the root package, because bazel/conf/.bazelrc.build points --platforms and --host_platform at //:linux-glibc-2.31. So with the version bump alone (the first commit), every build on Linux fetched the SDK, also for targets without Go, which don't fetch it with 0.51.3. On a cold cache, that means downloading and extracting it. That's why this PR moves the gazelle targets out of the root package; the measurements are under Verification. Builds that include the gazelle targets or //:gobin, such as //..., still fetch the SDK, as they did with 0.51.3.
  • go_repository moves its generated package metadata targets to a _gazelle_generated package (#2407). Their PURLs now include the go.sum checksum (#2409). For our five go_deps repos, this is the only difference in the generated BUILD.bazel and REPO.bazel files (compared file by file), and the generated Go rules are identical. Nothing in this repository reads that metadata.
  • Module downloads: fetch_repo now checks module sums against the JSON output of go mod download (#2366). All our go_deps repos fetch, and their sums verify.
  • rules_buf 0.5.2 imports bazel_gazelle_go_repository_tools from gazelle's internal non_module_deps extension. 0.54.0 still provides that repo under the same name. We only use rules_buf's prebuilt buf, and buf-check and buf-breaking-check pass.

Verification

All of the following except the CI results ran in the dev container. The module graph, go_deps repos and //:gobin checks ran on the first commit; the second commit doesn't change MODULE.bazel or anything those checks use. The other checks ran on the final state.

  • Module graph: bazel mod explain gazelle shows 0.54.0, required by the root module, rules_go 0.62.0 and rules_buf 0.5.2. Compared with the base commit, the full bazel mod graph differs only in gazelle's version and its new platforms edge. There are no new warnings; the only one is the existing rules_qemu use_repo warning.

  • Analysis: bazel build //... --nobuild analyzes all 3389 targets. That's 2 more than on the first commit (3387): the //... pattern matches the new aliases //:gazelle and //:gazelle-update-repos, while the gazelle macro tags the sh_binary targets it creates manual.

  • Linter job: //pre-commit:{shfmt-check,ruff-check,buf-check,DFINITY-capitalization-check,do-not-merge-check,buildifier-check,gazelle-check,buf-breaking-check} all pass. The autofixes (buildifier-fix, shfmt-fix, ruff-fix and bazel run //:gazelle) leave git status clean.

  • Gazelle: bazel run //:gazelle (through the alias), bazel run //bazel/gazelle and bazel run //:gazelle -- -mode=diff exit 0 and change no files. bazel run //:gazelle-update-repos, which bazel/README.md documents, fails with loading WORKSPACE file: ... no such file or directory, as it does with 0.51.3 at the base commit. The repository has no WORKSPACE file.

  • Repos fetched by builds without Go: bazel build --nobuild of two targets, each in a fresh output base, then the repos under external/:

    //.github:CODEOWNERS //rs/types/base_types:base_types
    Base commit (0.51.3) 27 repos, no Go SDK 304 repos, no Go SDK
    First commit (0.54.0, gazelle targets in the root package) 29: adds rules_go++go_sdk+go_default_sdk and gazelle++non_module_deps+bazel_gazelle_go_repository_cache 306: adds the same two
    This PR (0.54.0, gazelle targets in //bazel/gazelle) 19: none from gazelle, rules_go or rules_buf 300: no Go SDK and no gazelle repos; the Go-related ones left (rules_go+, go_toolchains, io_bazel_rules_nogo) are in the base commit's list too
  • go_deps repos: I ran bazel test --keep_going over //... of the five repos we import (@com_github_fatih_color, @com_github_google_go_cmp, @com_github_schollz_closestmatch, @com_github_spf13_cobra, @com_github_stretchr_testify). I ran it with 0.54.0 first, then with 0.51.3, in the same output base.

    • 10 of the 14 tests pass with both versions.
    • The other four fail the same way with both versions, for reasons unrelated to gazelle. For example, closestmatch reads test/books.list, which the generated go_test doesn't list as data, and testify's suite test runs go from the PATH.
    • @com_github_spf13_cobra//doc doesn't analyze with either version, because our go.mod doesn't include go-md2man.
    • In the 0.51.3 run, every compile and link action and the 10 passing tests were cache hits from the 0.54.0 run. So the Go rules that gazelle generates produce identical actions.
  • //:gobin: version, env and mod verify work ("all modules verified").

  • Release artifacts: I didn't run the byte-identity build, because gazelle isn't in the release artifacts' build graph. I ran bazel cquery 'deps(...)' over the GuestOS (prod disk and update, recovery update), HostOS and SetupOS bundles plus //publish/binaries:bundle and //publish/canisters:bundle. Of its 110,935 labels, none comes from gazelle, its repos, rules_go or the Go SDK. On the final state, intersected with the root package and //bazel/gazelle, the same query returns only //:linux-glibc-2.31, //:mainnet-routing-table.json, //:mke2fs, //:debugfs, //:e2fsdroid and //:ovmfsev_code, none of which this PR changes.

  • CI on the first commit passed, including the darwin job. Its Build pocket-ic-server x86_64-darwin step builds with --platforms=//:macos-intel, a platform in the root package, so that run evaluated 0.54.0's go_deps on macOS. The job log doesn't list repository fetches, so it doesn't show the SDK download itself. With the gazelle targets moved, builds on macOS that don't involve them no longer evaluate go_deps.

  • Not verified: running //:gazelle on macOS. CI covers the full build and tests.

🤖 Generated with Claude Code

Bump the gazelle bazel_dep to its latest release. No other module's
resolved version changes. `bazel run //:gazelle` leaves the tree
unchanged, and the go_deps repos generate the same Go rules as before.
The package metadata targets of those repos move to a
`_gazelle_generated` package.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are recorded for the Gazelle tooling dependency update.

No open issues 🎉

What changed in this PR

Upgrades Gazelle from 0.51.3 to 0.54.0 for Bazel build-file generation and Go dependency setup. The change affects development tooling, not shipped artifacts.

Changes:

  • Updates the root Gazelle dependency requirement; no other code changes are included.
File Description
MODULE.bazel Bumps Gazelle from 0.51.3 to 0.54.0.

Review effort: Balanced

With gazelle 0.54.0, loading @gazelle//:def.bzl evaluates the go_deps
extension, which now fetches rules_go's Go SDK. Every Linux build loads the
root package (--platforms and --host_platform point at
//:linux-glibc-2.31), so with the root BUILD.bazel loading def.bzl every
Linux build fetched and extracted the Go SDK on a cold cache, even for
targets without Go.

Move the gazelle and gazelle-update-repos targets to //bazel/gazelle. The
root package keeps them as aliases (so `bazel run //:gazelle`,
//pre-commit:gazelle-check and the docs keep working) and keeps the
gazelle directives, which apply to the whole repository.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

There are no active review issues for the Gazelle upgrade and target relocation.

No open issues 🎉

Review effort: Balanced

basvandijk added a commit that referenced this pull request Nov 18, 2026
Stack this PR on the gazelle 0.54.0 upgrade (#12149): rules_buf 0.6.1
requires gazelle 0.54.0, and #12149 moves the gazelle targets out of the
root package so that ordinary builds don't fetch the Go SDK.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@basvandijk
basvandijk requested a balanced review from Copilot November 18, 2026 04:26

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues remain for the Gazelle upgrade and target relocation.

No open issues 🎉

Review effort: Balanced

@basvandijk
basvandijk marked this pull request as ready for review November 18, 2026 08:11
@basvandijk
basvandijk requested a review from a team as a code owner November 18, 2026 08:11
@basvandijk
basvandijk added this pull request to the merge queue Nov 18, 2026
Merged via the queue into master with commit dfae16a Nov 18, 2026
50 checks passed
@basvandijk
basvandijk deleted the bas/gazelle-0.54.0 branch November 18, 2026 10:41
basvandijk added a commit that referenced this pull request Nov 18, 2026
master now has #12149 (gazelle 0.51.3 -> 0.54.0), which changed the gazelle
line next to this PR's rules_go line. The resolution keeps both: rules_go
0.65.0 with this PR's comment, and gazelle 0.54.0 from master.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
basvandijk added a commit that referenced this pull request Nov 18, 2026
#12149, which this PR was stacked on, has landed in master (squash-merged),
so this PR now targets master. Merging master makes its diff show only its own
changes again. 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
Upgrades `rules_go` from 0.62.0 to
[0.65.0](https://github.com/bazel-contrib/rules_go/releases/tag/v0.65.0),
its latest release.

The repository has no Go sources and no `go_*` targets of its own.
rules_go builds `//:gazelle` (which `//pre-commit:gazelle-check` and the
Linter job's autofix run) and `//:gazelle-update-repos`, and provides
the `go` tool behind `//:gobin`. `bazel query 'rdeps(//...,
@rules_go//:go_context_data)'` lists only those targets in the main
repository.

## Changes

- **`MODULE.bazel`**: version bump, and a rewritten comment above it.
The old comment said that 0.62.0 matched the resolved graph because the
llvm module pulled it in. The llvm module (0.8.16, and also the latest
0.8.27) declares `bazel_dep(name = "rules_go", version = "0.62.0",
repo_name = None)`, so it only sets a minimum version. gazelle 0.51.3
requires 0.59.0 and rules_buf 0.5.2 requires 0.42.0. The root module's
0.65.0 is now the highest requirement, so it's the version that
resolution selects. BCR's `rules_go/0.65.0` has only the usual
`module_dot_bazel_version.patch`, and we carry no patch or override for
rules_go.

In the module graph, only rules_go's version changes. It also gains an
edge to `package_metadata`: 0.65.0 requires 0.0.5, which already
resolves to 0.0.7. On a fresh Bazel server the warnings are the same as
on master (only the existing rules_qemu `use_repo` one). That includes
gazelle's `go_deps` extension, which prints no warnings.

## What changes for us

- **Default Go SDK 1.25.0 → 1.26.7.** We don't declare a `go_sdk`, and
no other module in our graph does outside its dev dependencies. `bazel
mod show_extension @rules_go//go:extensions.bzl%go_sdk` shows only
rules_go's own `go_sdk.from_file(name = "go_default_sdk", go_mod =
"//:go.mod")`; gazelle only imports `go_host_compatible_sdk_label`. That
SDK's version comes from the `toolchain` line of rules_go's own
`go.mod`, which
[bazel-contrib/rules_go#4697](bazel-contrib/rules_go#4697)
bumped from go1.25.0 to go1.26.7 (released in 0.64.0). So Gazelle is now
compiled with Go 1.26.7, and `bazel run //:gobin -- version` prints
`go1.26.7` instead of `go1.25.0`.
- **Go modules in the Gazelle build.** gazelle's `go_deps` extension
resolves the Go modules that all Bazel modules' `go.mod` files require,
and the highest version wins. rules_go's `go.mod` now raises the
following (from `bazel mod show_repo`, master → this PR):
- compiled into Gazelle: `golang.org/x/mod` v0.25.0 → v0.41.0,
`golang.org/x/sync` v0.15.0 → v0.23.0 and `golang.org/x/sys` v0.33.0 →
v0.48.0.
- `golang.org/x/tools` v0.34.0 → v0.51.0
([dfinity#4701](bazel-contrib/rules_go#4701),
[dfinity#4740](bazel-contrib/rules_go#4740)). Its
`goyacc` generates the BUILD-file parser of buildtools during the
Gazelle build.

Gazelle's other dependencies (buildtools, doublestar, go-difflib,
`x/tools/go/vcs`) don't change. rules_go's `go.mod` requires none of the
Go modules that our `go.mod` requires directly.

## Upstream changes that touch our setup

- [dfinity#4762](bazel-contrib/rules_go#4762) raises
the minimum Bazel version to 7.7.0 (`bazel_compatibility`). We use
9.3.2.
- [dfinity#4761](bazel-contrib/rules_go#4761) removes
the `//go/private:request_nogo` setting. We don't configure nogo, and
neither gazelle 0.51.3 nor 0.54.0 references that setting. Gazelle
0.51.3's `gazelle_binary` uses `go_context`, `new_go_info`, `GoArchive`
and `CGO_ATTRS`/`CGO_FRAGMENTS`/`CGO_TOOLCHAINS`, which all still exist.
Gazelle 0.54.0 (dfinity#12149) uses `go_binary`, `GoArchive`, `go_context` and
the same `CGO_*` symbols.
- cgo, which the hermetic LLVM toolchain compiles:
- [dfinity#4671](bazel-contrib/rules_go#4671) replaces
cgo's default `-fdebug-prefix-map` flags with `-ffile-prefix-map`, which
clang supports, so `__FILE__` no longer embeds absolute paths. This also
covers the cgo part of the standard library build.
- [dfinity#4739](bazel-contrib/rules_go#4739) also
makes `-internal-externc-isystem`/`-stdlib++-isystem` header paths
absolute. llvm 0.8.16 (and 0.8.27) passes neither and uses `-Xclang
-internal-isystem`, which rules_go already handled.
- [dfinity#4667](bazel-contrib/rules_go#4667) turns off
path mapping for cgo standard library builds. We don't enable path
mapping.
- [dfinity#4689](bazel-contrib/rules_go#4689) and
[dfinity#4704](bazel-contrib/rules_go#4704) change how
the `static`, `pure` and `linkmode` settings reach Go tool binaries.
[dfinity#4706](bazel-contrib/rules_go#4706) applies the
`static` attribute at link time instead of through a transition. We set
none of the `//go/config` flags or those attributes.
- [dfinity#4728](bazel-contrib/rules_go#4728) changes
the build IDs of the Go binaries that rules_go links. 0.62.0 linked them
with `-buildid=redacted`. 0.65.0 links with a placeholder, then
overwrites it with a SHA-256 of the linked binary:
  - ELF: the Go build ID, and the GNU build ID if the binary has one.
- Mach-O: the Go build ID and `LC_UUID`. If the binary is code-signed
(Go's linker signs darwin/arm64 binaries), rules_go's builder then
re-signs it ad hoc in Go, without Apple's `codesign`.

For us this affects Gazelle, the `go` tool runner behind `//:gobin`, and
`goyacc`, which the Gazelle build runs. I checked the first two on Linux
and cross-compiled for macOS (see Verification).

## Verification (dev container)

- `bazel mod graph`, `bazel mod explain
rules_go`/`gazelle`/`package_metadata` and `bazel mod
show_extension`/`show_repo` give the resolution described above,
compared with the same commands on master.
- `bazel build //... --nobuild`: all 3387 targets analyze.
- Linter-job parity: `shfmt-check`, `ruff-check`, `buf-check`,
`DFINITY-capitalization-check`, `do-not-merge-check`,
`buildifier-check`, `gazelle-check` and `buf-breaking-check` pass. After
them, `buildifier-fix`, `shfmt-fix`, `ruff-fix` and `bazel run
//:gazelle` leave the tree unchanged.
- `//:gazelle`, `//:gazelle-update-repos` and `//:gobin` build, with
Gazelle and the Go standard library rebuilt with Go 1.26.7.
- With no Go code to test, I exercised rules_go's rules and cgo through
the "Hello World" workflow in `bazel/README.md`. I used a temporary
package that isn't committed: a `main.go` with a C function and
`os/user`, plus a `main_test.go`.
- `bazel run //:gazelle` generated a `go_library` (`cgo = True`), a
`go_binary` and a `go_test`.
- The binary printed `hello world from go1.26.7: 1+2=3`, and the test
passed.
- Its build compiled the standard library with `CGO_ENABLED=1` and the
hermetic clang 22.1.8 as `CC`.
- After dfinity#12149 (gazelle 0.54.0) landed, I merged master into this
branch. Its gazelle line sits next to this PR's rules_go line; the
resolution keeps both. Against master, `bazel mod graph` changes only
`rules_go` (0.62.0 → 0.65.0) with no new warnings, `bazel build //...
--nobuild` analyzes all 3389 targets, and `bazel run //:buildifier`
changes nothing.
- Before that, I repeated this with gazelle temporarily bumped to
0.54.0, as in dfinity#12149. It resolves to gazelle 0.54.0 and rules_go 0.65.0
without new warnings, Gazelle builds, `gazelle-check` leaves the tree
clean, and the temporary package builds, runs and passes its test.
- Release artifacts: I didn't run the byte-identity rebuild. I ran
`bazel cquery 'deps(...)'` over the seven release targets: the IC-OS
bundles that `ci/container/build-ic.sh --icos` builds,
`//publish/binaries:bundle` and `//publish/canisters:bundle`. None of
the 110,935 configured targets it lists references rules_go, gazelle or
a Go SDK or toolchain repo. No other module's resolved version changes
either, so this upgrade can't change what we ship.
- Build IDs
([dfinity#4728](bazel-contrib/rules_go#4728)), which I
read from the binaries with a small Python script:
- Linux: the Go build IDs of Gazelle and the `go` tool runner are now
content hashes in `go build`'s format (four 20-character chunks), not
`redacted`. The runner's GNU build ID matches its Go build ID. Gazelle's
binary has no GNU build ID note, so only its Go build ID is rewritten.
- macOS, cross-compiled on Linux: I built `@gazelle//cmd/gazelle` and
`@rules_go//go/tools/go_bin_runner` with
`--platforms=@rules_go//go/toolchain:darwin_arm64`, and again with
`darwin_amd64`. These platforms turn cgo off, so Go's internal linker
links the binaries. In all four binaries, the Go build ID and `LC_UUID`
come from the same content hash. The two arm64 binaries have a valid ad
hoc signature: every CodeDirectory page hash (2,861 and 945 of them)
matches the file. The amd64 binaries have no signature, because Go's
linker signs only darwin/arm64 binaries.
- Not verified on a Mac, either locally or in CI. CI's `Bazel Test
arm64-darwin` job builds three `//publish/binaries` targets
(`pocket-ic.gz` also for x86_64), `//rs/...` and `//packages/...`. Of
those, it tests the targets tagged `test_all_platforms` or
`test_all_platforms_slow`.
- `bazel query 'deps(...)'` over these targets follows every `select()`
branch. It lists 79,392 labels, and none comes from rules_go, gazelle, a
Go SDK or a Go module repository.
- Across the whole workspace, a `bazel query` for main-repository
targets that depend on such a label finds only the targets named at the
top and their two `-runner` targets.
- On a Mac, those targets now build with Go 1.26.7. On Apple silicon,
the Go binaries involved (Gazelle, the `go` tool runner and `goyacc`)
are re-signed after linking, as described above. The cross-compiled
binaries don't show that they build and run on a Mac.
- Before merging, could someone on a Mac run `bazel run //:gazelle` and
`bazel run //:gobin -- version` on this branch? The second should print
`go1.26.7`.
- On Linux, CI covers the rest. Because this PR changes `MODULE.bazel`,
CI builds and tests all of `//...`, not just the affected targets (PR
runs still skip `long_test`s). The Linter job also runs `gazelle-check`.

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

Co-authored-by: Claude Opus 5.5 <[email protected]>
AleDema pushed a commit to AleDema/ic that referenced this pull request Nov 18, 2026
Upgrades `rules_buf` from 0.5.2 to
[0.6.1](https://github.com/bufbuild/rules_buf/releases/tag/v0.6.1), its
latest release. 0.6.0 never reached the BCR, and 0.6.1 adds only a test
fix on top of it.

This PR was stacked on dfinity#12149, which has landed. dfinity#12149 upgraded gazelle
from 0.51.3 to 0.54.0, which rules_buf 0.6.1 requires
([bufbuild/rules_buf#170](bufbuild/rules_buf#170)),
and moved the gazelle targets out of the root package, so that loading
it doesn't fetch the Go SDK. This PR now targets master, with master
merged in (no conflicts).

We use rules_buf directly only for the buf CLI it downloads. The `buf`
extension at the top of `MODULE.bazel` creates `@rules_buf_toolchains`,
and `//pre-commit:buf-check`, `//pre-commit:buf-breaking-check` and
`//pre-commit:buf-fix` (aliased as `//:protobuf-format`) run its `:buf`
binary. Nothing in the repo loads rules_buf's `buf_lint_test`,
`buf_breaking_test` or `buf_format` rules, and nothing uses its Gazelle
extension. Indirectly, rules_buf's `go.mod` also takes part in gazelle's
`go_deps` version selection. So this PR also changes some of the Go
modules that the `//:gazelle` binary is built from (see "Upstream
changes that touch our setup"). Neither rules_buf nor gazelle is in the
build graph of the release artifacts.

## Changes

- **`MODULE.bazel`**: `rules_buf` 0.5.2 → 0.6.1. On top of dfinity#12149, this
PR also changes the `//:gazelle` binary: it links a newer buildtools
(see below). The gazelle checks under Verification ran with this PR's
binary.
- **`go.mod`, `go.sum`**: `github.com/stretchr/testify` v1.8.4 →
v1.12.1, and with it the indirect `github.com/stretchr/objx` v0.5.0 →
v0.5.3. rules_buf 0.6.1's own `go.mod` requires testify v1.12.1.
Gazelle's `go_deps` extension merges the `go.mod` files of all Bazel
modules, so it resolves testify to v1.12.1 for us too. We run with
`--lockfile_mode=off`, so every new Bazel server printed:
  ```
The following Go modules were required by the root module at the given
versions, but were implicitly updated to higher versions due to
transitive dependencies:
    github.com/stretchr/testify: v1.8.4 -> v1.12.1
  ```
I ran the command that the warning suggests: `bazel run @rules_go//go --
get github.com/stretchr/[email protected]`. The repo has no Go code, so
nothing uses testify and this change only removes the warning. The new
testify lines in `go.sum` match rules_buf 0.6.1's `go.sum`. The
`@rules_go//go` wrapper also runs `bazel mod tidy`, which rewrites the
`rules_qemu` `use_repo` that already warns on master. I reverted that
change because it's unrelated.

## Upstream changes that touch our setup

- **The buf CLI moves from v1.47.2 to v1.75.0**
([bufbuild/rules_buf#166](bufbuild/rules_buf#166)).
We don't pin a version with `buf.toolchains(version = ...)`, so the
pre-commit checks now run buf v1.75.0. Some changes in buf's
[changelog](https://github.com/bufbuild/buf/blob/v1.75.0/CHANGELOG.md)
could change our results: a new compiler for `buf build` (v1.68.0), a
new formatter (v1.71.0) and further `buf format` fixes (v1.59.0,
v1.73.0). On our protos the results don't change (see Verification). buf
v1.75.0 still accepts our `version: v1beta1` `buf.yaml` without warnings
and sees the same 64 files. It also configures the same breaking rules.
The configured lint rules differ only by `IMPORT_NO_WEAK`. buf
deprecated that rule and made it a no-op when protobuf-go dropped weak
imports
([bufbuild/buf#3653](bufbuild/buf#3653)), and
none of our protos uses `import weak`.
- **rules_buf's `go.mod` also changes Go modules in the `//:gazelle`
binary**
([bufbuild/rules_buf#170](bufbuild/rules_buf#170)).
rules_buf calls `go_deps.from_file(go_mod = "//:go.mod")` as a regular
dependency, not a dev dependency. For Go modules that aren't also Bazel
modules, `go_deps` picks the highest version that any Bazel module's
`go.mod` requires. Compared with the gazelle bump alone (dfinity#12149, which
resolves the same Go module versions as master), this PR changes:
- `github.com/bazelbuild/buildtools` v0.0.0-20250930140053-2eb4fccefb52
(gazelle's own pin) → v0.0.0-20260904073137-eaa4d125b423 (rules_buf's
pin).
- `github.com/stretchr/testify` v1.8.4 → v1.12.1 and
`github.com/stretchr/objx` v0.5.0 → v0.5.3 (see `go.mod` above).
- New: `go.yaml.in/yaml/v3` v3.0.5, which testify v1.12.1 requires, and
`github.com/google/safeopen` v0.0.0-20260327150837-43626d6f4685, which
the new buildtools requires.

`//:gazelle` runs `@gazelle//cmd/gazelle`, and
`//pre-commit:gazelle-check` is an alias for it. That binary links
buildtools' `build`, `labels` and `tables` packages. Gazelle runs every
existing BUILD file it visits through `build.Format`, rewrites included,
and writes the file back if the output differs. So this PR changes the
tool behind the Linter's `gazelle-check` and the Autofix job's `bazel
run :gazelle`. Apart from code comments, the [53 buildtools
commits](bazel-contrib/buildtools@2eb4fcc...eaa4d12)
change those packages as follows; `labels` doesn't change:
- Add Starlark type-annotation syntax
([bazel-contrib/buildtools#1403](bazel-contrib/buildtools#1403),
[bazel-contrib/buildtools#1488](bazel-contrib/buildtools#1488),
[bazel-contrib/buildtools#1509](bazel-contrib/buildtools#1509)).
- Make formatting idempotent for compact block statements followed by
comments
([bazel-contrib/buildtools#1481](bazel-contrib/buildtools#1481)).
- Sort `visibility()` arguments in `.bzl` files
([bazel-contrib/buildtools#1452](bazel-contrib/buildtools#1452))
and classify more file names, including the new REPO.bazel and
VENDOR.bazel types
([bazel-contrib/buildtools#1433](bazel-contrib/buildtools#1433),
[bazel-contrib/buildtools#1485](bazel-contrib/buildtools#1485)).
Neither matters for `//:gazelle`, which parses BUILD files with
`ParseBuild` and formats only BUILD files.
- Add a helper for buildozer's `comment` command
([bazel-contrib/buildtools#1434](bazel-contrib/buildtools#1434)),
a lint table
([bazel-contrib/buildtools#1318](bazel-contrib/buildtools#1318))
and parser/printer speedups
([bazel-contrib/buildtools#1473](bazel-contrib/buildtools#1473),
[bazel-contrib/buildtools#1474](bazel-contrib/buildtools#1474),
[bazel-contrib/buildtools#1475](bazel-contrib/buildtools#1475)).

With this PR's binary, `bazel run //:gazelle` visits all 637 BUILD files
and changes none of them, both locally and in this PR's Autofix job.
`buildifier-check` and `buildifier-fix` run the prebuilt buildifier from
`buildifier_prebuilt`, which this PR doesn't change.

Nothing we build uses the two new repositories, and Bazel fetches a
repository only when a build needs it. rules_buf's `MODULE.bazel` notes
that safeopen's BUILD files reference repositories that `go_deps`
doesn't create. Its fix, a `gazelle_override`, is declared with
`dev_dependency = True`, so it doesn't apply here. That would only
matter if something here built safeopen.
- **New minimum versions**:
- 0.5.4: rules_go 0.42.0 → 0.59.0 (we're on 0.62.0) and gazelle 0.34.0 →
0.40.0
([bufbuild/rules_buf#134](bufbuild/rules_buf#134)).
- 0.6.0: gazelle 0.54.0 (dfinity#12149), platforms 1.1.0 and rules_proto 7.1.0
(our graph already resolves both).

Across the whole Bazel module graph, only `rules_buf` changes version
compared with master.
- **0.5.4's other changes**: 0.5.4 is a re-release of 0.5.3, which never
reached the BCR.
[bufbuild/rules_buf#127](bufbuild/rules_buf#127)
adds `gazelle:resolve` support to the Gazelle extension, which we don't
use.
[bufbuild/rules_buf#129](bufbuild/rules_buf#129)
makes the toolchain repository rule return `repo_metadata(reproducible =
True)` when it has a sha256. We don't set `buf.toolchains(...)`, so the
extension passes the sha256 of the default buf release.
`@rules_buf_toolchains` is therefore now marked reproducible, and Bazel
can keep it in its repository contents cache. That doesn't change which
buf binary it provides.
- **Changes we don't use**: `buf_lint_test` and `buf_breaking_test` now
load `ProtoInfo` and the proto toolchain from protobuf instead of
rules_proto
([bufbuild/rules_buf#167](bufbuild/rules_buf#167)).
The Gazelle extension also changed
([bufbuild/rules_buf#148](bufbuild/rules_buf#148),
[bufbuild/rules_buf#171](bufbuild/rules_buf#171)).

## Verification

In the dev container:

- **Module graph**: `bazel mod graph` resolves `[email protected]` and
`[email protected]`, and no other Bazel module version changes from the
base commit. Before the `go.mod` change, the `go_deps` warning above was
the only new warning. Now only the existing `rules_qemu` `use_repo`
warning remains.
- **`go_deps` module set**: I ran `bazel mod show_extension
@gazelle//:extensions.bzl%go_deps`, and `bazel mod show_repo` on each
repository it lists, in three states: the base commit, the base commit
plus only the gazelle bump (dfinity#12149's change), and this PR.
- The base commit and the gazelle bump resolve the same Go module
versions.
  - This PR changes exactly the five Go modules listed above.
- `bazel query 'somepath(//:gazelle,
@@gazelle++go_deps+com_github_bazelbuild_buildtools//build)'` goes
through `@gazelle//cmd/gazelle`.
- `deps(//:gazelle + //:gazelle-update-repos)` contains no target from
safeopen or `go.yaml.in/yaml/v3`. No Bazel file in the repo references a
`go_deps` repository directly.
- `deps(//pre-commit:buildifier-check + //pre-commit:buildifier-fix)`
contains no `go_deps` target.
- **Analysis**: `bazel build //... --nobuild` analyzes all 3387 targets.
After stacking this branch on dfinity#12149 (a merge, no other change),
`//:gazelle` and `//bazel/gazelle:all` build and `bazel build //...
--nobuild` analyzes all 3389 targets (dfinity#12149 adds two root aliases).
After merging master, `bazel build //... --nobuild` again analyzes all
3389 targets, and `bazel run //:buildifier` changes nothing.
- **CI Linter checks**:
- `shfmt-check`, `ruff-check`, `buf-check`,
`DFINITY-capitalization-check`, `do-not-merge-check`,
`buildifier-check`, `gazelle-check` and `buf-breaking-check` all pass.
- The autofixes (`buildifier-fix`, `shfmt-fix`, `ruff-fix`,
`//:gazelle`) and `bazel run //:protobuf-format` leave the tree
unchanged.
- A second, separate run of `bazel run //pre-commit:gazelle-check` and
`bazel run //:gazelle` with this PR's gazelle binary: both exit 0 and
`git status` stays clean.
- `//:gazelle` and `//:gazelle-update-repos` build with gazelle 0.54.0.
I didn't run `//:gazelle-update-repos`.
- **buf v1.47.2 vs v1.75.0**: I ran the commands of `buf-check` (`buf
format --exit-code --diff .` and `buf lint .`) and of
`buf-breaking-check` (`buf build`, `buf build ".git#ref=HEAD"` and `buf
breaking`) with both versions. I ran them on the unmodified tree and on
three deliberately broken variants of
`rs/protobuf/def/determinism_test/v1/determinism_test.proto`. Both
versions gave identical results:
  - Unmodified tree: all checks pass.
- Extra spaces in a field declaration: `buf format` fails with the same
diff.
- An added `message bad_message_name {}`: `buf lint` reports the same
PascalCase violation.
- `float v_float = 1;` changed to `string v_float = 1;`: `buf breaking`
reports the same `changed type from "float" to "string"`.

`bazel run //pre-commit:buf-check` and `bazel run
//pre-commit:buf-breaking-check` also fail on these variants.
- **Release artifacts**: I ran `bazel cquery 'deps(...)'` over the IC-OS
bundles that `ci/container/build-ic.sh --icos` builds plus
`//publish/binaries:bundle` and `//publish/canisters:bundle`. The result
has no target from rules_buf, `@rules_buf_toolchains`, gazelle, its
`go_deps` repositories or rules_go, so I didn't run a byte-identity
comparison.
- **Tests**: no tests in the repo use rules_buf or gazelle. CI covers
the full build and test suite.

🤖 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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants