Skip to content

Commit 39adaee

Browse files
authored
Merge branch 'main' into feat/duplication-scan
2 parents df381cb + bbfc46b commit 39adaee

3 files changed

Lines changed: 48 additions & 10 deletions

File tree

src/github/webhook-coalesce.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ const COALESCABLE_PULL_REQUEST_ACTIONS = new Set([
55
"synchronize",
66
"edited",
77
"ready_for_review",
8-
"labeled",
9-
"unlabeled",
108
]);
119

1210
export function githubWebhookCoalesceKey(

test/integration/orb-relay.test.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -551,6 +551,44 @@ describe("enqueueRelayPending", () => {
551551
expect(JSON.parse(rows.results[0]?.raw_body ?? "{}")).toMatchObject({ marker: "new" });
552552
});
553553

554+
it("does not let label-only PR events coalesce away pending gate-triggering PR events", async () => {
555+
const e = brokeredEnv();
556+
const prBody = (action: string, marker: string) =>
557+
JSON.stringify({
558+
action,
559+
repository: { full_name: "JSONbored/Gittensory" },
560+
pull_request: { number: 1629, head: { sha: "a".repeat(40) } },
561+
marker,
562+
});
563+
564+
await enqueueRelayPending(e, {
565+
deliveryId: "pr-opened-actionable",
566+
installationId: 9608,
567+
eventName: "pull_request",
568+
rawBody: prBody("opened", "actionable"),
569+
});
570+
await enqueueRelayPending(e, {
571+
deliveryId: "pr-labeled-not-actionable",
572+
installationId: 9608,
573+
eventName: "pull_request",
574+
rawBody: prBody("labeled", "label-only"),
575+
});
576+
577+
const events = await pullRelayPending(e, 9608);
578+
expect(events.map((event) => event.deliveryId).sort()).toEqual([
579+
"pr-labeled-not-actionable",
580+
"pr-opened-actionable",
581+
]);
582+
expect(
583+
Object.fromEntries(
584+
events.map((event) => [event.deliveryId, JSON.parse(event.rawBody).action]),
585+
),
586+
).toEqual({
587+
"pr-labeled-not-actionable": "labeled",
588+
"pr-opened-actionable": "opened",
589+
});
590+
});
591+
554592
it("keeps exact duplicate coalescible delivery IDs idempotent", async () => {
555593
const e = brokeredEnv();
556594
const body = (marker: string) =>

test/unit/github-webhook-coalesce.test.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ describe("githubWebhookCoalesceKey", () => {
2424
).toBe("github-webhook:ci-completed:jsonbored/gittensory@def5678");
2525
});
2626

27-
it("coalesces refresh-like pull request events and ignores terminal actions", () => {
27+
it("coalesces gate-triggering pull request events and ignores non-actionable or terminal actions", () => {
2828
expect(
2929
githubWebhookCoalesceKey("pull_request", {
3030
action: "synchronize",
@@ -40,13 +40,15 @@ describe("githubWebhookCoalesceKey", () => {
4040
pull_request: { number: 100, head: { sha: "BEEF123" } },
4141
} as GitHubWebhookPayload),
4242
).toBe("github-webhook:pr-refresh:jsonbored/gittensory#100@beef123");
43-
expect(
44-
githubWebhookCoalesceKey("pull_request", {
45-
action: "closed",
46-
repository: { full_name: "JSONbored/Gittensory" },
47-
pull_request: { number: 100, head: { sha: "BEEF123" } },
48-
} as GitHubWebhookPayload),
49-
).toBeNull();
43+
for (const action of ["labeled", "unlabeled", "closed"]) {
44+
expect(
45+
githubWebhookCoalesceKey("pull_request", {
46+
action,
47+
repository: { full_name: "JSONbored/Gittensory" },
48+
pull_request: { number: 100, head: { sha: "BEEF123" } },
49+
} as GitHubWebhookPayload),
50+
).toBeNull();
51+
}
5052
});
5153

5254
it("returns null for malformed or non-coalescible webhook shapes", () => {

0 commit comments

Comments
 (0)