Skip to content

ci: reuse Bazel CI startup for target-discovery queries#19232

Merged
bolinfest merged 1 commit intomainfrom
pr19232
Apr 24, 2026
Merged

ci: reuse Bazel CI startup for target-discovery queries#19232
bolinfest merged 1 commit intomainfrom
pr19232

Conversation

@bolinfest
Copy link
Copy Markdown
Collaborator

@bolinfest bolinfest commented Apr 23, 2026

Why

A rerun of the Windows Bazel clippy job after #19161 had exactly the cache behavior we wanted in BuildBuddy: zero action-cache misses. Even so, the GitHub job still took a little over five minutes.

The problem was that the job was paying for two separate Bazel startup paths:

  1. a bazel query to discover extra lint targets
  2. the real bazel build --config=clippy ... invocation

On Windows, that query was bypassing the CI Bazel wrapper, so it did not reuse the same --output_user_root, CI config, or remote-cache setup as the real build. In practice that meant the rerun could still cold-start a separate Bazel server before the actual clippy build even began.

What

  • add .github/scripts/run-bazel-query-ci.sh to run CI-side Bazel queries with the same startup and cache-related flags as the main Bazel command
  • switch scripts/list-bazel-clippy-targets.sh to use that helper for manual rust_test target discovery
  • switch tools/argument-comment-lint/list-bazel-targets.sh to use the same helper
  • simplify .github/scripts/run-argument-comment-lint-bazel.sh so its Windows-only query path also goes through the shared helper

This keeps the target-discovery queries aligned with the later build/test invocation instead of treating them as a separate cold Bazel session.

Verification

  • bash -n .github/scripts/run-bazel-query-ci.sh
  • bash -n scripts/list-bazel-clippy-targets.sh
  • bash -n tools/argument-comment-lint/list-bazel-targets.sh
  • bash -n .github/scripts/run-argument-comment-lint-bazel.sh
  • mocked a Windows invocation of run-bazel-query-ci.sh and verified it forwards --output_user_root, --config=ci-windows, the BuildBuddy auth header, and the repository cache flags

Docs

No documentation updates are needed.

@bolinfest bolinfest changed the title ci: reuse Bazel CI startup for query helpers ci: reuse Bazel CI startup for target-discovery queries Apr 23, 2026
Copy link
Copy Markdown
Contributor

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d9c9743233

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +39 to +42
./.github/scripts/run-bazel-query-ci.sh \
--keep_going \
--output=label \
"$query" >"$query_stdout" 2>"$query_stderr"; then
cat "$query_stderr" >&2
rm -f "$query_stdout" "$query_stderr"
exit 1
fi

cat "$query_stdout"
rm -f "$query_stdout" "$query_stderr"
-- "$query"
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.

P1 Badge Fail when Bazel target query exits non-zero

read_query_labels now streams run-bazel-query-ci.sh output directly, but this function is consumed via process substitution (done < <(read_query_labels ...)), where Bash set -e does not fail the parent script when the producer exits non-zero. With --keep_going, bazel query can emit partial labels before failing; those labels are then used as final_build_targets, so the Windows lint job can continue with an incomplete target set instead of failing closed. The previous implementation buffered stdout and only emitted labels on success, which avoided this silent partial-target behavior.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator

@etraut-openai etraut-openai left a comment

Choose a reason for hiding this comment

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

Nice find! I don't have experience with bazel, but this looks good to me.

@bolinfest bolinfest merged commit b683667 into main Apr 24, 2026
39 checks passed
@bolinfest bolinfest deleted the pr19232 branch April 24, 2026 06:26
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 24, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants