GeezerVison is showing github.com — fix(server): PR watches wake when checks finish after an early failure by Rhinomcd · Pull Request #28020 · pingdotgg/t3code
fix(server): PR watches wake when checks finish after an early failure
#28020
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and
privacy statement . We’ll occasionally send you account related emails.
Already on GitHub?
Sign in
to your account
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
e7c27ec
fix(server): PR watches wake when checks finish after an early failure
Rhinomcd Oct 31, 2026
cbfcff0
fix(server): only a failing gate check owes the checks-finished wake
Rhinomcd Oct 31, 2026
9b2cb8e
fix(server): an advisory failure keeps the owed gate checks
Rhinomcd Oct 31, 2026
76ba89f
fix(server): owed checks stay owed while they run, whatever the gate
Rhinomcd Oct 31, 2026
f357c58
fix(server): owed checks survive another failure, and finishing wakes…
Rhinomcd Oct 31, 2026
a904b1f
fix(server): a checks-finished wake says when only required checks fi…
Rhinomcd Nov 5, 2026
f2544f8
test(server): drop the copy assertion on the checks-finished summary
Rhinomcd Nov 5, 2026
4001515
Merge remote-tracking branch 'github/main' into fix/pr-watch-wake-aft…
maria-rcks Nov 5, 2026
9a48b34
revert(contracts): keep the owedChecks doc comment as on main
maria-rcks Nov 5, 2026
4700db1
Merge remote-tracking branch 'github/main' into pr-28020
maria-rcks Nov 10, 2026
f3436f2
Merge remote-tracking branch 'origin/main' into fix/pr-watch-wake-aft…
juliusmarminge Nov 12, 2026
abbde4d
test(server): keep the notification outcome, not the copy, in the che…
juliusmarminge Nov 12, 2026
9c0ae21
Merge remote-tracking branch 'origin/main' into fix/pr-watch-wake-aft…
juliusmarminge Nov 12, 2026
File filter
Filter by extension
.ts
(2)
All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Hide whitespace
Diff view
Hide whitespace
There are no files selected for viewing
Original file line number
Diff line number
Diff line change
Expand Up
@@ -541,6 +541,136 @@ describe("evaluatePullRequestWatch", () => {
assert.deepEqual(evaluatePullRequestWatch(final.next, recovered, noRemarks).changes, []);
});
it("wakes once when the other checks finish after one failed where none is required", () => {
const sonar = check("sonar", "cancelled");
const early = detail({ checks: [sonar, check("unit", "pending"), check("e2e", "pending")] });
const first = evaluatePullRequestWatch(watch(), early, noRemarks);
assert.deepEqual(first.changes, [{ kind: "checks-failed", failed: [sonar] }]);
const partway = detail({ checks: [sonar, check("unit", "success"), check("e2e", "pending")] });
const waiting = evaluatePullRequestWatch(first.next, partway, noRemarks);
assert.deepEqual(waiting.changes, []);
const done = detail({ checks: [sonar, check("unit", "success"), check("e2e", "success")] });
const final = evaluatePullRequestWatch(waiting.next, done, noRemarks);
assert.deepEqual(final.changes, [
{ kind: "checks-finished", failing: [sonar], required: false },
]);
assert.deepEqual(evaluatePullRequestWatch(final.next, done, noRemarks).changes, []);
// An owed check stays owed while it runs, even when the failed one turns required.
const gated = detail({
checks: [{ ...sonar, required: true }, check("unit", "success"), check("e2e", "pending")],
});
const still = evaluatePullRequestWatch(waiting.next, gated, noRemarks);
assert.deepEqual(still.changes, []);
assert.deepEqual(still.next.owedChecks, ["e2e"]);
// Another gate failure owes the gate's running checks on top of those still owed.
const lint = { ...check("lint", "failure"), required: true };
const another = detail({ checks: [...gated.checks, lint] });
const both = evaluatePullRequestWatch(still.next, another, noRemarks);
assert.deepEqual(both.changes, [{ kind: "checks-failed", failed: [lint] }]);
assert.deepEqual(both.next.owedChecks, ["e2e"]);
// The last owed check finishing still wakes when an unrelated check fails in the same read.
const bot = check("bot", "failure");
const finishedWithBot = detail({
checks: [sonar, check("unit", "success"), check("e2e", "success"), bot],
});
assert.deepEqual(evaluatePullRequestWatch(waiting.next, finishedWithBot, noRemarks).changes, [
{ kind: "checks-failed", failed: [bot] },
{ kind: "checks-finished", failing: [sonar, bot], required: false },
]);
// A later failure is its own wake and leaves nothing more owed.
const broke = detail({ checks: [sonar, check("unit", "success"), check("e2e", "failure")] });
const failure = evaluatePullRequestWatch(waiting.next, broke, noRemarks);
assert.deepEqual(failure.changes, [
{ kind: "checks-failed", failed: [check("e2e", "failure")] },
]);
assert.deepEqual(evaluatePullRequestWatch(failure.next, broke, noRemarks).changes, []);
// A failure while another owed check still runs keeps that one owed.
const unitBroke = detail({
checks: [sonar, check("unit", "failure"), check("e2e", "pending")],
});
const second = evaluatePullRequestWatch(first.next, unitBroke, noRemarks);
assert.deepEqual(second.changes, [
{ kind: "checks-failed", failed: [check("unit", "failure")] },
]);
const settled = detail({ checks: [sonar, check("unit", "failure"), check("e2e", "success")] });
const last = evaluatePullRequestWatch(second.next, settled, noRemarks);
assert.deepEqual(last.changes, [
{ kind: "checks-finished", failing: [sonar, check("unit", "failure")], required: false },
]);
});
it("wakes once when the other required checks finish after a required one failed", () => {
const required = (name: string, status: PullRequestCheck["status"]) => ({
...check(name, status),
required: true,
});
const early = detail({
checks: [
required("lint", "failure"),
required("unit", "pending"),
check("bot", "failure"),
check("e2e", "pending"),
],
});
const first = evaluatePullRequestWatch(watch(), early, noRemarks);
assert.equal(first.changes.length, 1);
assert.deepEqual(first.next.owedChecks, ["unit"]);
const done = detail({
checks: [
required("lint", "failure"),
required("unit", "success"),
check("bot", "failure"),
check("e2e", "pending"),
],
});
const final = evaluatePullRequestWatch(first.next, done, noRemarks);
assert.deepEqual(final.changes, [
{ kind: "checks-finished", failing: [required("lint", "failure")], required: true },
]);
assert.deepEqual(evaluatePullRequestWatch(final.next, done, noRemarks).changes, []);
const message = pullRequestWatchMessage({
number: 7,
url: "https://github.com/o/r/pull/7",
baseBranch: "main",
headSha: "aaaaaaaaaa",
report: final,
});
assert.equal(message.notification.outcome, "failed");
// A new advisory failure keeps what was owed rather than owing a required check started since.
const advisory = detail({
checks: [
required("lint", "failure"),
required("unit", "pending"),
required("smoke", "pending"),
check("bot", "failure"),
check("e2e", "failure"),
],
});
const later = evaluatePullRequestWatch(first.next, advisory, noRemarks);
assert.deepEqual(later.changes, [{ kind: "checks-failed", failed: [check("e2e", "failure")] }]);
assert.deepEqual(later.next.owedChecks, ["unit"]);
// A rerun of the failed required check is not the gate finishing, even with an advisory failure.
const rerun = detail({
checks: [
required("lint", "pending"),
required("unit", "success"),
check("bot", "failure"),
check("e2e", "pending"),
],
});
assert.deepEqual(evaluatePullRequestWatch(first.next, rerun, noRemarks).changes, []);
});
it("clears old-head owed checks when a new head is pushed", () => {
const required = { ...check("test", "success"), required: true };
const early = detail({ checks: [required, check("e2e", "pending")] });
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -17,6 +17,11 @@ const SNIPPET_LENGTH = 200;
export type PullRequestWatchChange =
| { readonly kind: "checks-failed"; readonly failed: ReadonlyArray<PullRequestCheck> }
| { readonly kind: "checks-passed"; readonly count: number; readonly required: boolean }
| {
readonly kind: "checks-finished";
readonly failing: ReadonlyArray<PullRequestCheck>;
readonly required: boolean;
}
| { readonly kind: "checks-awaiting-approval"; readonly checks: ReadonlyArray<PullRequestCheck> }
| { readonly kind: "remarks"; readonly remarks: ReadonlyArray<PullRequestComment> }
| { readonly kind: "no-checks"; readonly minutes: number }
Expand Down
Expand Up
@@ -55,15 +60,16 @@ export function evaluatePullRequestWatch(
let passed = headMoved ? false : watch.passed;
let passedChecks = headMoved ? [] : watch.passedChecks;
let owedChecks = headMoved ? [] : (watch.owedChecks ?? []);
const owedBefore = owedChecks;
let awaitingApproval = headMoved ? [] : (watch.awaitingApproval ?? []);
let approvalAnnounced = headMoved ? false : (watch.approvalAnnounced ?? false);
// An unavailable approval read cannot establish success or that no checks exist.
const unread = detail.checks.some((check) => check.placeholder === true);
const checks = detail.checks.filter((check) => check.placeholder !== true);
const failed = checks.filter(isFailedCheck);
const awaiting = checks.filter((check) => check.status === "action-required");
const newlyFailed = failed.filter((check) => !failedChecks.includes(check.name));
if (checks.length > 0) {
const newlyFailed = failed.filter((check) => !failedChecks.includes(check.name));
if (!checksBaseline && newlyFailed.length > 0) {
changes.push({ kind: "checks-failed", failed: newlyFailed });
}
Expand Down
Expand Up
@@ -140,6 +146,25 @@ export function evaluatePullRequestWatch(
} else if (settled && owed.length > 0) {
changes.push({ kind: "checks-passed", count: checks.length, required: false });
owedChecks = [];
} else if (gate.some(isFailedCheck)) {
// Gate checks still running when one failed are owed one wake when they finish, since
// the gate can no longer pass and so never sends the checks-passed wake.
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
Uh oh!
There was an error while loading. Please reload this page.
const running = checks
.filter((check) => check.status === "pending" || check.status === "action-required")
.map((check) => check.name);
const stillOwed = owedBefore.filter((name) => running.includes(name));
const gateNewlyFailed = newlyFailed.some((check) => gateNames.includes(check.name));
owedChecks = gateNewlyFailed
? [...new Set([...stillOwed, ...running.filter((name) => gateNames.includes(name))])]
: stillOwed;
const owedFailed = newlyFailed.some((check) => owedBefore.includes(check.name));
if (!owedFailed && owedBefore.length > 0 && owedChecks.length === 0) {
changes.push({
kind: "checks-finished",
failing: gate.filter(isFailedCheck),
required: owedBefore.every((name) => required.some((check) => check.name === name)),
});
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
Uh oh!
There was an error while loading. Please reload this page.
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
Uh oh!
There was an error while loading. Please reload this page.
}
passed = passedNow;
passedChecks = passedNow ? gateNames : [];
Expand Down
Expand Up
@@ -272,6 +297,14 @@ function changeLines(
return ` - ${remark.author?.login ?? "someone"}${where}: ${said}${remark.url ? ` ${remark.url}` : ""}`;
}),
];
case "checks-finished":
return [
`- The ${change.required ? "required " : ""}checks still running when one failed have finished${context.commit}. Still failing:`,
...listed(
change.failing,
(check) => ` - ${check.name}${check.url ? ` ${check.url}` : ""}`,
),
];
case "no-checks":
return [
`- No checks have reported${context.commit} after ${change.minutes} minutes. None may be configured to run on this change.`,
Expand All
@@ -284,6 +317,7 @@ function changeLines(
const SUMMARY: Record<PullRequestWatchChange["kind"], string> = {
"checks-failed": "checks failed",
"checks-passed": "checks passed",
"checks-finished": "checks finished",
"checks-awaiting-approval": "checks await approval",
remarks: "new comments",
"no-checks": "no checks reported",
Expand Down
Expand Up
@@ -348,7 +382,10 @@ export function pullRequestWatchMessage(input: {
: WATCHING_CLOSING,
].join("\n");
const failed = changes.some(
(change) => change.kind === "checks-failed" || change.kind === "conflicting",
(change) =>
change.kind === "checks-failed" ||
change.kind === "checks-finished" ||
change.kind === "conflicting",
);
const summary = changes.map((change) => SUMMARY[change.kind]);
if (exhausted) summary.push("stopped watching");
Expand Down
Loading
Oops, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.