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

Merged opened this in answer to

Check · Review · Land · Live done — Landed and live in production.

Merged

scout/forge:scout/16639-main-has-had-no-full-check-since-the-11 → main 0 commits fork 3 threads · 3 unresolved

  • Merged. scout/16639-main-has-had-no-full-check-since-the-11 was merged into main as 4b13b3b.

Review

Sign in to review this change.
8 files changed +97 −10
src/checks/event_handler.ts +16 −2
@@ -12,6 +12,7 @@ import { checkOnApproval } from "./approval.ts";
1212 import { settleLandedRuns } from "../crew/interrupted.ts";
1313 import type { LaneState } from "./lane_state.ts";
1414 import { recheckBase } from "./recheck_base.ts";
15 import { askVerifications } from "./verify_lane.ts";
1516
1617 export async function onEvent(lane: LaneState, event: ForgeEvent): Promise<void> {
1718 const { app } = lane;
@@ -49,7 +50,7 @@ export async function onEvent(lane: LaneState, event: ForgeEvent): Promise<void>
4950 )
5051 continue;
5152 const branch = update.ref.slice("refs/heads/".length);
52 if (branch === repo.defaultBranch)
53 if (branch === repo.defaultBranch) {
5354 await lane.request(
5455 repo,
5556 branch,
@@ -58,6 +59,8 @@ export async function onEvent(lane: LaneState, event: ForgeEvent): Promise<void>
5859 undefined,
5960 actor,
6061 );
62 await verifyLanding(lane);
63 }
6164 await recheckBase(lane, repo, branch, update.newOid);
6265 for (const pull of listPulls(app.db, repo.id, {
6366 sealed: true,
@@ -170,7 +173,7 @@ export async function onEvent(lane: LaneState, event: ForgeEvent): Promise<void>
170173 pull.baseBranch === repo.defaultBranch &&
171174 typeof mergeOid === "string" &&
172175 /^[0-9a-f]{40}$/.test(mergeOid)
173 )
176 ) {
174177 await lane.request(
outdated

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.

175178 repo,
176179 repo.defaultBranch,
@@ -180,6 +183,8 @@ export async function onEvent(lane: LaneState, event: ForgeEvent): Promise<void>
180183 actor,
181184 lane.settle > 0 ? new Date(Date.now() + lane.settle).toISOString() : undefined,
182185 );
186 await verifyLanding(lane);
187 }
183188 if (event.kind === "pull.merged" && typeof mergeOid === "string" && /^[0-9a-f]{40}$/.test(mergeOid))
184189 await recheckBase(lane, repo, pull.baseBranch, mergeOid);
185190 return;
@@ -189,6 +194,15 @@ export async function onEvent(lane: LaneState, event: ForgeEvent): Promise<void>
189194 }
190195 }
191196
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
192206 async function headOf(app: App, repo: Repo, pull: Pull): Promise<string | undefined> {
193207 const dir = await pullDir(app.db, app.reposRoot, repo, pull);
194208 const ref = pull.crossRepo
src/checks/lane_state.ts +5
@@ -79,6 +79,11 @@ export interface ChecksOptions {
7979 * to `VERIFY_EVERY_MS`. The forge sets it to `VERIFY_EVERY_MS`.
8080 */
8181 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;
8287 /** Test seam: stands in for the tier the local runner runs, to see what reaches it. */
8388 readonly runTier?: ((x: Execution) => Promise<CheckOutcome>) | undefined;
8489 /** 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 {
2626 if (repo !== undefined) start(lane, next, repo);
2727 }
2828
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;
3340 const since = new Date(now - 24 * 3_600_000).toISOString();
3441 // The newest default-branch check of each repository that had one today.
3542 const tips = app.db
test/check-budget.test.ts +1
@@ -29,6 +29,7 @@ beforeAll(async () => {
2929 concurrency: 1,
3030 budgetMs: 400,
3131 verifyBudgetMs: 60_000,
32 verifyOnLanding: false,
3233 });
3334 });
3435
test/check-verify-rerun.test.ts +1 −1
@@ -77,7 +77,7 @@ beforeAll(async () => {
7777 const made = await createRepo(app, alice, { name: "reran", visibility: "public" });
7878 if (!made.ok) throw new Error("repo");
7979 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 });
8181 });
8282 afterAll(async () => {
8383 await checks.stop();
test/check-verify.test.ts +1 −1
@@ -76,7 +76,7 @@ beforeAll(async () => {
7676 const made = await createRepo(app, alice, { name: "verified", visibility: "public" });
7777 if (!made.ok) throw new Error("repo");
7878 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 });
8080 });
8181 afterAll(async () => {
8282 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";
1515 import { checksForge } from "./helpers/checks-forge.ts";
1616
1717 describe("a verification a restart cut off", () => {
18 const f = checksForge("forge-verify-requeue-");
18 const f = checksForge("forge-verify-requeue-", { verifyOnLanding: false });
1919
2020 test("is asked again of main's tip", async () => {
2121 // 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", () => {
5959 // No service was up to ask main's own check of it: asked here, as the push would have.
6060 createRun(f.app.db, { repoId: f.repo.id, kind: "check", env: "main", commitOid: third.value.commitOid });
6161 // 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 });
6363 const verifications = (): Run[] =>
6464 listRuns(f.app.db, f.repo.id, { kind: "check", limit: 50 }).filter((run) => run.env === VERIFY_ENV);
6565 await f.until(() => verifications().some((run) => run.summary.startsWith(BUDGET_PREFIX)), "the overrun said");

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs