-
Notifications
You must be signed in to change notification settings - Fork 638
fix(ci): revalidate readiness when CodeRabbit finds new issues #1175
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
556dc88
fix(ci): revalidate readiness on CodeRabbit findings
Wibias 160ef53
test(ci): cover CodeRabbit readiness revalidation
Wibias 296ab8a
test(ci): bind readiness guard assertion
Wibias 388eb62
test(ci): keep readiness regression out of existing shards
Wibias be5857f
test(ci): remove superseded readiness test path
Wibias b98e6e5
fix(ci): retain CodeRabbit outside-diff findings
Wibias d1cb1a0
test(ci): pin durable outside-diff findings
Wibias 410e855
test(ci): pin deterministic CodeRabbit review ordering
Wibias 43479a0
fix(ci): make CodeRabbit review ordering deterministic
Wibias 5dae9e2
test(ci): pin default-branch trust for comment gate
Wibias aaca47f
fix(ci): source comment gate scripts from default branch
Wibias 3322303
test(ci): update trusted checkout boundary assertion
Wibias 9d43c05
test(ci): run CodeRabbit ordering regression in required suite
Wibias b093eac
test(ci): align hardening allowlist with trusted comment checkout
Wibias File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,136 @@ | ||
| "use strict"; | ||
|
|
||
| const { describe, it } = require("node:test"); | ||
| const assert = require("node:assert/strict"); | ||
| const { | ||
| coderabbitOutsideDiffFindingIds, | ||
| latestCodeRabbitReviewForHead, | ||
| unresolvedFindingsClaim, | ||
| } = require("./pr-quality-state.cjs"); | ||
|
|
||
| const HEAD = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; | ||
| const OUTSIDE_A = "cr-comment:v1:1d258eb2f6791036acf724b1"; | ||
| const OUTSIDE_B = "cr-comment:v1:7a8b9c001122334455667788"; | ||
|
|
||
| function review(overrides = {}) { | ||
| return { | ||
| id: 9001, | ||
| commit_id: HEAD, | ||
| submitted_at: "2026-08-07T06:00:00Z", | ||
| user: { login: "coderabbitai[bot]" }, | ||
| body: `**Actionable comments posted: 4**\n\n> [!CAUTION]\n> Some comments are outside the diff and can’t be posted inline due to platform limitations.\n> <details>\n> <summary>⚠️ Outside diff range comments (2)</summary>\n> <!-- ${OUTSIDE_A} -->\n> <!-- ${OUTSIDE_B} -->\n> </details>`, | ||
| ...overrides, | ||
| }; | ||
| } | ||
|
|
||
| describe("durable CodeRabbit outside-diff findings", () => { | ||
| it("uses CodeRabbit's stable cr-comment markers as finding identities", () => { | ||
| assert.deepEqual( | ||
| coderabbitOutsideDiffFindingIds({ reviews: [review()], liveHeadSha: HEAD }), | ||
| [OUTSIDE_A, OUTSIDE_B], | ||
| ); | ||
| }); | ||
|
|
||
| it("keeps standalone outside-diff findings active without an inline thread", () => { | ||
| assert.deepEqual( | ||
| unresolvedFindingsClaim({ | ||
| threads: [], | ||
| reviews: [review()], | ||
| liveHeadSha: HEAD, | ||
| }), | ||
| { | ||
| code: "review_findings", | ||
| unresolved: 2, | ||
| byBot: { "coderabbitai[bot]": 2 }, | ||
| }, | ||
| ); | ||
| }); | ||
|
|
||
| it("adds outside-diff markers without double-counting the review actionable total", () => { | ||
| assert.deepEqual( | ||
| unresolvedFindingsClaim({ | ||
| threads: [ | ||
| { isResolved: false, author: { login: "coderabbitai[bot]" } }, | ||
| ], | ||
| reviews: [review()], | ||
| liveHeadSha: HEAD, | ||
| }), | ||
| { | ||
| code: "review_findings", | ||
| unresolved: 3, | ||
| byBot: { "coderabbitai[bot]": 3 }, | ||
| }, | ||
| ); | ||
| }); | ||
|
|
||
| it("a later clean CodeRabbit review on the same head clears older markers", () => { | ||
| assert.deepEqual( | ||
| unresolvedFindingsClaim({ | ||
| threads: [], | ||
| reviews: [ | ||
| review({ id: 9000, submitted_at: "2026-08-07T05:00:00Z" }), | ||
| review({ | ||
| id: 9002, | ||
| submitted_at: "2026-08-07T07:00:00Z", | ||
| body: "**Actionable comments posted: 0**", | ||
| }), | ||
| ], | ||
| liveHeadSha: HEAD, | ||
| }), | ||
| { code: null, unresolved: 0, byBot: {} }, | ||
| ); | ||
| }); | ||
|
|
||
| it("uses review id as a deterministic tie-breaker when timestamps are missing", () => { | ||
| const latest = latestCodeRabbitReviewForHead({ | ||
| reviews: [ | ||
| review({ id: 9001, submitted_at: undefined, body: `Outside diff range comments (1)\n<!-- ${OUTSIDE_A} -->` }), | ||
| review({ id: 9002, submitted_at: undefined, body: "**Actionable comments posted: 0**" }), | ||
| ], | ||
| liveHeadSha: HEAD, | ||
| }); | ||
|
|
||
| assert.equal(latest?.id, 9002); | ||
| assert.deepEqual( | ||
| coderabbitOutsideDiffFindingIds({ | ||
| reviews: [ | ||
| review({ id: 9001, submitted_at: undefined, body: `Outside diff range comments (1)\n<!-- ${OUTSIDE_A} -->` }), | ||
| review({ id: 9002, submitted_at: undefined, body: "**Actionable comments posted: 0**" }), | ||
| ], | ||
| liveHeadSha: HEAD, | ||
| }), | ||
| [], | ||
| ); | ||
| }); | ||
|
|
||
| it("ignores CodeRabbit markers from an older head and from human reviews", () => { | ||
| assert.deepEqual( | ||
| coderabbitOutsideDiffFindingIds({ | ||
| reviews: [ | ||
| review({ commit_id: "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb" }), | ||
| review({ | ||
| id: 9002, | ||
| user: { login: "maintainer" }, | ||
| submitted_at: "2026-08-07T07:00:00Z", | ||
| }), | ||
| ], | ||
| liveHeadSha: HEAD, | ||
| }), | ||
| [], | ||
| ); | ||
| }); | ||
|
|
||
| it("deduplicates repeated markers in the review body", () => { | ||
| assert.deepEqual( | ||
| coderabbitOutsideDiffFindingIds({ | ||
| reviews: [ | ||
| review({ | ||
| body: `Outside diff range comments (1)\n<!-- ${OUTSIDE_A} -->\n<!-- ${OUTSIDE_A} -->`, | ||
| }), | ||
| ], | ||
| liveHeadSha: HEAD, | ||
| }), | ||
| [OUTSIDE_A], | ||
| ); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.