Repository navigation
chore(bazel): upgrade rules_buf from 0.5.2 to 0.6.1 - #12151
Merged
Merged
Conversation
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]>
rules_buf 0.6.1 moves the buf CLI that //pre-commit:buf-check, //pre-commit:buf-breaking-check and //pre-commit:buf-fix run from v1.47.2 to v1.75.0. Both versions give the same format, lint and breaking results on our protos. rules_buf 0.6.1 requires gazelle 0.54.0, so declare gazelle 0.54.0 (the same one-line change as bas/gazelle-0.54.0). Its go.mod also requires github.com/stretchr/testify v1.12.1, which gazelle's go_deps extension then resolves for the root module too and warns about. go.mod and go.sum are updated with `bazel run @rules_go//go -- get github.com/stretchr/[email protected]` to match. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues block the buf tooling and dependency updates.
No open issues 🎉
What changed in this PR
Upgrades the Bazel-managed buf tooling used for protobuf formatting, linting, and breaking-change checks, and aligns dependency declarations with the new requirements.
Changes:
- Updates
rules_buffrom 0.5.2 to 0.6.1 and Gazelle from 0.51.3 to 0.54.0. - Updates Testify and its indirect Objx dependency to match transitive requirements and remove the Go dependency warning.
| File | Description |
|---|---|
MODULE.bazel |
Upgrades rules_buf and Gazelle. |
go.sum |
Adds checksums for the updated Testify and Objx versions. |
go.mod |
Aligns Testify and Objx versions with transitive requirements. |
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]>
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]>
#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]>
rzakrzyk
approved these changes
Nov 18, 2026
AleDema
pushed a commit
to AleDema/ic
that referenced
this pull request
Nov 18, 2026
Upgrades `gazelle` from 0.51.3 to [0.54.0](https://github.com/bazel-contrib/bazel-gazelle/releases/tag/v0.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](https://bcr.bazel.build/modules/gazelle/0.54.0/MODULE.bazel) 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. dfinity#12151 (rules_buf 0.6.1, which requires gazelle 0.54.0) is stacked on this PR. dfinity#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](bazel-contrib/bazel-gazelle#2386)). Its update command now drives the built-in (v1) language extensions through v2 compatibility wrappers ([dfinity#2423](bazel-contrib/bazel-gazelle#2423)), and the directory walk moved to the v2 packages ([dfinity#2330](bazel-contrib/bazel-gazelle#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** ([dfinity#2392](bazel-contrib/bazel-gazelle#2392)), and records `GOROOT` as a label ([dfinity#2374](bazel-contrib/bazel-gazelle#2374), [dfinity#2385](bazel-contrib/bazel-gazelle#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** ([dfinity#2407](bazel-contrib/bazel-gazelle#2407)). Their PURLs now include the `go.sum` checksum ([dfinity#2409](bazel-contrib/bazel-gazelle#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` ([dfinity#2366](bazel-contrib/bazel-gazelle#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](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.
Upgrades
rules_buffrom 0.5.2 to 0.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 #12149, which has landed. #12149 upgraded gazelle from 0.51.3 to 0.54.0, which rules_buf 0.6.1 requires (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
bufextension at the top ofMODULE.bazelcreates@rules_buf_toolchains, and//pre-commit:buf-check,//pre-commit:buf-breaking-checkand//pre-commit:buf-fix(aliased as//:protobuf-format) run its:bufbinary. Nothing in the repo loads rules_buf'sbuf_lint_test,buf_breaking_testorbuf_formatrules, and nothing uses its Gazelle extension. Indirectly, rules_buf'sgo.modalso takes part in gazelle'sgo_depsversion selection. So this PR also changes some of the Go modules that the//:gazellebinary 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_buf0.5.2 → 0.6.1. On top of chore(bazel): upgrade gazelle from 0.51.3 to 0.54.0 #12149, this PR also changes the//:gazellebinary: 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/testifyv1.8.4 → v1.12.1, and with it the indirectgithub.com/stretchr/objxv0.5.0 → v0.5.3. rules_buf 0.6.1's owngo.modrequires testify v1.12.1. Gazelle'sgo_depsextension merges thego.modfiles 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: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 ingo.summatch rules_buf 0.6.1'sgo.sum. The@rules_go//gowrapper also runsbazel mod tidy, which rewrites therules_qemuuse_repothat 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). 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 could change our results: a new compiler forbuf build(v1.68.0), a new formatter (v1.71.0) and furtherbuf formatfixes (v1.59.0, v1.73.0). On our protos the results don't change (see Verification). buf v1.75.0 still accepts ourversion: v1beta1buf.yamlwithout warnings and sees the same 64 files. It also configures the same breaking rules. The configured lint rules differ only byIMPORT_NO_WEAK. buf deprecated that rule and made it a no-op when protobuf-go dropped weak imports (bufbuild/buf#3653), and none of our protos usesimport weak.rules_buf's
go.modalso changes Go modules in the//:gazellebinary (bufbuild/rules_buf#170). rules_buf callsgo_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_depspicks the highest version that any Bazel module'sgo.modrequires. Compared with the gazelle bump alone (chore(bazel): upgrade gazelle from 0.51.3 to 0.54.0 #12149, which resolves the same Go module versions as master), this PR changes:github.com/bazelbuild/buildtoolsv0.0.0-20250930140053-2eb4fccefb52 (gazelle's own pin) → v0.0.0-20260904073137-eaa4d125b423 (rules_buf's pin).github.com/stretchr/testifyv1.8.4 → v1.12.1 andgithub.com/stretchr/objxv0.5.0 → v0.5.3 (seego.modabove).go.yaml.in/yaml/v3v3.0.5, which testify v1.12.1 requires, andgithub.com/google/safeopenv0.0.0-20260327150837-43626d6f4685, which the new buildtools requires.//:gazelleruns@gazelle//cmd/gazelle, and//pre-commit:gazelle-checkis an alias for it. That binary links buildtools'build,labelsandtablespackages. Gazelle runs every existing BUILD file it visits throughbuild.Format, rewrites included, and writes the file back if the output differs. So this PR changes the tool behind the Linter'sgazelle-checkand the Autofix job'sbazel run :gazelle. Apart from code comments, the 53 buildtools commits change those packages as follows;labelsdoesn't change:visibility()arguments in.bzlfiles (bazelbuild/buildtools#1452) and classify more file names, including the new REPO.bazel and VENDOR.bazel types (bazelbuild/buildtools#1433, bazelbuild/buildtools#1485). Neither matters for//:gazelle, which parses BUILD files withParseBuildand formats only BUILD files.commentcommand (bazelbuild/buildtools#1434), a lint table (bazelbuild/buildtools#1318) and parser/printer speedups (bazelbuild/buildtools#1473, bazelbuild/buildtools#1474, bazelbuild/buildtools#1475).With this PR's binary,
bazel run //:gazellevisits all 637 BUILD files and changes none of them, both locally and in this PR's Autofix job.buildifier-checkandbuildifier-fixrun the prebuilt buildifier frombuildifier_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.bazelnotes that safeopen's BUILD files reference repositories thatgo_depsdoesn't create. Its fix, agazelle_override, is declared withdev_dependency = True, so it doesn't apply here. That would only matter if something here built safeopen.New minimum versions:
Across the whole Bazel module graph, only
rules_bufchanges 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 adds
gazelle:resolvesupport to the Gazelle extension, which we don't use. bufbuild/rules_buf#129 makes the toolchain repository rule returnrepo_metadata(reproducible = True)when it has a sha256. We don't setbuf.toolchains(...), so the extension passes the sha256 of the default buf release.@rules_buf_toolchainsis 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_testandbuf_breaking_testnow loadProtoInfoand the proto toolchain from protobuf instead of rules_proto (bufbuild/rules_buf#167). The Gazelle extension also changed (bufbuild/rules_buf#148, bufbuild/rules_buf#171).Verification
In the dev container:
Module graph:
bazel mod graphresolves[email protected]and[email protected], and no other Bazel module version changes from the base commit. Before thego.modchange, thego_depswarning above was the only new warning. Now only the existingrules_qemuuse_repowarning remains.go_depsmodule set: I ranbazel mod show_extension @gazelle//:extensions.bzl%go_deps, andbazel mod show_repoon each repository it lists, in three states: the base commit, the base commit plus only the gazelle bump (chore(bazel): upgrade gazelle from 0.51.3 to 0.54.0 #12149's change), and this PR.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 orgo.yaml.in/yaml/v3. No Bazel file in the repo references ago_depsrepository directly.deps(//pre-commit:buildifier-check + //pre-commit:buildifier-fix)contains nogo_depstarget.Analysis:
bazel build //... --nobuildanalyzes all 3387 targets. After stacking this branch on chore(bazel): upgrade gazelle from 0.51.3 to 0.54.0 #12149 (a merge, no other change),//:gazelleand//bazel/gazelle:allbuild andbazel build //... --nobuildanalyzes all 3389 targets (chore(bazel): upgrade gazelle from 0.51.3 to 0.54.0 #12149 adds two root aliases). After merging master,bazel build //... --nobuildagain analyzes all 3389 targets, andbazel run //:buildifierchanges nothing.CI Linter checks:
shfmt-check,ruff-check,buf-check,DFINITY-capitalization-check,do-not-merge-check,buildifier-check,gazelle-checkandbuf-breaking-checkall pass.buildifier-fix,shfmt-fix,ruff-fix,//:gazelle) andbazel run //:protobuf-formatleave the tree unchanged.bazel run //pre-commit:gazelle-checkandbazel run //:gazellewith this PR's gazelle binary: both exit 0 andgit statusstays clean.//:gazelleand//:gazelle-update-reposbuild 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 .andbuf lint .) and ofbuf-breaking-check(buf build,buf build ".git#ref=HEAD"andbuf breaking) with both versions. I ran them on the unmodified tree and on three deliberately broken variants ofrs/protobuf/def/determinism_test/v1/determinism_test.proto. Both versions gave identical results:buf formatfails with the same diff.message bad_message_name {}:buf lintreports the same PascalCase violation.float v_float = 1;changed tostring v_float = 1;:buf breakingreports the samechanged type from "float" to "string".bazel run //pre-commit:buf-checkandbazel run //pre-commit:buf-breaking-checkalso fail on these variants.Release artifacts: I ran
bazel cquery 'deps(...)'over the IC-OS bundles thatci/container/build-ic.sh --icosbuilds plus//publish/binaries:bundleand//publish/canisters:bundle. The result has no target from rules_buf,@rules_buf_toolchains, gazelle, itsgo_depsrepositories 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