Skip to content
Merged
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
21 changes: 21 additions & 0 deletions .changes/pr-pipeline/fix-holds-into-do-not-merge-fd88d380.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
bump: minor
---

### Changed

- report-outcome labels a lanes App pull request that a person merges `do-not-merge`, and the
`human-merge-hold` label is gone, with its ci-status step and the label readers in
`enable-auto-merge.mjs` and the merge queue's label steps.
- ci-status no longer reads a lanes App pull request's body hold text; its lanes App step keeps a
member's veto comment, the hold paths, cost, trusted-actor list, kill switch and the merge
queue's pr-verify verdict read.
- ci-status no longer fails on a `pr-unblock/*` stop status, and the merge queue's early hold check
no longer reads the head's statuses. `enable-auto-merge.mjs` still does not arm a stopped head.
- The address-feedback round cap, uncertain and disputed stops put `needs-session` on the pull
request in place of `needs-human`; the open review thread still blocks the merge, and a session's
answer on the thread restarts the lane. A CRITICAL code-review finding goes to a session too.
When the finding is security (a CRITICAL or unrated security-review finding), the
new `feedback-round-cap-security`, `feedback-uncertain-security` and
`feedback-disputed-security` stops keep `needs-human`, as do the intent, design and security
question stops. The lost-runs reconciler no longer re-runs ci-status after a cleared stop.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
bump: patch
---

### Changed

- `babysit-prs`: the merge lane no longer treats `human-merge-hold` as a hold label; the lanes App
now marks a pull request a person merges with `do-not-merge`, which the lane already holds.
56 changes: 2 additions & 54 deletions .github/scripts/maintenance-reconcile-lost-runs/reconcile.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,6 @@
// it is lifted re-runs that ci-status, recorded as a CI re-run, with no
// lookback: the switch may have been on for days. A run at attempt 2 or
// later is left to a person, since pr-verify trusts only a recorded attempt 2.
// - Stop: a PR whose newest pr-require-checks run failed, at attempt 1, only
// in ci-status, and only on its notes that a `pr-unblock/*` status failed
// the head (PR_UNBLOCK_STOP_NOTE), while no such status fails it now: the
// lane that stopped ran again and cleared its stop (report-escalation.sh
// clear). A status post starts no run, so nothing else re-runs that
// ci-status. Re-run as a Switch is, with no lookback; a re-run that fails is
// a warning, not a failed run, since the head's next push or a person's
// re-run still clears it.
// - Pending: any PR whose newest pr-require-checks run failed, at attempt 1,
// only in ci-status, and only on its notes that a review lane had not
// finished or had no run yet (PENDING_REVIEW_NOTE, MISSING_REVIEW_NOTE),
Expand Down Expand Up @@ -423,19 +415,8 @@ export const killSwitchNoted = (annotations) =>
export const REVIEW_STOP_NOTE = "a kill switch was on when it started";
export const reviewStopNoted = (annotations) =>
Array.isArray(annotations) && annotations.some((a) => a?.annotation_level === "failure" && String(a.message ?? "").includes(REVIEW_STOP_NOTE));
// The error ci-status's pr-unblock step writes for each `pr-unblock/*` status
// failing the head (pr-require-checks.yml; reconcile.test.mjs pins it there).
export const PR_UNBLOCK_STOP_NOTE = /^'pr-unblock\/[a-z]+(?:-[a-z]+)*' is (?:failure|error) on [0-9a-f]{40}: /;
// The note GitHub adds for a step that exits non-zero.
const EXIT_NOTE = /^Process completed with exit code [0-9]+\.$/;
// True when ci-status's only failure is its pr-unblock step: one or more stop
// notes and that step's one exit note. Any other failure would fail a re-run too.
export const unblockStopNoted = (annotations) => {
const failures = (Array.isArray(annotations) ? annotations : []).filter((a) => a?.annotation_level === "failure").map((a) => String(a.message ?? ""));
const stops = failures.filter((m) => PR_UNBLOCK_STOP_NOTE.test(m)).length;
const exits = failures.filter((m) => EXIT_NOTE.test(m)).length;
return stops > 0 && exits <= 1 && stops + exits === failures.length;
};
// The errors ci-status's review-lane step writes for a review still running,
// or with no run yet, when it read the head (pr-require-checks.yml;
// reconcile.test.mjs pins both there).
Expand All @@ -462,23 +443,6 @@ export const pendingReviewNoted = (annotations) => {
// a third attempt. Should both land, the extra attempt has no record of its
// own, so pr-verify refuses it: the head is stranded, never let through.
export const PENDING_BACKOFF_MINUTES = 20;
// True when the newest status of a `pr-unblock/*` context on the head, by
// github-actions[bot], is failure or error: ci-status's own read. Statuses
// list newest first.
async function unblockStopStands(call, repo, head) {
const seen = new Set();
for (const s of await paginate(call, `/repos/${repo}/commits/${head}/statuses`, 10)) {
const context = String(s?.context ?? "");
if (!context.startsWith("pr-unblock/") || s?.creator?.login !== "github-actions[bot]" || seen.has(context)) {
continue;
}
seen.add(context);
if (s.state === "failure" || s.state === "error") {
return true;
}
}
return false;
}
// A hosted review run a kill switch may have stopped: it reads success with no
// job failed, so only its jobs can tell (`reviewStopped`).
const isUnreviewed = (r) => GATED_REVIEWS.has(r?.path) && r.event === "pull_request" && r.status === "completed" && r.conclusion === "success" && r.run_attempt === 1;
Expand All @@ -488,7 +452,7 @@ const lostNow = (item, r, since) => {
if (r?.head_sha !== item.head) {
return false;
}
if (item.kind === "infra" || item.kind === "flake" || item.kind === "switch" || item.kind === "stop" || item.kind === "pending" || item.kind === "upstream") {
if (item.kind === "infra" || item.kind === "flake" || item.kind === "switch" || item.kind === "pending" || item.kind === "upstream") {
return r.status === "completed" && r.conclusion === "failure" && r.run_attempt === item.attempt;
}
if (item.kind === "review") {
Expand Down Expand Up @@ -902,20 +866,6 @@ async function plan({ repo, call, say, since, now, readStatus, judgeSpec, laneAp
set.push({ kind: "switch", pr: pull.number, id: checks.id, path: checks.path, conclusion: "failure (kill switch)", attempt: 1, head: pull.head.sha });
} else if (checks.run_attempt >= 2 && notes && laneApp !== undefined && pull.user?.id === laneApp && pull.user?.type === "Bot" && killSwitchNoted(notes)) {
say(`#${pull.number}: ci-status failed on the kill switch at attempt ${checks.run_attempt}; a re-run needs a person on the trusted-actor list`);
} else if (isFailedChecks(checks) && notes && unblockStopNoted(notes)) {
// An unreadable status list re-runs nothing and fails no listing: the next run reads it again.
let stands = true;
try {
stands = await unblockStopStands(call, repo, pull.head.sha);
} catch (error) {
if (error instanceof RateLimited) {
throw error;
}
say(`#${pull.number}: its pr-unblock statuses could not be read (${escapeCommand(error?.message ?? error)}); the next run reads them again`);
}
if (!stands) {
set.push({ kind: "stop", pr: pull.number, id: checks.id, path: checks.path, conclusion: "failure (cleared pr-unblock stop)", attempt: 1, head: pull.head.sha });
}
} else if (isFailedChecks(checks) && notes && pendingReviewNoted(notes)) {
// Every PR, not only the lanes App's: a lost rerun-ci-status strands
// a person's head the same way. ci-status's own pick of each review:
Expand Down Expand Up @@ -1219,7 +1169,6 @@ async function act({ repo, call, say, since, sleep, items }) {
item.kind === "infra" ||
item.kind === "flake" ||
item.kind === "switch" ||
item.kind === "stop" ||
item.kind === "pending" ||
item.kind === "upstream"
) {
Expand All @@ -1230,7 +1179,6 @@ async function act({ repo, call, say, since, sleep, items }) {
infra: ", which failed on infra only",
flake: ", its one re-run before fix-ci takes it",
switch: ": ci-status failed while the lanes kill switch was on",
stop: ": ci-status failed on a pr-unblock stop the lane has since cleared",
pending: ": ci-status failed on a review that has since finished",
upstream: ": the upstream-status gate stopped its review, and the gate lets it run now",
}[item.kind];
Expand All @@ -1257,7 +1205,7 @@ async function act({ repo, call, say, since, sleep, items }) {
if (error instanceof RateLimited) {
throw error;
}
if (item.kind === "stop" || item.kind === "pending") {
if (item.kind === "pending") {
console.log(`::warning title=reconcile::${where} run ${item.id}: ${escapeCommand(error?.message ?? error)}`);
continue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { test } from "node:test";

import { createGitHub, GitHubError } from "../../actions/check-trusted-trigger/check-trusted-trigger.mjs";
import { createRateLimitLatch } from "../../actions/log-api-budget/rate-guard.mjs";
import { CI_WORKFLOWS, GITHUB_STATUS_URL, JUDGE_PREDECESSOR, JUDGE_STEP, KILL_SWITCH_NOTE, main, NPM_STATUS_URL, MISSING_REVIEW_NOTE, PENDING_BACKOFF_MINUTES, PENDING_REVIEW_NOTE, PR_UNBLOCK_STOP_NOTE, prefilterSpec, REVIEW_STEP, REVIEW_STOP_NOTE, REVIEW_STOP_STEP, REVIEW_SWITCHES, SETTLED_VERSION, TOO_OLD_DAYS, UPSTREAM_STOP_STEP, VERDICT_STOP_STEP, WRITE_STEP } from "./reconcile.mjs";
import { CI_WORKFLOWS, GITHUB_STATUS_URL, JUDGE_PREDECESSOR, JUDGE_STEP, KILL_SWITCH_NOTE, main, NPM_STATUS_URL, MISSING_REVIEW_NOTE, PENDING_BACKOFF_MINUTES, PENDING_REVIEW_NOTE, prefilterSpec, REVIEW_STEP, REVIEW_STOP_NOTE, REVIEW_STOP_STEP, REVIEW_SWITCHES, SETTLED_VERSION, TOO_OLD_DAYS, UPSTREAM_STOP_STEP, VERDICT_STOP_STEP, WRITE_STEP } from "./reconcile.mjs";
import { switchHold } from "../pr-merge/merge-holds.mjs";
import { tempDir } from "../../../lib/test-tmp.mjs";

Expand Down Expand Up @@ -1733,12 +1733,8 @@ test("ci-status's lanes-hold step still fails a lanes App PR with the kill-switc
assert.ok(switchHold(lanes, { appId: "7", disabled: "true", repoDisabled: "false" }).startsWith(`#1: ${KILL_SWITCH_NOTE} (`));
});

// Any PR whose newest pr-require-checks run failed only in ci-status, on its
// first attempt, on the pr-unblock step's notes: once no pr-unblock/* status
// by github-actions[bot] fails the head (the lane's clear posted success over
// its stop), that ci-status is re-run, recorded as attempt 2. The notes are
// the ones ci-status wrote on #10828's head (check run 123256890668), and the
// step's line is pinned below.
// A ci-status that failed on a pr-unblock stop note (the step ci-status no
// longer has) is not re-run: the reconciler has no stop kind.
const STOP_LINE = (context = "pr-unblock/address-feedback", head = sha(1)) =>
`'${context}' is failure on ${head}: Lane stopped: feedback-untaken-threads; checked again on a new head. The lane that stopped clears it by running again on this head, or a new head carries none.`;
const stopJobs = ({ notes = [STOP_LINE()] } = {}) => [
Expand All @@ -1761,75 +1757,11 @@ const unblockStatus = (state, { context = "pr-unblock/address-feedback", creator
// Newest first, as GitHub lists them: the clear over the stop.
const cleared = (head = sha(1)) => ({ [head]: [unblockStatus("success"), unblockStatus("failure")] });

test("a ci-status a pr-unblock stop failed is re-run once after the lane clears the stop, recorded, past the lookback", async () => {
for (const created of ["2026-10-19T19:00:00Z", "2026-10-12T19:00:00Z"]) {
const { code, outputs, reruns, failedJobReruns, calls } = await reconcile({ pulls: [pr(1)], runs: [failed(101, sha(1), { jobs: stopJobs(), created })], statuses: cleared() });
assert.equal(code, 0);
assert.deepEqual(failedJobReruns, [101]);
assert.deepEqual(reruns, []);
assert.deepEqual(records(outputs), [`reconcile-rerun-101-2-${sha(1)}`, "", ""]);
assert.ok(calls.includes(`GET /repos/${REPO}/commits/${sha(1)}/statuses?per_page=100&page=1`));
}
const again = await reconcile({ pulls: [pr(1)], runs: [failed(101, sha(1), { jobs: stopJobs(), attempt: 2 })], statuses: cleared() });
assert.equal(again.code, 0);
assert.deepEqual(again.failedJobReruns, []);
});

test("a ci-status re-run waits for every pr-unblock stop on the head to clear, and reads only github-actions[bot]'s statuses", async () => {
const notes = [STOP_LINE(), STOP_LINE("pr-unblock/fix-ci")];
const statuses = { [sha(1)]: [unblockStatus("success"), unblockStatus("error", { context: "pr-unblock/fix-ci" }), unblockStatus("failure")] };
const standing = await reconcile({ pulls: [pr(1)], runs: [failed(101, sha(1), { jobs: stopJobs({ notes }) })], statuses });
assert.deepEqual(standing.failedJobReruns, []);
const other = { [sha(1)]: [unblockStatus("success", { creator: { login: "someone" } }), unblockStatus("failure")] };
const forged = await reconcile({ pulls: [pr(1)], runs: [failed(101, sha(1), { jobs: stopJobs() })], statuses: other });
assert.deepEqual(forged.failedJobReruns, []);
});

test("a ci-status with no pr-unblock stop note, or another failure beside it, is not re-run and its statuses are not read", async () => {
const cases = [
stopJobs({ notes: ["#1: the PR body holds it"] }),
stopJobs({ notes: [] }),
stopJobs({ notes: [STOP_LINE(), "the pull request title is not in Conventional Commits form"] }),
stopJobs().map((j) => (j.name === "ci-status" ? { ...j, notes: [...j.notes, { annotation_level: "failure", message: "Process completed with exit code 1." }] } : j)),
];
for (const jobs of cases) {
const { code, calls } = await reconcile({ pulls: [pr(1)], runs: [failed(101, sha(1), { jobs })], statuses: cleared() });
assert.equal(code, 0);
assert.deepEqual(calls.filter((c) => c.startsWith("POST ")), []);
assert.ok(!calls.some((c) => c.includes("/statuses")));
}
const passed = await reconcile({ pulls: [pr(1)], runs: [run(101, sha(1), { conclusion: "success" })], statuses: cleared() });
assert.deepEqual(passed.calls.filter((c) => c.startsWith("POST ") || c.includes("/statuses")), []);
});

test("an unreadable status list re-runs nothing and fails no listing", async (t) => {
const log = t.mock.method(console, "log", () => {});
const fail = { [`GET /repos/${REPO}/commits/${sha(1)}/statuses?per_page=100&page=1`]: new Error("HTTP 502") };
const { code, calls } = await reconcile({ pulls: [pr(1)], runs: [failed(101, sha(1), { jobs: stopJobs() })], statuses: cleared(), fail });
test("a ci-status that failed on a pr-unblock stop note is not re-run, even once the stop cleared", async () => {
const { code, calls } = await reconcile({ pulls: [pr(1)], runs: [failed(101, sha(1), { jobs: stopJobs() })], statuses: cleared() });
assert.equal(code, 0);
assert.deepEqual(calls.filter((c) => c.startsWith("POST ")), []);
assert.ok(log.mock.calls.some((c) => String(c.arguments[0]).includes("#1: its pr-unblock statuses could not be read (HTTP 502)")));
});

test("a failed ci-status re-run after a cleared stop is a warning, and the run still passes", async (t) => {
const log = t.mock.method(console, "log", () => {});
const fail = { [`POST /repos/${REPO}/actions/runs/101/rerun-failed-jobs`]: new Error("HTTP 500") };
const { code, calls } = await reconcile({ pulls: [pr(1)], runs: [failed(101, sha(1), { jobs: stopJobs() })], statuses: cleared(), fail });
const lines = log.mock.calls.map((c) => String(c.arguments[0]));
assert.equal(code, 0);
assert.ok(calls.includes(`POST /repos/${REPO}/actions/runs/101/rerun-failed-jobs`));
assert.ok(lines.includes("::warning title=reconcile::#1 run 101: HTTP 500"));
assert.ok(!lines.some((l) => l.startsWith("::error")));
});

test("ci-status's pr-unblock step still writes the stop note the reconciler matches", () => {
const workflow = readFileSync(new URL("../../workflows/pr-require-checks.yml", import.meta.url), "utf8");
const step = /- name: Fail a head a pr-unblock lane stopped\n(?:(?:[ ]{8,}.*)?\n)+/.exec(workflow)?.[0] ?? "";
const line = step.split("\n").find((l) => l.includes(`echo "::error::'$context' is $state on $head: `));
assert.ok(line, "the stop error line is in the step");
assert.match(step, /done <<<"\$failing"\n[ ]+exit 1\n/);
assert.match(STOP_LINE("pr-unblock/conflict"), PR_UNBLOCK_STOP_NOTE);
assert.doesNotMatch(STOP_LINE("ci-lanes"), PR_UNBLOCK_STOP_NOTE);
assert.ok(!calls.some((c) => c.includes("/statuses")));
});

// A hosted review run the upstream-status gate stopped: its kill-switch job
Expand Down
3 changes: 3 additions & 0 deletions .github/scripts/pr-merge/clear-escalations.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -1529,6 +1529,9 @@ test("a security, intent or decision stop is never lifted, even after a trusted
"feedback-question-design",
"feedback-question-security",
"feedback-round-cap",
"feedback-round-cap-security",
"feedback-uncertain-security",
"feedback-disputed-security",
"dependency-security-close",
"dependency-escalate",
"repeat-cap",
Expand Down
3 changes: 1 addition & 2 deletions .github/scripts/pr-merge/enable-auto-merge.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,6 @@ import {
BODY_HOLD,
costDecision,
costHold,
HUMAN_MERGE_HOLD,
humansOf,
LANE_HOLD,
liftersOf,
Expand All @@ -250,7 +249,7 @@ const REPO = /^([A-Za-z0-9_.-]+)\/([A-Za-z0-9_.-]+)$/;
const SHA = /^[0-9a-f]{40}$/;
const BOT_LOGIN = /^([a-z0-9][a-z0-9-]*)\[bot\]$/;
// babysit_merge_policy.MERGE_HOLD_LABELS, plus the human-gated label.
export const HOLD_LABELS = Object.freeze(["do-not-merge", "pr-verify-failed", HUMAN_MERGE_HOLD, OUTSIDE_ACTOR_LABEL]);
export const HOLD_LABELS = Object.freeze(["do-not-merge", "pr-verify-failed", OUTSIDE_ACTOR_LABEL]);
Comment thread
kyle-sexton marked this conversation as resolved.
Resolved
// 100 pull requests a page; more than this many open is a listing the run
// holds on (ListingFull) rather than one it reads only part of.
const MAX_PAGES = 10;
Expand Down
Loading
Loading