fix(check): isolate updates by check suite

Same-named checks from different suites must not edit one message.
Include the suite or app identity and retain the former key for
controlled adoption of existing tracked messages.
This commit is contained in:
翅膀 committed 2026-10-23 23:22:04 +08:00
1 parent a95feefaf8
commit 76380ff1c0
3 files changed
+37 -2

No files matched your search

+12 -1
View File
@@ -184,7 +184,13 @@ export function formatCheckRun(
details_url?: string;
status?: string;
output?: { title?: string; summary?: string };
check_suite?: { id?: number };
app?: { id?: number };
};
// Phases of one check (a fresh run id each, as Cloudflare Pages sends them)
// share a suite; two checks of the same name from different workflows or
// apps do not — they never share a message.
const owner = checkRun.check_suite?.id ?? checkRun.app?.id;
const status = workflowStatus(checkRun.status, checkRun.conclusion);
const emoji = WORKFLOW_CONCLUSION_EMOJI[status] ?? "⏳";
@@ -226,9 +232,14 @@ export function formatCheckRun(
url: checkRun.html_url,
color: GITHUB_COLORS[colorKey],
fields,
// Chains tracked before the suite joined the key.
legacyUpdateKey:
repo && checkRun.name && checkRun.head_sha && owner != null
? `check_run:${repo}:${checkRun.name}:${checkRun.head_sha}`
: undefined,
updateKey:
repo && checkRun.name && checkRun.head_sha
? `check_run:${repo}:${checkRun.name}:${checkRun.head_sha}`
? `check_run:${repo}:${owner != null ? `${owner}:` : ""}${checkRun.name}:${checkRun.head_sha}`
: repo && checkRun.id != null
? `check_run:${repo}:${checkRun.id}`
: undefined,
+5
View File
@@ -321,6 +321,11 @@ export interface NeutralMessage {
* previously sent message instead of sending a new one.
*/
updateKey?: string;
/**
* The chain key this message had before `updateKey` changed shape, used
* only to find a message tracked under the old key (then re-keyed).
*/
legacyUpdateKey?: string;
/**
* Discord role ids to mention in the message content (set by dispatch from
* the route's `discordRoleIds`). Only used by the Discord driver.
+20 -1
View File
@@ -317,6 +317,7 @@ describe("message title spec", () => {
head_sha: "abc123def456",
status: "in_progress",
conclusion: null,
check_suite: { id: 7 },
},
repository: repo,
sender,
@@ -331,13 +332,31 @@ describe("message title spec", () => {
head_sha: "abc123def456",
status: "completed",
conclusion: "failure",
check_suite: { id: 7 },
},
repository: repo,
sender,
}),
);
expect(running.updateKey).toBe("check_run:acme/widget:Cloudflare Pages:abc123def456");
expect(running.updateKey).toBe("check_run:acme/widget:7:Cloudflare Pages:abc123def456");
expect(failed.updateKey).toBe(running.updateKey);
// A same-named check of another suite (workflow / app) has its own message.
const other = formatEvent(
route,
event("check_run", {
check_run: {
id: 44,
name: "Cloudflare Pages",
head_sha: "abc123def456",
status: "completed",
conclusion: "success",
check_suite: { id: 8 },
},
repository: repo,
sender,
}),
);
expect(other.updateKey).not.toBe(running.updateKey);
});
it("check_suite shows conclusion, service, branch and commit", () => {