Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/label-pr-review-state.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ jobs:
const codeRabbitActiveLabel = 'coderabbit-review-active';
const reviewGateName = 'Zoo Code / PR review gate';
const reconciliationCheckName = 'Zoo Code / reconcile PR review state';
const workflowRunUrl = `${context.serverUrl}/${owner}/${repo}/actions/runs/${context.runId}`;

// When triggered by a single PR event, only reconcile that PR.
// The hourly schedule and workflow_dispatch reconcile all open PRs.
Expand Down Expand Up @@ -316,8 +317,7 @@ jobs:
}
if (!lookupSucceeded && passed) return;
if (latestGateStatus?.state === state &&
latestGateStatus.description === description &&
latestGateStatus.target_url === pr.html_url) {
latestGateStatus.description === description) {
return;
}
const mustInvalidateSuccess = !passed &&
Expand All @@ -331,7 +331,7 @@ jobs:
state,
context: reviewGateName,
description,
target_url: pr.html_url,
target_url: workflowRunUrl,
});
} catch (error) {
if (required || mustInvalidateSuccess) throw error;
Expand Down
31 changes: 30 additions & 1 deletion src/services/__tests__/pr-review-state-workflow.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const workflowScript = workflow.jobs.reconcile.steps[0].with.script as string
const SHA = "a".repeat(40)
const OLD_SHA = "b".repeat(40)
const REVIEWED_AT = Date.parse("2026-08-29T15:02:00Z")
const WORKFLOW_RUN_URL = "https://github.com/Zoo-Code-Org/Zoo-Code/actions/runs/123456"

type ReviewState = "APPROVED" | "CHANGES_REQUESTED" | "COMMENTED" | "DISMISSED"

Expand Down Expand Up @@ -329,6 +330,8 @@ async function runWorkflow(options: HarnessOptions = {}) {
const context = {
eventName,
repo: { owner: "Zoo-Code-Org", repo: "Zoo-Code" },
runId: 123456,
serverUrl: "https://github.com",
payload,
}
const core = {
Expand Down Expand Up @@ -1099,7 +1102,12 @@ describe("PR review-state workflow", () => {
const result = await runWorkflow()

expect(latestGateStatus(result)).toEqual(
expect.objectContaining({ context: "Zoo Code / PR review gate", sha: SHA, state: "pending" }),
expect.objectContaining({
context: "Zoo Code / PR review gate",
sha: SHA,
state: "pending",
target_url: WORKFLOW_RUN_URL,
}),
Comment thread
zoomote[bot] marked this conversation as resolved.
)
})

Expand All @@ -1119,6 +1127,27 @@ describe("PR review-state workflow", () => {
expect(result.addLabels).toHaveBeenCalledWith(expect.objectContaining({ labels: ["awaiting-coderabbit"] }))
})

it("publishes a changed review gate status with the workflow run URL", async () => {
const result = await runWorkflow({
gateStatuses: [
{
context: "Zoo Code / PR review gate",
state: "pending",
description: "Wait for the required CI checks to finish.",
targetUrl: "https://github.com/Zoo-Code-Org/Zoo-Code/pull/1437",
},
],
})

expect(latestGateStatus(result)).toEqual(
expect.objectContaining({
state: "pending",
description: "Required CI passed. Wait for CodeRabbit to approve the latest commit.",
target_url: WORKFLOW_RUN_URL,
}),
)
})

it("continues metadata reconciliation when gate publication fails", async () => {
const result = await runWorkflow({ createCommitStatusErrorStatus: 500 })

Expand Down
Loading