Watch
0
0
Fork
You've already forked hyperhive
0

swarm-ui: a builds page for the swarm builder's runs, and the status links to it

/builds lists the builder's recent builds newest first, one card each with how
it ended, and opens a failed build's nix tail. /builds?run=<id> opens that
build's card and scrolls to it. The swarm-builder commit status now links
there instead of to the raw JSON record.
This commit is contained in:
iris 2026-10-18 00:38:21 +02:00 • committed by mara
commit 0e77d61a9f
9 changed files with 391 additions and 13 deletions

View file

@ -0,0 +1,51 @@
// The builds page's `?run=` link and what each outcome's card shows. Run by
// `npm test`, which Node runs with its built-in test runner and type
// stripping, so the `.ts` module is imported as it is.
import assert from "node:assert/strict";
import { test } from "node:test";
import { bodyText, wantedRun } from "../src/pages/builds/builds-types.ts";
const base = {
id: "atlas-abc-1",
repo: "agent-configs/atlas",
pr: 3,
head_sha: "abcdef0123456789",
started_unix: 100,
finished_unix: 160,
};
test("a ?run= link names the run it carries", () => {
assert.equal(wantedRun("?run=atlas-abc-1"), "atlas-abc-1");
assert.equal(wantedRun("run=atlas-abc-1&x=1"), "atlas-abc-1");
});
test("no run, or an empty one, names none", () => {
assert.equal(wantedRun(""), null);
assert.equal(wantedRun("?x=1"), null);
assert.equal(wantedRun("?run="), null);
});
test("a failed build shows what nix printed, as it was printed", () => {
const body = bodyText({ ...base, outcome: "failed", error_tail: "error: x" });
assert.deepEqual(body, {
label: "what nix printed",
text: "error: x",
preformatted: true,
});
});
test("a built one shows its closure, an errored one its reason", () => {
assert.equal(
bodyText({ ...base, outcome: "built", out_path: "/nix/store/x" })?.text,
"/nix/store/x",
);
assert.equal(
bodyText({ ...base, outcome: "error", detail: "no node" })?.text,
"no node",
);
});
test("a run with no text for its outcome shows no body", () => {
assert.equal(bodyText({ ...base, outcome: "failed" }), null);
assert.equal(bodyText({ ...base, outcome: "built", error_tail: "x" }), null);
});