fix(skills): require approved workflows before declaring CI green - #1707
Conversation
The gate checker and triage scripts treated 'all present checks green' as passing, even when only 2 of ~9 checks existed. Fork PRs from first-time contributors need a maintainer to click 'Approve and run' before pull_request workflows execute — until then only pull_request_target checks (check-pr-limit) and external bots (CodeRabbit) appear. Changes: - check-gates.ts: add REQUIRED_CHECK_NAMES (checks, commit-lint, dco-check) validation; add StatusCheck type to handle both CheckRun and StatusContext shapes from GitHub's statusCheckRollup API - triage.ts: add same required-check validation so triage does not score unapproved-workflow PRs as review-ready - MERGE-GATE.md: add 'Missing required checks' guidance as first bullet in Step 2 Also fixes a StatusContext handling bug where CodeRabbit (which reports as a StatusContext with a state field, not status/conclusion) was always treated as 'pending' even when state was SUCCESS.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughEnforces presence of required CI checks ( Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
.agents/skills/nemoclaw-maintainer-day/scripts/triage.ts (2)
54-58: Interface doesn't reflect StatusContext fields.
PrData.statusCheckRolluponly declares CheckRun fields (name,status,conclusion), but the code at lines 221-224 accessescontextvia a cast. Consider aligning with theStatusCheckinterface fromcheck-gates.tsto accurately represent both shapes.♻️ Suggested type alignment
statusCheckRollup: Array<{ + __typename?: string; name: string; + context?: string; // StatusContext field status: string; conclusion: string; + state?: string; // StatusContext field }>;🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.agents/skills/nemoclaw-maintainer-day/scripts/triage.ts around lines 54 - 58, PrData.statusCheckRollup is typed only with CheckRun-like fields (name, status, conclusion) but the code reads a context property after casting; update the type to match the full StatusCheck shape from check-gates.ts so both CheckRun and StatusContext forms are represented. Replace the inline anonymous type for statusCheckRollup with a union or the imported StatusCheck interface (or mirror its fields) so references to PrData.statusCheckRollup and code that accesses .context (and any usage in functions that read status/conclusion) no longer require unsafe casts.
220-229: Consider extractingREQUIRED_CHECKStoshared.tsto avoid duplication.This duplicates
REQUIRED_CHECK_NAMESfromcheck-gates.ts. If the required checks change (e.g., adding a new workflow), both files must be updated in sync, risking drift.♻️ Suggested refactor
Export from
shared.ts:export const REQUIRED_CHECK_NAMES: string[] = [ "checks", // pr.yaml — lint, typecheck, test "commit-lint", // commit-lint.yaml "dco-check", // dco-check.yaml ];Then import in both
triage.tsandcheck-gates.ts:import { isRiskyFile, run, parseStringArg, + REQUIRED_CHECK_NAMES, // ... } from "./shared.ts";- const REQUIRED_CHECKS = ["checks", "commit-lint", "dco-check"]; + const REQUIRED_CHECKS = REQUIRED_CHECK_NAMES;🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.agents/skills/nemoclaw-maintainer-day/scripts/triage.ts around lines 220 - 229, Extract the duplicated constant into a shared export and replace the local copies: create/export a single array constant (e.g. export const REQUIRED_CHECK_NAMES: string[] = ["checks","commit-lint","dco-check"]) from shared.ts, then in triage.ts replace the local REQUIRED_CHECKS with an import of REQUIRED_CHECK_NAMES and use that in the existing presence check (the code that builds presentNames and checks REQUIRED_CHECKS.some(...)); do the same in check-gates.ts (remove its local REQUIRED_CHECK_NAMES and import the shared constant) so both modules reference the same symbol.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In @.agents/skills/nemoclaw-maintainer-day/scripts/triage.ts:
- Around line 54-58: PrData.statusCheckRollup is typed only with CheckRun-like
fields (name, status, conclusion) but the code reads a context property after
casting; update the type to match the full StatusCheck shape from check-gates.ts
so both CheckRun and StatusContext forms are represented. Replace the inline
anonymous type for statusCheckRollup with a union or the imported StatusCheck
interface (or mirror its fields) so references to PrData.statusCheckRollup and
code that accesses .context (and any usage in functions that read
status/conclusion) no longer require unsafe casts.
- Around line 220-229: Extract the duplicated constant into a shared export and
replace the local copies: create/export a single array constant (e.g. export
const REQUIRED_CHECK_NAMES: string[] = ["checks","commit-lint","dco-check"])
from shared.ts, then in triage.ts replace the local REQUIRED_CHECKS with an
import of REQUIRED_CHECK_NAMES and use that in the existing presence check (the
code that builds presentNames and checks REQUIRED_CHECKS.some(...)); do the same
in check-gates.ts (remove its local REQUIRED_CHECK_NAMES and import the shared
constant) so both modules reference the same symbol.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 3e43dee7-a1de-49c5-97d3-476de3c8438a
📒 Files selected for processing (3)
.agents/skills/nemoclaw-maintainer-day/MERGE-GATE.md.agents/skills/nemoclaw-maintainer-day/scripts/check-gates.ts.agents/skills/nemoclaw-maintainer-day/scripts/triage.ts
…ES into shared.ts Addresses CodeRabbit review nitpicks: moves the duplicated REQUIRED_CHECK_NAMES constant and StatusCheck interface into shared.ts so both check-gates.ts and triage.ts import from a single source. Also replaces unsafe `as Record<string, string>` casts in triage.ts with proper StatusCheck field access. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…IDIA#1707) ## Summary The gate checker and triage scripts treated "all present checks green" as passing, even when only 2 of ~9 checks existed. This caused premature approvals on fork PRs where workflows hadn't been triggered yet. ### Root cause Fork PRs from first-time contributors need a maintainer to click "Approve and run" before `pull_request` workflows execute. Until then, only `pull_request_target` checks (`check-pr-limit`) and external bots (`CodeRabbit`) appear in `statusCheckRollup`. The scripts saw 2/2 green and reported CI as passing. A secondary bug: GitHub's `statusCheckRollup` returns two shapes — `CheckRun` (`name`/`status`/`conclusion`) and `StatusContext` (`context`/`state`). The scripts only read CheckRun fields, so CodeRabbit (a StatusContext) was always treated as "pending" even when `state` was `SUCCESS`. ### Changes - **`check-gates.ts`**: Add `REQUIRED_CHECK_NAMES` (`checks`, `commit-lint`, `dco-check`) validation. Add `StatusCheck` union type to correctly handle both `CheckRun` and `StatusContext` shapes. CI gate now fails with `"required check(s) not found — workflows may need approval"` when expected checks are absent. - **`triage.ts`**: Add same required-check validation so triage does not score unapproved-workflow PRs as `review-ready`. - **`MERGE-GATE.md`**: Add "Missing required checks" as first bullet in Step 2 interpretation guidance. ### Before / After | PR scenario | Before | After | |---|---|---| | Fork PR, workflows not approved (2 checks) | "All 2 checks green" ✅ | "3 required check(s) not found — workflows may need approval" ❌ | | Fork PR, workflows running, dco-check failing | "1 pending" (CodeRabbit misread) | "3 failing check(s): dco-check: FAILURE, ..." ❌ | | Internal PR, all 12 checks green | "1 pending" (CodeRabbit misread) | "All 12 checks green" ✅ | ### Test plan - [x] Verified against PR NVIDIA#1660 (fork, workflows not approved) — correctly reports missing checks - [x] Verified against PR NVIDIA#1663 (fork, workflows approved, dco-check failing) — correctly reports failures - [x] Verified against PR NVIDIA#1683 (internal, all green) — correctly reports all 12 green - [x] Triage script correctly classifies NVIDIA#1660 as `salvage-now` with `failing-checks` reason instead of `review-ready` Signed-off-by: Carlos Villela <cvillela@nvidia.com> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Chores** * Enhanced merge gate to require specific CI checks be present and completed before a PR can be approved; missing required checks will block approval until workflows finish and validation is re-run. * Improved CI evaluation to better distinguish pending vs failed states across different check types. * PRs missing required check contexts are now classified as not-green. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…IDIA#1707) ## Summary The gate checker and triage scripts treated "all present checks green" as passing, even when only 2 of ~9 checks existed. This caused premature approvals on fork PRs where workflows hadn't been triggered yet. ### Root cause Fork PRs from first-time contributors need a maintainer to click "Approve and run" before `pull_request` workflows execute. Until then, only `pull_request_target` checks (`check-pr-limit`) and external bots (`CodeRabbit`) appear in `statusCheckRollup`. The scripts saw 2/2 green and reported CI as passing. A secondary bug: GitHub's `statusCheckRollup` returns two shapes — `CheckRun` (`name`/`status`/`conclusion`) and `StatusContext` (`context`/`state`). The scripts only read CheckRun fields, so CodeRabbit (a StatusContext) was always treated as "pending" even when `state` was `SUCCESS`. ### Changes - **`check-gates.ts`**: Add `REQUIRED_CHECK_NAMES` (`checks`, `commit-lint`, `dco-check`) validation. Add `StatusCheck` union type to correctly handle both `CheckRun` and `StatusContext` shapes. CI gate now fails with `"required check(s) not found — workflows may need approval"` when expected checks are absent. - **`triage.ts`**: Add same required-check validation so triage does not score unapproved-workflow PRs as `review-ready`. - **`MERGE-GATE.md`**: Add "Missing required checks" as first bullet in Step 2 interpretation guidance. ### Before / After | PR scenario | Before | After | |---|---|---| | Fork PR, workflows not approved (2 checks) | "All 2 checks green" ✅ | "3 required check(s) not found — workflows may need approval" ❌ | | Fork PR, workflows running, dco-check failing | "1 pending" (CodeRabbit misread) | "3 failing check(s): dco-check: FAILURE, ..." ❌ | | Internal PR, all 12 checks green | "1 pending" (CodeRabbit misread) | "All 12 checks green" ✅ | ### Test plan - [x] Verified against PR NVIDIA#1660 (fork, workflows not approved) — correctly reports missing checks - [x] Verified against PR NVIDIA#1663 (fork, workflows approved, dco-check failing) — correctly reports failures - [x] Verified against PR NVIDIA#1683 (internal, all green) — correctly reports all 12 green - [x] Triage script correctly classifies NVIDIA#1660 as `salvage-now` with `failing-checks` reason instead of `review-ready` Signed-off-by: Carlos Villela <cvillela@nvidia.com> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Chores** * Enhanced merge gate to require specific CI checks be present and completed before a PR can be approved; missing required checks will block approval until workflows finish and validation is re-run. * Improved CI evaluation to better distinguish pending vs failed states across different check types. * PRs missing required check contexts are now classified as not-green. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Summary
The gate checker and triage scripts treated "all present checks green" as passing, even when only 2 of ~9 checks existed. This caused premature approvals on fork PRs where workflows hadn't been triggered yet.
Root cause
Fork PRs from first-time contributors need a maintainer to click "Approve and run" before
pull_requestworkflows execute. Until then, onlypull_request_targetchecks (check-pr-limit) and external bots (CodeRabbit) appear instatusCheckRollup. The scripts saw 2/2 green and reported CI as passing.A secondary bug: GitHub's
statusCheckRollupreturns two shapes —CheckRun(name/status/conclusion) andStatusContext(context/state). The scripts only read CheckRun fields, so CodeRabbit (a StatusContext) was always treated as "pending" even whenstatewasSUCCESS.Changes
check-gates.ts: AddREQUIRED_CHECK_NAMES(checks,commit-lint,dco-check) validation. AddStatusCheckunion type to correctly handle bothCheckRunandStatusContextshapes. CI gate now fails with"required check(s) not found — workflows may need approval"when expected checks are absent.triage.ts: Add same required-check validation so triage does not score unapproved-workflow PRs asreview-ready.MERGE-GATE.md: Add "Missing required checks" as first bullet in Step 2 interpretation guidance.Before / After
Test plan
salvage-nowwithfailing-checksreason instead ofreview-readySigned-off-by: Carlos Villela cvillela@nvidia.com
Summary by CodeRabbit