{"draft":null,"from":3,"to":318,"files":[{"path":"client/src/ci.ts","added":56,"removed":7,"diff":"--- a/client/src/ci.ts\n+++ b/client/src/ci.ts\n@@ -1,4 +1,4 @@\n-// What the project's CI says (#39): the server runs avcs.json's setup, build\n+// What the project's CI says (#39): the server runs abso.json's setup, build\n // and check on each new version of shared. status and log show it; abso ci\n // shows it whole, and one version's job with the end of its output.\n \n@@ -51,7 +51,10 @@\n \t\t\tshared > v ? (ci.running !== null ? running : ci.skipped ? \"\" : ` Versions after ${v} aren't checked yet.`) : \"\";\n \t\tif (ci.checked.result === \"pass\") lines.push(`Shared is green: version ${v} passed its check.${newer}`);\n \t\telse if (ci.checked.result === \"fail\") lines.push(`Version ${v} failed its check. abso ci ${v} shows why.${newer}`);\n-\t\telse lines.push(`CI couldn't check version ${v} (the box failed twice, or avcs.json has nothing to run).${newer}`);\n+\t\telse\n+\t\t\tlines.push(\n+\t\t\t\t`CI couldn't check version ${v} (the box failed twice, or the pipeline file has nothing to run).${newer}`,\n+\t\t\t);\n \t} else {\n \t\tlines.push(\n \t\t\tci.running === null\n@@ -77,6 +80,43 @@\n \treturn lines;\n }\n \n+/** A stored pipeline run as runRuns lists it: what the CI lines need of it. */\n+interface StoredRun {\n+\treadonly id: number;\n+\treadonly version: number;\n+\treadonly state: string;\n+\treadonly file: string;\n+}\n+\n+/** The stored pipeline runs, newest first, from the server's `pipelines` read; empty for anything else. */\n+export function storedRuns(raw: unknown): StoredRun[] {\n+\tconst runs = (raw as { runs?: unknown } | null)?.runs;\n+\tif (!Array.isArray(runs)) return [];\n+\treturn runs.filter(\n+\t\t(r): r is StoredRun =>\n+\t\t\ttypeof r === \"object\" &&\n+\t\t\tr !== null &&\n+\t\t\tNumber.isInteger((r as StoredRun).id) &&\n+\t\t\tNumber.isInteger((r as StoredRun).version) &&\n+\t\t\ttypeof (r as StoredRun).state === \"string\" &&\n+\t\t\ttypeof (r as StoredRun).file === \"string\",\n+\t);\n+}\n+\n+/** One stored run in a line, with where its jobs are. */\n+export function runLine(run: StoredRun): string {\n+\tconst how = run.state === \"planned\" ? \"was planned, not run,\" : run.state === \"running\" ? \"is running\" : run.state;\n+\treturn `Pipeline run ${run.id} (${run.file}) ${how} on version ${run.version}. abso pipeline runs ${run.id} shows its jobs.`;\n+}\n+\n+/**\n+ * Whether the built-in check (abso.json's setup, build and check) had nothing of its own to run. With stored runs, that is\n+ * about the built-in check, not the project's CI, so it isn't said as the project's (abso 719).\n+ */\n+export function builtInHasNothing(ci: CiStatus): boolean {\n+\treturn ci.red === null && ci.skipped?.reason.startsWith(\"nothing to run\") === true;\n+}\n+\n /** A shared version's mark in abso log; \"not checked\" says nothing, since most versions in a busy hour are covered by a newer one's job. */\n export function ciMarkText(mark: CiMark | undefined): string {\n \tswitch (mark) {\n@@ -114,7 +154,7 @@\n \t\t\t? `Version ${job.version} passed${covered}${took === \"\" ? \"\" : ` (${took})`}${job.built ? \"; its build is kept for the preview\" : \"\"}.`\n \t\t\t: job.result === \"fail\"\n \t\t\t\t? `Version ${job.version} failed at ${job.step ?? \"a step\"}${job.exit === undefined || job.exit === null ? \"\" : ` (exit ${job.exit})`}${covered}${took === \"\" ? \"\" : `, ${took}`}.`\n-\t\t\t\t: `Version ${job.version} wasn't checked${job.step === undefined ? \"\" : ` (${job.step})`}: the box failed twice, or avcs.json has nothing to run.`;\n+\t\t\t\t: `Version ${job.version} wasn't checked${job.step === undefined ? \"\" : ` (${job.step})`}: the box failed twice, or the pipeline file has nothing to run.`;\n \tconst output = job.output?.trimEnd() ?? \"\";\n \treturn [\n \t\thead,\n@@ -140,11 +180,20 @@\n \t\t}\n \t\tif (typed !== undefined) {\n \t\t\tif (!/^\\d+$/.test(typed)) throw new UsageError(`a version is a number (got ${JSON.stringify(typed)})`);\n-\t\t\tconst job = await api.ci(Number(typed));\n-\t\t\treturn { text: jobText(job).join(\"\\n\"), json: { ...job } };\n+\t\t\tconst [job, raw] = await Promise.all([api.ci(Number(typed)), api.pipelineRuns().catch(() => null)]);\n+\t\t\tconst run = storedRuns(raw).find((r) => r.version === job.version);\n+\t\t\t// A version the built-in check never ran, with a pipeline run of its own: the run is its CI (abso 719).\n+\t\t\tconst text = run !== undefined && job.result === \"none\" ? [runLine(run)] : jobText(job);\n+\t\t\treturn { text: text.join(\"\\n\"), json: { ...job } };\n \t\t}\n-\t\tconst [ci, status] = await Promise.all([api.ci(), api.status()]);\n-\t\tconst lines = ciText(ci, status.version);\n+\t\tconst [ci, status, raw] = await Promise.all([api.ci(), api.status(), api.pipelineRuns().catch(() => null)]);\n+\t\tconst newest = storedRuns(raw)[0];\n+\t\tconst lines =\n+\t\t\tnewest === undefined\n+\t\t\t\t? ciText(ci, status.version)\n+\t\t\t\t: builtInHasNothing(ci)\n+\t\t\t\t\t? [runLine(newest)]\n+\t\t\t\t\t: [...ciText(ci, status.version), runLine(newest)];\n \t\treturn {\n \t\t\ttext: [\n \t\t\t\t`shared is at version ${status.version}.`,"}],"unmatched":[]}