Public: anyone can read this; the crew can change it.
Main has had no full check since the 11:19 PM one failed at 42m #16640
Check · Review · Land · Live done — Landed and live in production.
scout/forge:scout/16639-main-has-had-no-full-check-since-the-11 → main 0 commits fork 3 threads · 3 unresolved
8 files
changed +97
−10
src/checks/event_handler.ts +16 −2
| @@ -12,6 +12,7 @@ import { checkOnApproval } from "./approval.ts"; | ||
| 12 | 12 | import { settleLandedRuns } from "../crew/interrupted.ts"; |
| 13 | 13 | import type { LaneState } from "./lane_state.ts"; |
| 14 | 14 | import { recheckBase } from "./recheck_base.ts"; |
| 15 | import { askVerifications } from "./verify_lane.ts"; | |
| 15 | 16 | |
| 16 | 17 | export async function onEvent(lane: LaneState, event: ForgeEvent): Promise<void> { |
| 17 | 18 | const { app } = lane; |
| @@ -49,7 +50,7 @@ export async function onEvent(lane: LaneState, event: ForgeEvent): Promise<void> | ||
| 49 | 50 | ) |
| 50 | 51 | continue; |
| 51 | 52 | const branch = update.ref.slice("refs/heads/".length); |
| 52 | if (branch === repo.defaultBranch) | |
| 53 | if (branch === repo.defaultBranch) { | |
| 53 | 54 | await lane.request( |
| 54 | 55 | repo, |
| 55 | 56 | branch, |
| @@ -58,6 +59,8 @@ export async function onEvent(lane: LaneState, event: ForgeEvent): Promise<void> | ||
| 58 | 59 | undefined, |
| 59 | 60 | actor, |
| 60 | 61 | ); |
| 62 | await verifyLanding(lane); | |
| 63 | } | |
| 61 | 64 | await recheckBase(lane, repo, branch, update.newOid); |
| 62 | 65 | for (const pull of listPulls(app.db, repo.id, { |
| 63 | 66 | sealed: true, |
| @@ -170,7 +173,7 @@ export async function onEvent(lane: LaneState, event: ForgeEvent): Promise<void> | ||
| 170 | 173 | pull.baseBranch === repo.defaultBranch && |
| 171 | 174 | typeof mergeOid === "string" && |
| 172 | 175 | /^[0-9a-f]{40}$/.test(mergeOid) |
| 173 | ) | |
| 176 | ) { | |
| 174 | 177 | await lane.request( |
| 175 | 178 | repo, |
| 176 | 179 | repo.defaultBranch, |
| @@ -180,6 +183,8 @@ export async function onEvent(lane: LaneState, event: ForgeEvent): Promise<void> | ||
| 180 | 183 | actor, |
| 181 | 184 | lane.settle > 0 ? new Date(Date.now() + lane.settle).toISOString() : undefined, |
| 182 | 185 | ); |
| 186 | await verifyLanding(lane); | |
| 187 | } | |
| 183 | 188 | if (event.kind === "pull.merged" && typeof mergeOid === "string" && /^[0-9a-f]{40}$/.test(mergeOid)) |
| 184 | 189 | await recheckBase(lane, repo, pull.baseBranch, mergeOid); |
| 185 | 190 | return; |
| @@ -189,6 +194,15 @@ export async function onEvent(lane: LaneState, event: ForgeEvent): Promise<void> | ||
| 189 | 194 | } |
| 190 | 195 | } |
| 191 | 196 | |
| 197 | /** | |
| 198 | * Every landing on the default branch starts a full check: the verification of its new tip is | |
| 199 | * asked now, not at the sweep's next turn, and not held back by the age of the last (#16639). | |
| 200 | */ | |
| 201 | async function verifyLanding(lane: LaneState): Promise<void> { | |
| 202 | if (lane.options.verifyOnLanding === false) return; | |
| 203 | await askVerifications(lane, Date.now(), 0); | |
| 204 | } | |
| 205 | ||
| 192 | 206 | async function headOf(app: App, repo: Repo, pull: Pull): Promise<string | undefined> { |
| 193 | 207 | const dir = await pullDir(app.db, app.reposRoot, repo, pull); |
| 194 | 208 | const ref = pull.crossRepo |
src/checks/lane_state.ts +5
| @@ -79,6 +79,11 @@ export interface ChecksOptions { | ||
| 79 | 79 | * to `VERIFY_EVERY_MS`. The forge sets it to `VERIFY_EVERY_MS`. |
| 80 | 80 | */ |
| 81 | 81 | readonly verifyEveryMs?: number | undefined; |
| 82 | /** | |
| 83 | * Whether a landing on the default branch asks its own verification at once (#16639). | |
| 84 | * Tests of the sweep (`verifyDue`) turn it off to see the sweep alone. @default true | |
| 85 | */ | |
| 86 | readonly verifyOnLanding?: boolean | undefined; | |
| 82 | 87 | /** Test seam: stands in for the tier the local runner runs, to see what reaches it. */ |
| 83 | 88 | readonly runTier?: ((x: Execution) => Promise<CheckOutcome>) | undefined; |
| 84 | 89 | /** Test seam: how often the queue is looked at. @default TICK_MS */ |
src/checks/verify_lane.ts +11 −4
| @@ -26,10 +26,17 @@ export function startVerify(lane: LaneState): void { | ||
| 26 | 26 | if (repo !== undefined) start(lane, next, repo); |
| 27 | 27 | } |
| 28 | 28 | |
| 29 | /** Every verification due now: main moved since the last, and that one is old enough. */ | |
| 30 | export async function askVerifications(lane: LaneState, now = Date.now()): Promise<Run[]> { | |
| 31 | const { app, options } = lane; | |
| 32 | const everyMs = options.verifyEveryMs ?? VERIFY_EVERY_MS; | |
| 29 | /** | |
| 30 | * Every verification due now: main moved since the last, and that one is old enough. A landing | |
| 31 | * passes `everyMs` 0: the commit that just landed is verified at once, whatever the last one's | |
| 32 | * age, unless one is already queued or running (#16639). | |
| 33 | */ | |
| 34 | export async function askVerifications( | |
| 35 | lane: LaneState, | |
| 36 | now = Date.now(), | |
| 37 | everyMs: number = lane.options.verifyEveryMs ?? VERIFY_EVERY_MS, | |
| 38 | ): Promise<Run[]> { | |
| 39 | const { app } = lane; | |
| 33 | 40 | const since = new Date(now - 24 * 3_600_000).toISOString(); |
| 34 | 41 | // The newest default-branch check of each repository that had one today. |
| 35 | 42 | const tips = app.db |
test/check-budget.test.ts +1
test/check-verify-rerun.test.ts +1 −1
| @@ -77,7 +77,7 @@ beforeAll(async () => { | ||
| 77 | 77 | const made = await createRepo(app, alice, { name: "reran", visibility: "public" }); |
| 78 | 78 | if (!made.ok) throw new Error("repo"); |
| 79 | 79 | repo = made.value; |
| 80 | checks = startChecks(app, { forgeUrl: "http://forge.test", concurrency: 1 }); | |
| 80 | checks = startChecks(app, { forgeUrl: "http://forge.test", concurrency: 1, verifyOnLanding: false }); | |
| 81 | 81 | }); |
| 82 | 82 | afterAll(async () => { |
| 83 | 83 | await checks.stop(); |
test/check-verify.test.ts +1 −1
| @@ -76,7 +76,7 @@ beforeAll(async () => { | ||
| 76 | 76 | const made = await createRepo(app, alice, { name: "verified", visibility: "public" }); |
| 77 | 77 | if (!made.ok) throw new Error("repo"); |
| 78 | 78 | repo = made.value; |
| 79 | checks = startChecks(app, { forgeUrl: "http://forge.test", concurrency: 1 }); | |
| 79 | checks = startChecks(app, { forgeUrl: "http://forge.test", concurrency: 1, verifyOnLanding: false }); | |
| 80 | 80 | }); |
| 81 | 81 | afterAll(async () => { |
| 82 | 82 | await checks.stop(); |
test/verify-on-landing.test.ts added +60
| @@ -0,0 +1,60 @@ | ||
| 1 | /** | |
| 2 | * Every landing on main starts a full check (#16639): the verification of the new tip is asked | |
| 3 | * by the landing itself, not left to the sweep, and the age of the last one does not hold it back. | |
| 4 | */ | |
| 5 | import { describe, expect, test } from "bun:test"; | |
| 6 | import { commitToBranch } from "../src/actions/repos.ts"; | |
| 7 | import { VERIFY_ENV } from "../src/checks/verify.ts"; | |
| 8 | import { checksForge } from "./helpers/checks-forge.ts"; | |
| 9 | ||
| 10 | describe("a landing on main", () => { | |
| 11 | const f = checksForge("forge-verify-landing-"); | |
| 12 | const verifications = (oid: string) => f.checksOf(oid).filter((r) => r.env === VERIFY_ENV); | |
| 13 | ||
| 14 | test("asks its own verification once; one landing while it runs asks none, the sweep asks the next", async () => { | |
| 15 | // Invariant: a push to the default branch queues a verification of that commit without | |
| 16 | // verifyDue, never twice, and never beside one that is queued or running. | |
| 17 | const declare = `{"check": {"run": "true", "install": "", "verify": ${JSON.stringify(f.held("v"))}}}\n`; | |
| 18 | const first = await commitToBranch(f.app, f.alice, f.repo, { | |
| 19 | message: "main declares a verification", | |
| 20 | files: [{ path: "forge.json", content: declare }], | |
| 21 | }); | |
| 22 | if (!first.ok) throw new Error(JSON.stringify(first.error)); | |
| 23 | const a = first.value.commitOid; | |
| 24 | await f.until(() => verifications(a).length > 0, "the landing's verification asked"); | |
| 25 | ||
| 26 | // A second landing while the first verification is held: nothing is queued beside it. | |
| 27 | const second = await commitToBranch(f.app, f.alice, f.repo, { | |
| 28 | message: "main moves", | |
| 29 | files: [{ path: "NEXT.md", content: "next\n" }], | |
| 30 | }); | |
| 31 | if (!second.ok) throw new Error(JSON.stringify(second.error)); | |
| 32 | const b = second.value.commitOid; | |
| 33 | await f.until(() => f.checksOf(b).some((r) => r.env === f.repo.defaultBranch), "main's check of the second asked"); | |
| 34 | expect(verifications(b)).toEqual([]); | |
| 35 | expect(await f.checks.verifyDue(Date.now() + 60 * 60_000)).toEqual([]); | |
| 36 | ||
| 37 | f.release("v"); | |
| 38 | await f.settled((r) => r.env === VERIFY_ENV && r.commitOid === a); | |
| 39 | // Asked once for the first landing, and not again by the sweep once it has ended. | |
| 40 | expect(verifications(a)).toHaveLength(1); | |
| 41 | ||
| 42 | // Ended: the sweep asks exactly one verification, of the new tip. | |
| 43 | const asked = await f.checks.verifyDue(Date.now() + 60 * 60_000); | |
| 44 | expect(asked.map((r) => r.commitOid)).toEqual([b]); | |
| 45 | expect(await f.checks.verifyDue(Date.now() + 60 * 60_000)).toEqual([]); | |
| 46 | f.release("v"); | |
| 47 | await f.settled((r) => r.env === VERIFY_ENV && r.commitOid === b); | |
| 48 | expect(verifications(b)).toHaveLength(1); | |
| 49 | ||
| 50 | // Minutes old is far under the 30 the sweep waits: a third landing is verified now. | |
| 51 | const third = await commitToBranch(f.app, f.alice, f.repo, { | |
| 52 | message: "main moves again", | |
| 53 | files: [{ path: "THIRD.md", content: "third\n" }], | |
| 54 | }); | |
| 55 | if (!third.ok) throw new Error(JSON.stringify(third.error)); | |
| 56 | await f.until(() => verifications(third.value.commitOid).length > 0, "the third landing's verification asked"); | |
| 57 | expect(verifications(third.value.commitOid)).toHaveLength(1); | |
| 58 | f.release("v"); | |
| 59 | }); | |
| 60 | }); |
test/verify-requeued-at-tip.test.ts +2 −2
| @@ -15,7 +15,7 @@ import { BUDGET_PREFIX } from "../src/kernel/budgets.ts"; | ||
| 15 | 15 | import { checksForge } from "./helpers/checks-forge.ts"; |
| 16 | 16 | |
| 17 | 17 | describe("a verification a restart cut off", () => { |
| 18 | const f = checksForge("forge-verify-requeue-"); | |
| 18 | const f = checksForge("forge-verify-requeue-", { verifyOnLanding: false }); | |
| 19 | 19 | |
| 20 | 20 | test("is asked again of main's tip", async () => { |
| 21 | 21 | // Invariant: a cut verification's retry names the default branch's newest checked commit. |
| @@ -59,7 +59,7 @@ describe("a verification a restart cut off", () => { | ||
| 59 | 59 | // No service was up to ask main's own check of it: asked here, as the push would have. |
| 60 | 60 | createRun(f.app.db, { repoId: f.repo.id, kind: "check", env: "main", commitOid: third.value.commitOid }); |
| 61 | 61 | // The forge that carries on gives a verification a third of a second: the held one overruns. |
| 62 | f.checks = startChecks(f.app, { forgeUrl: f.servers.url, concurrency: 1, budgetMs: 300, verifyBudgetMs: 300 }); | |
| 62 | f.checks = startChecks(f.app, { forgeUrl: f.servers.url, concurrency: 1, budgetMs: 300, verifyBudgetMs: 300, verifyOnLanding: false }); | |
| 63 | 63 | const verifications = (): Run[] => |
| 64 | 64 | listRuns(f.app.db, f.repo.id, { kind: "check", limit: 50 }).filter((run) => run.env === VERIFY_ENV); |
| 65 | 65 | await f.until(() => verifications().some((run) => run.summary.startsWith(BUDGET_PREFIX)), "the overrun said"); |
new above
offline
The brace on its own line does not match the file's style. Put
{on the closing-paren line as the push branch above does.