Skip to content

refactor(IDX): move node-name to step summary - #2407

Merged
cgundy merged 4 commits into
masterfrom
move-node-name-to-step-summary
Nov 4, 2024
Merged

cgundy merged 4 commits into
masterfrom
move-node-name-to-step-summary

Conversation

@cgundy

@cgundy cgundy commented Nov 4, 2024 •

Copy link
Copy Markdown
Contributor

This PR moves the node name to the step summary as part of the bazel-test-all action instead of before-script. I then removed before-script completely as it's not needed.

@cgundy
cgundy marked this pull request as ready for review November 4, 2024 09:34
@cgundy
cgundy requested a review from a team as a code owner November 4, 2024 09:34
@github-actions github-actions Bot added the @idx label Nov 4, 2024

@basvandijk basvandijk left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Good idea!

@cgundy

cgundy commented Nov 4, 2024

Copy link
Copy Markdown
Contributor Author

@basvandijk I just realized we use before-script in other workflows too so I went through and removed those as well. Since the node name is now exported as part of the bazel-test-all action now I could remove it most places, but had to add it back to jobs that use bazel but don't call the bazel-test-all action. The bazel jobs are the ones where it's most helpful to have a node name for debugging so we don't necessarily need it everywhere but let me know if you think otherwise.

@cgundy
cgundy requested a review from basvandijk November 4, 2024 10:06
@cgundy
cgundy added this pull request to the merge queue Nov 4, 2024
Merged via the queue into master with commit 1a1c514 Nov 4, 2024
@cgundy
cgundy deleted the move-node-name-to-step-summary branch November 4, 2024 11:50
alin-at-dfinity pushed a commit that referenced this pull request Nov 7, 2024
This PR moves the node name to be part of the step summary instead of
`before-script`. I then removed `before-script` completely as it's not
needed.

---------

Co-authored-by: IDX GitHub Automation <IDX GitHub Automation>
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]>
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.

2 participants