Skip to content

Commit 4fe5a1f

Browse files
zoomote[bot]roomote
andauthored
[Fix] Review Roomote pull requests with CodeRabbit (#1598)
* fix(ci): review zoomote pull requests with CodeRabbit * test(ci): assert CodeRabbit routing logs --------- Co-authored-by: Roomote <[email protected]>
1 parent c6eb8fb commit 4fe5a1f

2 files changed

Lines changed: 47 additions & 6 deletions

File tree

‎.github/workflows/label-pr-review-state.yml‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ jobs:
8787
const codeRabbitLogin = 'coderabbitai[bot]';
8888
const codeRabbitLogins = new Set([codeRabbitLogin, 'coderabbitai']);
8989
const codeRabbitActiveLabel = 'coderabbit-review-active';
90+
const codeRabbitEligibleBotLogins = new Set(['zoomote[bot]']);
9091
const reviewGateName = 'Zoo Code / PR review gate';
9192
const reconciliationCheckName = 'Zoo Code / reconcile PR review state';
9293
@@ -660,6 +661,8 @@ jobs:
660661
review => review.state === 'CHANGES_REQUESTED'
661662
);
662663
const automatedAuthor = pr.user?.type === 'Bot';
664+
const codeRabbitEligibleAuthor = !automatedAuthor ||
665+
codeRabbitEligibleBotLogins.has(pr.user?.login.toLowerCase());
663666
const codeRabbitReviewComplete = freshCodeRabbitReview?.state === 'APPROVED';
664667
const codeRabbitChangesRequested = freshCodeRabbitReview?.state === 'CHANGES_REQUESTED';
665668
const maintainerApproval = freshMaintainerReviews
@@ -676,7 +679,7 @@ jobs:
676679
if (codeRabbitChangesRequested || maintainerChangeRequest) {
677680
desiredLabel = 'awaiting-author';
678681
phase = codeRabbitChangesRequested ? 'coderabbit-changes' : 'maintainer-changes';
679-
} else if (automatedAuthor) {
682+
} else if (!codeRabbitEligibleAuthor) {
680683
if (pr.draft) {
681684
desiredLabel = null;
682685
phase = 'draft';
@@ -736,7 +739,7 @@ jobs:
736739
737740
core.info(
738741
`PR #${pr.number}: CI passing, reviews=${latest.size}, ` +
739-
`coderabbit=${freshCodeRabbitReview?.state ?? (automatedAuthor ? 'optional' : 'pending')}, ` +
742+
`coderabbit=${freshCodeRabbitReview?.state ?? (codeRabbitEligibleAuthor ? 'pending' : 'optional')}, ` +
740743
`maintainer=${maintainerApproval?.state ?? 'pending'} → ${desiredLabel ?? '(none)'}`
741744
);
742745

‎src/services/__tests__/pr-review-state-workflow.test.ts‎

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,7 @@ async function runWorkflow(options: HarnessOptions = {}) {
396396
createCommitStatus,
397397
createLabel,
398398
setFailed,
399+
info: core.info,
399400
warning: core.warning,
400401
getPullRequest,
401402
listPullRequests: github.rest.pulls.list,
@@ -537,22 +538,59 @@ describe("PR review-state workflow", () => {
537538
expect(latestGuide(result)).toContain("Review-state labels are managed by this workflow")
538539
})
539540

540-
it("routes bot-authored PRs directly to maintainer review", async () => {
541+
it("starts CodeRabbit for zoomote-authored PRs after required CI passes", async () => {
541542
const result = await runWorkflow({
542543
prAuthor: { login: "zoomote[bot]", type: "Bot" },
543544
})
544545

546+
expect(result.addLabels).toHaveBeenCalledWith(expect.objectContaining({ labels: ["coderabbit-review-active"] }))
547+
expect(result.addLabels).toHaveBeenCalledWith(expect.objectContaining({ labels: ["awaiting-coderabbit"] }))
548+
expect(latestGateStatus(result)?.state).toBe("pending")
549+
expect(latestGateStatus(result)?.description).toContain("Waiting for automated review")
550+
expect(result.info).toHaveBeenCalledWith(expect.stringContaining("coderabbit=pending"))
551+
})
552+
553+
it("does not start CodeRabbit for draft zoomote-authored PRs", async () => {
554+
const result = await runWorkflow({
555+
draft: true,
556+
prAuthor: { login: "zoomote[bot]", type: "Bot" },
557+
})
558+
559+
expect(result.addLabels).not.toHaveBeenCalledWith(
560+
expect.objectContaining({ labels: ["coderabbit-review-active"] }),
561+
)
562+
expect(latestGuide(result)).toContain("Mark the PR ready")
563+
})
564+
565+
it("does not start CodeRabbit for zoomote-authored PRs while required CI fails", async () => {
566+
const result = await runWorkflow({
567+
prAuthor: { login: "zoomote[bot]", type: "Bot" },
568+
requiredConclusion: "failure",
569+
})
570+
571+
expect(result.addLabels).not.toHaveBeenCalledWith(
572+
expect.objectContaining({ labels: ["coderabbit-review-active"] }),
573+
)
574+
expect(latestGateStatus(result)?.description).toContain("Fix the failing required CI checks")
575+
})
576+
577+
it("routes other bot-authored PRs directly to maintainer review", async () => {
578+
const result = await runWorkflow({
579+
prAuthor: { login: "dependabot[bot]", type: "Bot" },
580+
})
581+
545582
expect(result.addLabels).toHaveBeenCalledWith(expect.objectContaining({ labels: ["awaiting-maintainer"] }))
546583
expect(result.addLabels).not.toHaveBeenCalledWith(
547584
expect.objectContaining({ labels: ["coderabbit-review-active"] }),
548585
)
549586
expect(latestGateStatus(result)?.state).toBe("success")
550587
expect(latestGateStatus(result)?.description).toContain("Awaiting fresh human maintainer")
588+
expect(result.info).toHaveBeenCalledWith(expect.stringContaining("coderabbit=optional"))
551589
})
552590

553-
it("completes bot-authored PR review after human maintainer approval", async () => {
591+
it("completes other bot-authored PR review after human maintainer approval", async () => {
554592
const result = await runWorkflow({
555-
prAuthor: { login: "zoomote[bot]", type: "Bot" },
593+
prAuthor: { login: "dependabot[bot]", type: "Bot" },
556594
permissions: { maintainer: "write" },
557595
reviews: [
558596
{
@@ -569,7 +607,7 @@ describe("PR review-state workflow", () => {
569607

570608
it("honors manually requested CodeRabbit changes on bot-authored PRs", async () => {
571609
const result = await runWorkflow({
572-
prAuthor: { login: "zoomote[bot]", type: "Bot" },
610+
prAuthor: { login: "dependabot[bot]", type: "Bot" },
573611
reviews: [
574612
{
575613
login: "coderabbitai[bot]",

0 commit comments

Comments
 (0)