Skip to content

ci: share final gate checks across Core and REST - #4742

Merged
chet merged 1 commit into
NVIDIA:mainfrom
chet:gh-issue-4741
Aug 10, 2026
Merged

ci: share final gate checks across Core and REST#4742
chet merged 1 commit into
NVIDIA:mainfrom
chet:gh-issue-4741

Conversation

@chet

@chet chet commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

This is a follow-up to #4655, where we made Core verify that every top-level CI job is covered by core-ci-pass, but left REST on its own jq result check. Nothing catches a new REST job added without also updating rest-ci-pass, so the two required checks can drift even though they enforce the same rule.

So, this turns check_core_ci_gate.py into check_ci_gate.py, keeps the lane-specific gate names and exemptions in explicit policies, and runs the same inventory and result checks for both workflows.

  • Expected green-run effect: No speedup is expected; rest-ci-pass adds one small hosted checkout before it evaluates the job results.
  • What it really buys us: New REST jobs cannot quietly sit outside rest-ci-pass, and malformed result data now fails closed instead of passing through REST's separate jq check.

Core keeps its existing 52-job contract, while REST starts with all nine top-level jobs accounted for. success and skipped remain the only passing results; #4586 still owns deciding whether an individual skip was actually valid.

Related issues

This supports #4741

Type of Change

  • Add - New feature or capability
  • Change - Changes in existing functionality
  • Fix - Bug fixes
  • Remove - Removed features or deprecated functionality
  • Internal - Internal changes (refactoring, tests, docs, etc.)

Breaking Changes

  • This PR contains breaking changes

Testing

  • Unit tests added/updated
  • Integration tests added/updated
  • Manual testing performed
  • No testing required (docs, internal refactor, etc.)

Validated both live workflow inventories, Actionlint, cargo make format-nightly, cargo make clippy, and the cached full Carbide-lints gate.

Additional Notes

This deliberately preserves the current blanket acceptance of skipped. #4586 still owns classifier-aware skip validation, Actions API pagination, job-name mapping, cross-workflow correlation, and timing reports.

Closes #4741

@chet
chet requested a review from a team as a code owner August 8, 2026 01:28
@coderabbitai

coderabbitai Bot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Summary by CodeRabbit

  • New Features
    • Added support for validating multiple CI gate policies, including Core and REST workflows.
    • Added policy selection for inventory validation with clearer policy-specific diagnostics.
  • Bug Fixes
    • Improved handling of missing, malformed, or unreadable workflow results so they correctly fail validation.
    • Strengthened final-gate checks across Core and REST CI workflows.
  • Tests
    • Added coverage for policy selection, invalid policies, workflow access errors, and result validation.

Walkthrough

The CI gate checker now supports Core CI and REST CI policies. Both workflows use the shared checker for inventory and result validation. Tests cover policy selection, REST inventory rules, command errors, and result handling.

Changes

CI gate policy validation

Layer / File(s) Summary
Policy contracts and workflow parsing
.github/ci/check_ci_gate.py
GatePolicy defines gate jobs and exemptions for Core CI and REST CI. Workflow parsing and diagnostics use the selected gate job.
Policy-based inventory and command dispatch
.github/ci/check_ci_gate.py
Inventory validation applies the selected policy. The CLI requires --policy for inventory commands and accepts optional argument lists.
Policy and CLI test coverage
.github/ci/test_check_ci_gate.py
Tests cover REST inventories, policy mismatches, policy selection, unreadable workflows, and shared result validation.
Core and REST workflow integration
.github/workflows/ci.yaml, .github/workflows/rest-ci.yml
Core CI uses the shared checker with --policy core. REST CI validates its inventory and delegates result evaluation to the shared checker.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant REST CI workflow
  participant check_ci_gate.py
  participant GitHub Actions job results
  REST CI workflow->>check_ci_gate.py: inventory --policy rest
  check_ci_gate.py-->>REST CI workflow: inventory validation result
  REST CI workflow->>GitHub Actions job results: collect NEEDS_JSON
  REST CI workflow->>check_ci_gate.py: results with serialized job results
  check_ci_gate.py-->>REST CI workflow: result validation status
Loading

Possibly related issues

  • NVIDIA/infra-controller#4741 — The PR implements the shared policy-aware checker for Core CI and REST CI, replacing REST-specific validation.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
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.
Title check ✅ Passed The title clearly and concisely describes sharing final-gate checks across Core and REST workflows.
Description check ✅ Passed The description directly explains the shared checks, policy handling, workflow changes, testing, and intended effect.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@chet

chet commented Aug 8, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai full_review, thanks!

@coderabbitai

coderabbitai Bot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

@chet I will perform a complete review of the pull request.

🐇

✅ Action performed

Full review finished.

@github-actions

github-actions Bot commented Aug 8, 2026

Copy link
Copy Markdown

🔐 TruffleHog Secret Scan

No secrets or credentials found!

Your code has been scanned for 700+ types of secrets and credentials. All clear! 🎉

🔗 View scan details

🕐 Last updated: 2026-08-08 01:49:19 UTC | Commit: 71c3119

As it stood, Core checked its final-gate inventory in source, while REST still had a separate `jq` block and no guard when a top-level job was added without updating `rest-ci-pass`. That meant the two required checks could drift even though they enforce the same current rule.

So, this turns `check_core_ci_gate.py` into `check_ci_gate.py`, keeps the lane-specific gate names and exemptions in explicit policies, and runs the same inventory and result checks for both workflows.

Primary callouts are:

- **Expected green-run effect:** No speedup is expected; `rest-ci-pass` adds one small hosted checkout before it evaluates the job results.
- **What it really buys us:** New REST jobs cannot quietly sit outside `rest-ci-pass`, and malformed result data now fails closed instead of passing through REST's separate `jq` check.
- Core keeps its existing 52-job contract, while REST starts with all nine top-level jobs accounted for.
- `success` and `skipped` remain the only passing results; NVIDIA#4586 still owns deciding whether an individual skip was actually valid.

Tests updated!

This supports NVIDIA#4741

Signed-off-by: Chet Nichols III <chetn@nvidia.com>

@nv-dmendoza nv-dmendoza 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.

LGTM

@chet
chet merged commit dc74f79 into NVIDIA:main Aug 10, 2026
122 checks passed
@chet
chet deleted the gh-issue-4741 branch August 10, 2026 16:54
chet added a commit that referenced this pull request Aug 11, 2026
## TLDR

This fixes how Core and REST tell TruffleHog which commits to scan. On a
PR's first CI run, GitHub has no previous commit, which caused REST to
scan the entire repository history. After a force-push, the next run can
have the opposite problem: `copy-pr-bot` replaces its internal PR
branch, but GitHub still identifies that branch's now-missing old commit
as the starting point. TruffleHog then scans zero bytes, and the
surrounding action still reports success -- so yes, we would fail open
-- and this was caught during the CICD work that we've been doing.

Both workflows now:
1. Ignore that [unreliable] previous commit for PR runs.
2. Look up the PR's current base.
3. Use the commit that started the workflow as the current head.
4. Calculate the real range from the fetched Git history before starting
TruffleHog.

If that range cannot be calculated, the workflow fails before the scan;
this keeps the first run from scanning the whole repository and prevents
this missing-commit case from going green after scanning nothing.

## Expected green-run effect

No reliable steady-state speedup. The first synthetic REST scan on this
PR processed 11,464 bytes instead of the roughly 446 MB full-history
scan we observed on #4742 -- about 39,000x less scan input. This is
still primarily a correctness fix; normal update scans should take about
the same time.

## What it really buys us

One latest green Core or REST secret check now proves that the
repository-side range was resolved from the current PR and passed to the
scanner. Rebases and force-pushes can no longer make that run depend on
a stale or missing synthetic-branch commit.

## Testing

Ran a bunch of commands to test it out:
- `bash -n .github/ci/resolve-pr-scan-range.sh
.github/ci/test-resolve-pr-scan-range.sh`
- `bash .github/ci/test-resolve-pr-scan-range.sh`
- `python3 -B .github/ci/test_check_ci_gate.py`
- Core and REST final-gate inventory checks
- CI token-permission checker fixtures, plus the Core and stale-workflow
permission checks
- Core and REST concurrency-policy checks
- `actionlint` for both edited workflows, ignoring only the repository's
known custom-runner labels
- `cargo make check-format-nightly`
- `cargo make clippy`
- cached Carbide-lints workflow (`--all-targets --all-features`)
- `git diff --check`

Acceptance exercised the initial synthetic push and two rewritten heads.
On the initial head, Core and REST both resolved `00ece37...b8acd55`,
scanned 6 chunks / 11,464 bytes, and reported no source errors. On the
first rewrite, the push event contained stale `before=b8acd55`, but both
workflows resolved `00ece37...eb5f72f` and scanned the same real range.
After the final simplification and rebase, the event contained stale
`before=eb5f72f`; both workflows instead resolved `7d9b87e...d79119f`,
scanned 6 chunks / 9,129 bytes, and passed. Final-head Core CI completed
52 jobs with zero failures, and REST's final gate also passed.

This supports #4786

Signed-off-by: Chet Nichols III <chetn@nvidia.com>
Sinck pushed a commit to Sinck/infra-controller that referenced this pull request Aug 11, 2026
## TLDR

This fixes how Core and REST tell TruffleHog which commits to scan. On a
PR's first CI run, GitHub has no previous commit, which caused REST to
scan the entire repository history. After a force-push, the next run can
have the opposite problem: `copy-pr-bot` replaces its internal PR
branch, but GitHub still identifies that branch's now-missing old commit
as the starting point. TruffleHog then scans zero bytes, and the
surrounding action still reports success -- so yes, we would fail open
-- and this was caught during the CICD work that we've been doing.

Both workflows now:
1. Ignore that [unreliable] previous commit for PR runs.
2. Look up the PR's current base.
3. Use the commit that started the workflow as the current head.
4. Calculate the real range from the fetched Git history before starting
TruffleHog.

If that range cannot be calculated, the workflow fails before the scan;
this keeps the first run from scanning the whole repository and prevents
this missing-commit case from going green after scanning nothing.

## Expected green-run effect

No reliable steady-state speedup. The first synthetic REST scan on this
PR processed 11,464 bytes instead of the roughly 446 MB full-history
scan we observed on NVIDIA#4742 -- about 39,000x less scan input. This is
still primarily a correctness fix; normal update scans should take about
the same time.

## What it really buys us

One latest green Core or REST secret check now proves that the
repository-side range was resolved from the current PR and passed to the
scanner. Rebases and force-pushes can no longer make that run depend on
a stale or missing synthetic-branch commit.

## Testing

Ran a bunch of commands to test it out:
- `bash -n .github/ci/resolve-pr-scan-range.sh
.github/ci/test-resolve-pr-scan-range.sh`
- `bash .github/ci/test-resolve-pr-scan-range.sh`
- `python3 -B .github/ci/test_check_ci_gate.py`
- Core and REST final-gate inventory checks
- CI token-permission checker fixtures, plus the Core and stale-workflow
permission checks
- Core and REST concurrency-policy checks
- `actionlint` for both edited workflows, ignoring only the repository's
known custom-runner labels
- `cargo make check-format-nightly`
- `cargo make clippy`
- cached Carbide-lints workflow (`--all-targets --all-features`)
- `git diff --check`

Acceptance exercised the initial synthetic push and two rewritten heads.
On the initial head, Core and REST both resolved `00ece37...b8acd55`,
scanned 6 chunks / 11,464 bytes, and reported no source errors. On the
first rewrite, the push event contained stale `before=b8acd55`, but both
workflows resolved `00ece37...eb5f72f` and scanned the same real range.
After the final simplification and rebase, the event contained stale
`before=eb5f72f`; both workflows instead resolved `7d9b87e...d79119f`,
scanned 6 chunks / 9,129 bytes, and passed. Final-head Core CI completed
52 jobs with zero failures, and REST's final gate also passed.

This supports NVIDIA#4786

Signed-off-by: Chet Nichols III <chetn@nvidia.com>
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.

Share the Current CI Gate Checker Between Core and REST

2 participants