Skip to content

Commit 764db84

Browse files
zoomote2[bot]zoomote[bot]
andauthored
[Fix] Link review gate Details to the workflow run (#2204)
* fix: link review gate to workflow details * test: cover changed review gate links --------- Co-authored-by: zoomote[bot] <305051434+zoomote[bot]@users.noreply.github.com>
1 parent f932deb commit 764db84

2 files changed

Lines changed: 33 additions & 4 deletions

File tree

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,7 @@ jobs:
319319
const communityApprovedLabel = 'community-approved';
320320
const reviewGateName = 'Zoo Code / PR review gate';
321321
const reconciliationCheckName = 'Zoo Code / reconcile PR review state';
322+
const workflowRunUrl = `${context.serverUrl}/${owner}/${repo}/actions/runs/${context.runId}`;
322323
323324
if (context.eventName === 'issue_comment' &&
324325
(!context.payload.issue?.pull_request ||
@@ -656,8 +657,7 @@ jobs:
656657
}
657658
if (!lookupSucceeded && passed) return;
658659
if (latestGateStatus?.state === state &&
659-
latestGateStatus.description === description &&
660-
latestGateStatus.target_url === pr.html_url) {
660+
latestGateStatus.description === description) {
661661
return;
662662
}
663663
const mustInvalidateSuccess = !passed &&
@@ -671,7 +671,7 @@ jobs:
671671
state,
672672
context: reviewGateName,
673673
description,
674-
target_url: pr.html_url,
674+
target_url: workflowRunUrl,
675675
});
676676
} catch (error) {
677677
if (required || mustInvalidateSuccess) throw error;

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

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ const resolveScript = workflow.jobs.resolve.steps[0].with.script as string
1717
const SHA = "a".repeat(40)
1818
const OLD_SHA = "b".repeat(40)
1919
const REVIEWED_AT = Date.parse("2026-08-29T15:02:00Z")
20+
const WORKFLOW_RUN_URL = "https://github.com/Zoo-Code-Org/Zoo-Code/actions/runs/123456"
2021

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

@@ -492,6 +493,8 @@ function buildReconcileHarness(options: HarnessOptions = {}) {
492493
const context = {
493494
eventName,
494495
repo: { owner: "Zoo-Code-Org", repo: "Zoo-Code" },
496+
runId: 123456,
497+
serverUrl: "https://github.com",
495498
payload,
496499
runNumber: options.runNumber ?? 1,
497500
}
@@ -1935,7 +1938,12 @@ describe("PR review-state workflow", () => {
19351938
const result = await runWorkflow()
19361939

19371940
expect(latestGateStatus(result)).toEqual(
1938-
expect.objectContaining({ context: "Zoo Code / PR review gate", sha: SHA, state: "pending" }),
1941+
expect.objectContaining({
1942+
context: "Zoo Code / PR review gate",
1943+
sha: SHA,
1944+
state: "pending",
1945+
target_url: WORKFLOW_RUN_URL,
1946+
}),
19391947
)
19401948
})
19411949

@@ -1955,6 +1963,27 @@ describe("PR review-state workflow", () => {
19551963
expect(result.addLabels).toHaveBeenCalledWith(expect.objectContaining({ labels: ["awaiting-coderabbit"] }))
19561964
})
19571965

1966+
it("publishes a changed review gate status with the workflow run URL", async () => {
1967+
const result = await runWorkflow({
1968+
gateStatuses: [
1969+
{
1970+
context: "Zoo Code / PR review gate",
1971+
state: "pending",
1972+
description: "Wait for the required CI checks to finish.",
1973+
targetUrl: "https://github.com/Zoo-Code-Org/Zoo-Code/pull/1437",
1974+
},
1975+
],
1976+
})
1977+
1978+
expect(latestGateStatus(result)).toEqual(
1979+
expect.objectContaining({
1980+
state: "pending",
1981+
description: "Required CI passed. Waiting for automated review of the latest commit.",
1982+
target_url: WORKFLOW_RUN_URL,
1983+
}),
1984+
)
1985+
})
1986+
19581987
it("continues metadata reconciliation when gate publication fails", async () => {
19591988
const result = await runWorkflow({ createCommitStatusErrorStatus: 500 })
19601989

0 commit comments

Comments
 (0)