Skip to content

ci(bazel): glob-gate root on main too (drop the every-merge force)#327

Open
balajinvda wants to merge 1 commit into
mainfrom
fix/root-glob-gated-only
Open

ci(bazel): glob-gate root on main too (drop the every-merge force)#327
balajinvda wants to merge 1 commit into
mainfrom
fix/root-glob-gated-only

Conversation

@balajinvda

@balajinvda balajinvda commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Why

#311 forced the root row on every push to main to keep the remote cache warm. That was a workaround for the wrong hypothesis. The real reason root was always cold was that it never uploaded: root's .bazelrc --config=remote pinned --remote_upload_local_results=false, so even when root ran on a root-change merge it warmed nothing. That is fixed (force upload=true on main + .bazelrc consistency).

With the upload fix in place and the cache rings not evicting, root only needs to run when a ROOT_GLOB file changes: a later root PR reads the closure warmed by the last root-touching merge. Forcing root on every merge just spun up the ~7k-target build for docs- and helm-only merges that warm nothing new.

What changed

  • Drop the is_main_push force in the detect job. Root is now purely glob-gated on merges, exactly as it already is on PRs — a docs- or helm-only change never triggers root.
  • Keep the main-push upload (CACHE_UPLOAD), so root still warms the cache whenever it does run.
  • Remove the now-unused REF env.

Testing

YAML parses; the detect run: block passes bash -n. A docs-only merge will no longer schedule the root row.

Issues

Relates to #283

References

Refines the warming approach from #311.

Dependencies

None

Summary by CodeRabbit

  • Bug Fixes
    • Improved Bazel build selection to run only when relevant root-level files change.
    • Prevented unnecessary root builds for main-branch merges that do not affect configured root paths.
    • Updated change detection to reliably determine affected build areas across pull requests and merges.

#311 forced the root row on every push to main to keep the cache warm. That was
a workaround for the wrong hypothesis: root was cold because it never uploaded
(its .bazelrc --config=remote pinned --remote_upload_local_results=false), not
because it ran too rarely. With the upload fix in place and the cache rings not
evicting, root only needs to run (and upload) when a ROOT_GLOB file actually
changes -- a later root PR reads the closure warmed by the last root-touching
merge. Forcing root on every merge just spun up a ~7k-target job for docs- and
helm-only merges that warm nothing new.

Make root purely glob-gated on merges as it already is on PRs; keep the
main-push upload (CACHE_UPLOAD) so warming still happens whenever root runs.

Co-authored-by: Balaji Ganesan <bganesan@nvidia.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@balajinvda
balajinvda requested a review from a team as a code owner July 21, 2026 21:42
@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The Bazel workflow’s matrix detection no longer passes github.ref as REF. Root subtree builds are now selected only when changed files match ROOT_GLOBS, including on main merges.

Changes

Bazel matrix detection

Layer / File(s) Summary
Glob-gated root matrix selection
.github/workflows/bazel.yml
The detect job removes the REF environment input and changes root subtree selection to require a matching ROOT_GLOBS entry instead of always selecting root on main pushes.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

  • NVIDIA/nvcf#280: Introduces and rewires ROOT_GLOBS and related root matrix selection logic.
  • NVIDIA/nvcf#311: Adjusts Bazel detect-job root selection based on ROOT_GLOBS.

Suggested reviewers: kristinapathak

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main CI change: glob-gating the Bazel root job on main and removing the always-run merge behavior.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/root-glob-gated-only

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/bazel.yml:
- Around line 152-162: Expand the root-gate matching around ROOT_GLOBS to
include WORKSPACE, WORKSPACE.bazel, go.work, go.work.bazel, and root-level *.bzl
changes, keeping behavior consistent with the full-build triggers in the
target-selection logic. Use a matcher that supports the literal root-level *.bzl
pattern, since the current fixed-prefix awk check cannot interpret it;
preferably reuse a canonical root-global matcher if one exists.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 5e83c395-8a76-49be-938b-fa5ca669add3

📥 Commits

Reviewing files that changed from the base of the PR and between d6c2206 and e77714b.

📒 Files selected for processing (1)
  • .github/workflows/bazel.yml

Comment on lines +152 to +162
# Root is glob-gated on PRs and merges alike: it runs only when a
# ROOT_GLOB file changed (a docs- or helm-only change never triggers
# it). When it does run on a main push it uploads (CACHE_UPLOAD),
# warming the cache; the rings do not evict, so a later root PR reads
# that warm closure.
for g in "${ROOT_GLOBS[@]}"; do
# Fixed-string, start-of-line prefix test via awk index()==1:
# avoids treating the dots in .bazelrc/MODULE.bazel as regex
# wildcards and avoids any shell glob expansion of the token.
if printf '%s\n' "$changed" | awk -v p="$g" 'index($0, p) == 1 { f = 1 } END { exit !f }'; then hit=true; break; fi
done

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Include all root-wide Bazel inputs in the root gate.

When run_all=false, this is the only path selecting the root row, but ROOT_GLOBS does not cover WORKSPACE, WORKSPACE.bazel, go.work, go.work.bazel, or root-level *.bzl changes. The later target-selection logic treats these as full-build triggers (Lines [333]-[339]), so such changes can select no matrix rows and pass verification without running Bazel. Expand the gate or share a canonical root-global matcher; note that the current fixed-prefix awk check cannot match a literal *.bzl pattern.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/bazel.yml around lines 152 - 162, Expand the root-gate
matching around ROOT_GLOBS to include WORKSPACE, WORKSPACE.bazel, go.work,
go.work.bazel, and root-level *.bzl changes, keeping behavior consistent with
the full-build triggers in the target-selection logic. Use a matcher that
supports the literal root-level *.bzl pattern, since the current fixed-prefix
awk check cannot interpret it; preferably reuse a canonical root-global matcher
if one exists.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant