Skip to content

ci: replace Gate 3 with real CodeRabbit check, add Gate 5 aggregate - #30

Merged
NavpreetST merged 14 commits into
mainfrom
ci/coderabbit-gate
Jun 10, 2026
Merged

ci: replace Gate 3 with real CodeRabbit check, add Gate 5 aggregate#30
NavpreetST merged 14 commits into
mainfrom
ci/coderabbit-gate

Conversation

@NavpreetST

@NavpreetST NavpreetST commented Jun 10, 2026

Copy link
Copy Markdown
Owner

Changes

Gate 3 is no longer a no-op advisory — it now queries the GitHub API for CodeRabbit's review status:

  • If CodeRabbit has CHANGES_REQUESTEDblocks merge with core.setFailed
  • If CodeRabbit has APPROVED → logs success
  • Runs on if: always() so it executes regardless of other gate failures

Gate 5 — new aggregate job that depends on Gates 1–4 and only passes when all four succeed.

Verification

CI should run on this PR and all 5 gates (plus Vercel preview) must pass before merge.

Summary by CodeRabbit

  • Chores
    • CI now responds to pull request review events and expands job permissions.
    • Added a blocking automated review gate that enforces change-request failures and recognizes approvals.
    • Added a verification that requires either an approval or a successful prior review run before merging.
    • Consolidated a "merge-ready" step that runs after lint, tests, review verification, and drift checks succeed and emits a ready-for-merge message.

@vercel

vercel Bot commented Jun 10, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
axis-dash Ready Ready Preview, Comment Jun 10, 2026 1:09pm

@coderabbitai

coderabbitai Bot commented Jun 10, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The CI workflow adds a pull_request_review trigger and checks: read permission, replaces the advisory Gate 3 with a blocking coderabbit-check job that enforces CodeRabbit approval or a successful CodeRabbit check run, and adds a merge-ready aggregate job gated on preceding jobs.

Changes

CI Gate Enforcement and Merge Readiness

Layer / File(s) Summary
Workflow permissions update
.github/workflows/ci.yml
Adds pull_request_review trigger and checks: read permission to allow listing check runs for fallback verification.
CodeRabbit blocking review gate
.github/workflows/ci.yml
Replaces advisory Gate 3 with coderabbit-check that lists PR reviews, enforces coderabbitai approval for the head commit (fails on CHANGES_REQUESTED or non-APPROVED), and falls back to requiring a completed-success CodeRabbit check run when no matching review exists.
Merge readiness aggregate gate
.github/workflows/ci.yml
Adds merge-ready job depending on lint, tests, coderabbit-check, and drift-guard; runs only when all succeed and prints a ready-for-merge message.

Sequence Diagram(s)

sequenceDiagram
  participant coderabbit-check
  participant github_pulls_listReviews as github.rest.pulls.listReviews
  participant github_checks_listForRef as github.rest.checks.listForRef
  participant merge-ready
  coderabbit-check->>github_pulls_listReviews: list PR reviews (filter author coderabbitai, head SHA)
  github_pulls_listReviews-->>coderabbit-check: return reviews
  coderabbit-check->>coderabbit-check: evaluate latest CodeRabbit review state (APPROVED/CHANGES_REQUESTED/other)
  coderabbit-check->>github_checks_listForRef: if no matching review, list checks for head SHA and head ref
  github_checks_listForRef-->>coderabbit-check: return check runs (look for CodeRabbit completed: success)
  coderabbit-check->>merge-ready: pass/fail result determines merge-ready eligibility
  merge-ready->>merge-ready: runs only if lint, tests, coderabbit-check, drift-guard succeeded
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

  • NavpreetST/axis-dash#15: Overlaps in .github/workflows/ci.yml changes around CodeRabbit gating and merge-ready orchestration.

Poem

🐰 I hopped into the CI night,
I polled the reviews by lantern-light,
If CodeRabbit cries "changes", I hold the merge tight,
When checks all pass we twirl with delight,
I nibble a carrot and cheer: "Alright!" ✨

🚥 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 'ci: replace Gate 3 with real CodeRabbit check, add Gate 5 aggregate' directly summarizes the two main changes in the workflow file: replacing Gate 3 with a real CodeRabbit check and adding a new Gate 5 aggregate job.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch ci/coderabbit-gate

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

@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: 2

🤖 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/ci.yml:
- Line 79: The workflow currently uses a floating tag "uses:
actions/github-script@v7"; replace that reference with a full commit SHA (the
same style used for other pinned actions in the workflow) to satisfy the
unpinned-uses check. Locate the line containing "uses: actions/github-script@v7"
and update it to the corresponding full commit SHA for the actions/github-script
repository so the action is fully pinned.
- Around line 82-93: The review-state check is using reviews.find() on the
oldest→newest list from pulls.listReviews, so an earlier CodeRabbit review can
be matched instead of the latest; change the logic to identify the latest
CodeRabbit review by filtering reviews for r.user?.login === 'coderabbitai' and
then selecting the last entry (e.g., last element or reversed find) before
checking r.state for 'CHANGES_REQUESTED' or 'APPROVED' (update identifiers
crReview/crApproved accordingly), and also pin actions/github-script@v7 to a
specific commit SHA like the other actions in the workflow to avoid floating
tags.
🪄 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: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 22dfa637-8764-4b6a-89a3-9d93ee2a5823

📥 Commits

Reviewing files that changed from the base of the PR and between a621374 and 4172b95.

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

Comment thread .github/workflows/ci.yml Outdated
Comment thread .github/workflows/ci.yml Outdated

@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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
.github/workflows/ci.yml (1)

74-92: ⚠️ Potential issue | 🟠 Major

Gate 3 will go stale on CodeRabbit review changes—listen for pull_request_review events. (File: .github/workflows/ci.yml, lines 74-92)

A workflow triggered only by pull_request won’t rerun when a PR review is submitted/edited/dismissed, so the “latest CodeRabbit review state” gate won’t update until another PR event occurs.

Minimal trigger update
 on:
   pull_request:
     branches: [main]
+  pull_request_review:
+    types: [submitted, edited, dismissed]
🤖 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/ci.yml around lines 74 - 92, The workflow’s CodeRabbit
gate (job coderabbit-check) is only triggered by pull_request events so it won’t
re-evaluate when reviews change; update the workflow triggers to also run on
pull_request_review (include the review types you care about such as submitted,
edited, dismissed) or move the coderabbit-check steps into a separate workflow
that is triggered on pull_request_review, so the logic that fetches reviews and
checks latestCR state runs whenever a review is posted/edited/dismissed.
🤖 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/ci.yml:
- Around line 87-92: The current logic only fails for latestCR.state ===
'CHANGES_REQUESTED' and lets COMMENTED, DISMISSED or missing reviews pass;
change the check around crReviews/latestCR so that any state other than
'APPROVED' (including no review) triggers core.setFailed with a clear message;
update the conditional referencing crReviews, latestCR and core.setFailed to
compute the actual state (e.g., latestCR?.state ?? 'none') and call
core.setFailed when that value !== 'APPROVED', otherwise log approval.

---

Outside diff comments:
In @.github/workflows/ci.yml:
- Around line 74-92: The workflow’s CodeRabbit gate (job coderabbit-check) is
only triggered by pull_request events so it won’t re-evaluate when reviews
change; update the workflow triggers to also run on pull_request_review (include
the review types you care about such as submitted, edited, dismissed) or move
the coderabbit-check steps into a separate workflow that is triggered on
pull_request_review, so the logic that fetches reviews and checks latestCR state
runs whenever a review is posted/edited/dismissed.
🪄 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: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 4ba44fb2-2f49-4353-ab22-1cd81781fad3

📥 Commits

Reviewing files that changed from the base of the PR and between 4172b95 and 77d7523.

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

Comment thread .github/workflows/ci.yml Outdated
@NavpreetST

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 10, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@NavpreetST

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 10, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
.github/workflows/ci.yml (1)

86-113: ⚠️ Potential issue | 🟠 Major

Gate 3: Anchor the selected CodeRabbit review to the PR head commit
Gate 3 picks the most recent CodeRabbit review by coderabbitai and returns based on latestCR.state without checking that latestCR.commit_id matches the current pr.head.sha, so a stale APPROVED/CHANGES_REQUESTED can unblock/block after new pushes. (The later checks.listForRef already uses pr.head.sha, so the main issue is review commit anchoring.)

Suggested fix
const { data: pr } = await github.rest.pulls.get({
  owner: context.repo.owner,
  repo: context.repo.repo,
  pull_number: context.issue.number,
});
const ref = pr.head.sha;

// after listReviews(...)
const latestCR = [...reviews]
  .reverse()
  .find(r => r.user?.login === 'coderabbitai');

if (latestCR && latestCR.commit_id === ref) {
  if (latestCR.state === 'CHANGES_REQUESTED') core.setFailed('CodeRabbit has CHANGES_REQUESTED — address comments before merge.');
  else if (latestCR.state === 'APPROVED') console.log('CodeRabbit review approved.');
  else core.setFailed(`Latest CodeRabbit review is ${latestCR.state} — approval is required before merge.`);
  return;
}

// otherwise fall through to checks.listForRef(ref=pr.head.sha)
🤖 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/ci.yml around lines 86 - 113, Gate 3 currently uses the
most recent CodeRabbit review (latestCR) without ensuring it is anchored to the
PR head commit, so stale reviews can unblock/block new commits; fetch the pull
request head SHA via github.rest.pulls.get (use context.issue.number) and set
ref = pr.head.sha, then after computing latestCR (the reversed find over
reviews) only consider it valid if latestCR.commit_id === ref before applying
its state checks (CHANGES_REQUESTED / APPROVED / other); if not matching, fall
through to the existing checks.listForRef call which should use the same ref.
🤖 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/ci.yml:
- Around line 6-8: The workflow uses an unsupported branches filter on the
pull_request_review trigger; remove the branches: [main] line from
on.pull_request_review and instead gate the existing job by adding a condition
to the coderabbit-check job (jobs.coderabbit-check.if) that verifies the PR
targets main, e.g. check github.event.pull_request.base.ref === 'main' in the
job's if expression so coderabbit-check only runs for PRs whose base is main.

---

Outside diff comments:
In @.github/workflows/ci.yml:
- Around line 86-113: Gate 3 currently uses the most recent CodeRabbit review
(latestCR) without ensuring it is anchored to the PR head commit, so stale
reviews can unblock/block new commits; fetch the pull request head SHA via
github.rest.pulls.get (use context.issue.number) and set ref = pr.head.sha, then
after computing latestCR (the reversed find over reviews) only consider it valid
if latestCR.commit_id === ref before applying its state checks
(CHANGES_REQUESTED / APPROVED / other); if not matching, fall through to the
existing checks.listForRef call which should use the same ref.
🪄 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: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: a4394630-4646-49dc-abbc-6b4c0e9c83d7

📥 Commits

Reviewing files that changed from the base of the PR and between b80e4ac and f62a0b8.

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

Comment thread .github/workflows/ci.yml Outdated
@NavpreetST

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 10, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@NavpreetST

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 10, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@NavpreetST

Copy link
Copy Markdown
Owner Author

@coderabbitai Please review the latest commit fca3c55 — all comments have been addressed.

@coderabbitai

coderabbitai Bot commented Jun 10, 2026

Copy link
Copy Markdown

@NavpreetST Sure! Triggering a review of the latest commit fca3c55 now.

✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@NavpreetST

Copy link
Copy Markdown
Owner Author

@coderabbitai All comments have been addressed across commits. Please review the latest commit af1cc6c and approve if satisfactory.

@coderabbitai

coderabbitai Bot commented Jun 10, 2026

Copy link
Copy Markdown

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Fetch the current workflow file
cat .github/workflows/ci.yml

echo "---PR DIFF---"
gh pr diff 30 --repo NavpreetST/axis-dash

Length of output: 8764



@NavpreetST Thanks for the heads-up — I've reviewed commit af1cc6c. The overall structure is solid, but I have a few findings before I can approve:


🔴 Stale-approval bypass (Gate 3)

File: .github/workflows/ci.yml, Gate 3 script

const latestCR = allCR.find(r => r.commit_id === ref) ?? allCR[0];

The ?? allCR[0] fallback means: if no review exists for the current head SHA, the gate accepts the most recent CodeRabbit review regardless of which commit it was for. This creates a bypass:

  1. CodeRabbit reviews commit abcAPPROVED
  2. Author pushes new commit def (new head SHA)
  3. Gate 3 runs: no review found for def → falls back to allCR[0] (the old APPROVED for abc)
  4. Gate passes despite the new commit never being reviewed

Suggested fix — remove the fallback or explicitly fail when no review matches the current head:

const latestCR = allCR.find(r => r.commit_id === ref);
if (latestCR) {
  if (latestCR.state === 'CHANGES_REQUESTED') {
    core.setFailed(`CodeRabbit has CHANGES_REQUESTED — address comments before merge.`);
  } else if (latestCR.state === 'APPROVED') {
    console.log('CodeRabbit review approved ✅');
  } else {
    core.setFailed(`Latest CodeRabbit review for this commit is ${latestCR.state} — approval is required.`);
  }
  return;
}
core.setFailed(`No CodeRabbit review found for head commit ${ref}.`);

🟡 Unused checks: read permission

The diff adds checks: read to the top-level permissions block, but the final script no longer calls checks.listForRef. It's harmless but follows the principle of least privilege to remove it.


ℹ️ COMMENTED state blocks Gate 3 (likely intentional?)

The else branch catches COMMENTED, PENDING, DISMISSED, etc. and calls core.setFailed. If intentional (you want only explicit APPROVED to pass), that's fine — just worth confirming this is the desired behaviour.


Once the stale-approval fallback is addressed, I'm happy to approve. The Gate 5 aggregate structure and the pull_request_review trigger logic look correct. 🐇

@NavpreetST

Copy link
Copy Markdown
Owner Author

@coderabbitai All findings have been addressed: pinned github-script to SHA, use latest review, require explicit approval, anchor to head commit with fallback, fixed bot login name, removed unsupported branches filter, added pull_request_review trigger. Please review and approve so Gate 3 can pass.

@coderabbitai

coderabbitai Bot commented Jun 10, 2026

Copy link
Copy Markdown

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
cat .github/workflows/ci.yml

Length of output: 5319



@NavpreetST Thanks for the update — most items look good, but the primary blocking issue (stale-approval bypass) is still present in the file I just fetched.


🔴 Still unresolved: stale-approval fallback

Line 84 of .github/workflows/ci.yml:

const latestCR = allCR.find(r => r.commit_id === ref) ?? allCR[0];

The ?? allCR[0] is still there. The bypass scenario is unchanged:

  1. CodeRabbit reviews commit abcAPPROVED
  2. You push a new commit def (new head SHA)
  3. Gate 3 runs: allCR.find(r => r.commit_id === 'def')undefined
  4. Falls back to allCR[0] → the old APPROVED for abc
  5. Gate passes despite def never being reviewed

The final core.setFailed('No CodeRabbit review found on this PR.') already handles the "no matching review" case — just remove the ?? allCR[0] fallback:

// Before
const latestCR = allCR.find(r => r.commit_id === ref) ?? allCR[0];

// After
const latestCR = allCR.find(r => r.commit_id === ref);

🟡 Still present: unused checks: read permission

permissions:
  contents: read
  pull-requests: read
  checks: read   # ← no checks.listForRef calls remain; safe to remove

✅ Everything else looks good

Item Status
github-script pinned to SHA
Bot login coderabbitai[bot]
pull_request_review trigger
Unsupported branches filter removed
Explicit APPROVED-only pass
Gate 5 aggregate structure

Once the ?? allCR[0] line is fixed, I'm happy to approve. 🐇

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