Public: anyone can read this; the crew can change it.

Revert "The no_release alarm fires on any repository's oldest merge, so it always claims nothing has gone live" #8763

Merged opened this

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

Merged

revert-8687 → main 1 commit

  • Merged. revert-8687 was merged into main as 00f10d1.

Review

Sign in to review this change.
4 files changed +8 −40
src/release/landings.ts +1 −2
@@ -99,8 +99,7 @@ export function forgetLive(): void {
9999
100100 function isLive(row: MergedRow, state: LiveState | undefined): boolean {
101101 if (state === undefined || row.repo.toLowerCase() !== state.own.toLowerCase()) return true;
102 // A merge made before the running commit is behind it, though git was not asked about it (or answered no for a rewritten history).
103 return Date.parse(row.at) <= state.at || (row.oid !== "" && state.oids.has(row.oid));
102 return row.oid === "" ? Date.parse(row.at) <= state.at : state.oids.has(row.oid);
104103 }
105104
106105 /**
test/changelog.test.ts +2 −3
@@ -65,8 +65,7 @@ describe("changelog page", () => {
6565 const day = new Date().toISOString().slice(0, 10);
6666 merge("forge", "First <b>thing</b>", `${day}T01:00:00.000Z`, oids[0]!);
6767 merge("forge", "Second thing", `${day}T02:00:00.000Z`, oids[1]!);
68 // Not before the running commit was made, or it would be behind it.
69 merge("forge", "Third thing", `${day}T23:59:59.000Z`, oids[2]!);
68 merge("forge", "Third thing", `${day}T03:00:00.000Z`, oids[2]!);
7069 merge("notes", "A note app change", `${day}T02:30:00.000Z`, "");
7170 token = createToken(app.db, alice.id, "rw", "rw").token;
7271 }, 60_000);
@@ -175,7 +174,7 @@ describe("changelog page", () => {
175174 const fork = must(await createRepo(app, alice, { name: "fork", visibility: "public" }));
176175 const c = must(await commitToBranch(app, alice, fork, { message: "fork work", files: [{ path: "x.txt", content: "x\n" }] }));
177176 const day = new Date().toISOString().slice(0, 10);
178 merge("fork", "Fork change", `${day}T23:59:59.000Z`, c.commitOid);
177 merge("fork", "Fork change", `${day}T23:00:00.000Z`, c.commitOid);
179178 delete app.config.forgeRepo;
180179 forgetLive();
181180 process.env["FORGE_COMMIT"] = c.commitOid;
test/flow-alarm-no-release.test.ts +4 −33
@@ -7,7 +7,7 @@ import { createApp } from "../src/app.ts";
77 import { createRepo } from "../src/core/repos.ts";
88 import { createUser } from "../src/core/users.ts";
99 import { id } from "../src/kernel/id.ts";
10 import { forgetLive, keepLive, split, waitingSince } from "../src/release/landings.ts";
10 import { forgetLive, keepLive } from "../src/release/landings.ts";
1111 import { noReleaseAlarm } from "../src/flow/alarm_no_release.ts";
1212
1313 const NOW = new Date("2026-10-26T12:00:00.000Z");
@@ -19,19 +19,16 @@ async function seed() {
1919 if (!u.ok) throw new Error(u.error);
2020 const repo = await createRepo(app.db, app.reposRoot, { ownerId: u.value.id, name: "r", visibility: "public", description: "r" });
2121 if (!repo.ok) throw new Error(repo.error);
22 const other = await createRepo(app.db, app.reposRoot, { ownerId: u.value.id, name: "other", visibility: "public", description: "o" });
23 if (!other.ok) throw new Error(other.error);
2422 let n = 0;
2523 return {
2624 app,
2725 /** The running commit was made at `at`: it contains every merge before it. */
2826 release: (at: string) => keepLive("alice/r", [], Date.parse(at)),
29 merge: (at: string, oid?: string, into: "r" | "other" = "r") => {
30 const target = into === "r" ? repo.value : other.value;
27 merge: (at: string) => {
3128 const issueId = id();
3229 n++;
33 app.db.query(`INSERT INTO issue (id, repo_id, number, kind, title, body, author_id, state, created_at) VALUES (?1, ?2, ?3, 'pull', 'P', '', ?4, 'closed', ?5)`).run(issueId, target.id, n, u.value.id, at);
34 app.db.query(`INSERT INTO pull (issue_id, base_branch, head_branch, base_oid, head_oid, head_repo_id, merged_at, merged_oid) VALUES (?1, ?2, ?3, '', '', ?4, ?5, ?6)`).run(issueId, target.defaultBranch, `b/${n}`, target.id, at, oid ?? null);
30 app.db.query(`INSERT INTO issue (id, repo_id, number, kind, title, body, author_id, state, created_at) VALUES (?1, ?2, ?3, 'pull', 'P', '', ?4, 'closed', ?5)`).run(issueId, repo.value.id, n, u.value.id, at);
31 app.db.query(`INSERT INTO pull (issue_id, base_branch, head_branch, base_oid, head_oid, head_repo_id, merged_at) VALUES (?1, ?2, ?3, '', '', ?4, ?5)`).run(issueId, repo.value.defaultBranch, `b/${n}`, repo.value.id, at);
3532 },
3633 };
3734 }
@@ -65,30 +62,4 @@ describe("no release alarm", () => {
6562 t.release(minAgo(100));
6663 expect(noReleaseAlarm(t.app.db, NOW).fired).toBe(false);
6764 });
68 test("stays quiet with an empty release record: a merge older than the running commit is behind it", async () => {
69 const s = await seed();
70 s.merge(minAgo(4000), "cafe");
71 s.release(minAgo(10));
72 expect(noReleaseAlarm(s.app.db, NOW).fired).toBe(false);
73 expect(waitingSince(s.app.db)).toBeUndefined();
74 });
75 test("a merge in another repository never fires it", async () => {
76 const s = await seed();
77 s.merge(minAgo(4000), "beef", "other");
78 s.release(minAgo(10));
79 expect(noReleaseAlarm(s.app.db, NOW).fired).toBe(false);
80 });
81 test("a git miss merged after the running commit still fires it", async () => {
82 const s = await seed();
83 s.merge(minAgo(91), "cafe");
84 s.release(minAgo(200));
85 expect(noReleaseAlarm(s.app.db, NOW).fired).toBe(true);
86 });
87 test("split counts a miss older than the running commit live, so /changelog agrees", () => {
88 const row = (n: number, at: string) => ({ repo: "alice/r", number: n, title: "P", at, oid: `o${n}` });
89 const state = { own: "alice/r", oids: new Set<string>(), misses: new Set(["o1", "o2"]), at: Date.parse(minAgo(100)), commit: "c" };
90 const { live, onItsWay } = split([row(2, minAgo(50)), row(1, minAgo(500))], state);
91 expect(live.map((l) => l.number)).toEqual([1]);
92 expect(onItsWay.map((l) => l.number)).toEqual([2]);
93 });
9465 });
test/landings-asked-once.test.ts +1 −2
@@ -45,8 +45,7 @@ describe("landings ask git once per merge commit", () => {
4545 let n = 0;
4646 const merge = (oid: string) => {
4747 n++;
48 // After the running commit was made, or it would already contain the merge.
49 const at = new Date(Date.now() + n * 60_000).toISOString();
48 const at = new Date(Date.now() - (10 - n) * 60_000).toISOString();
5049 const issueId = id();
5150 app.db.query(`INSERT INTO issue (id, repo_id, number, kind, title, body, author_id, state, created_at) VALUES (?1, ?2, ?3, 'pull', 'P', '', ?4, 'closed', ?5)`).run(issueId, repo.value.id, n, u.value.id, at);
5251 app.db.query(`INSERT INTO pull (issue_id, base_branch, head_branch, base_oid, head_oid, head_repo_id, merged_at, merged_oid) VALUES (?1, ?2, ?3, '', '', ?4, ?5, ?6)`).run(issueId, repo.value.defaultBranch, `b/${n}`, repo.value.id, at, oid);

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs