Pipelines: a run job may set timeout, the seconds each of its steps may take (1 to 900, 300 when unset). JOB_TIMEOUT_DEFAULT and JOB_TIMEOUT_MAX are exported, and the job carries timeout when it is set. A timeout on a uses job, or one that isn't whole seconds in range, is refused with the reason. Tests: src/pipeline/test/pipeline.test.ts (25). Version 210 of shared· onboard· Oct 15 (2026-10-15 03:46 UTC) · Not checked
Version 209 · Files at version 210
2 files, 69 lines added, 5 removed.
--- a/src/pipeline/pipeline.ts
+++ b/src/pipeline/pipeline.ts
@@ -9,7 +9,8 @@
9 9 // jobs make a version green (`required`). A job runs a command (`run`) or a 10 10 // built-in step (`uses`), after the jobs it `needs`, and may take another 11 11 // job's kept files (`from`) and named `secrets`, and a run job may ask for an 12 − // abso key on its own project (`abso: reader` or `writer`) for the length of the job.
12 + // abso key on its own project (`abso: reader` or `writer`) for the length of the job. A run job may 13 + // say how long each of its steps may take (`timeout`, in seconds: 300 unless it says, 900 at most). 14 15 // What the check refuses: a cycle in needs; needs, required or from naming a 15 16 // job that doesn't exist; secrets in a pipeline a draft can start, since a @@ -42,6 +43,8 @@
42 43 readonly secrets: readonly string[]; 43 44 /** An abso key on the project for the job's length (abso 343): none unless asked. */ 44 45 readonly abso?: "reader" | "writer"; 46 + /** Seconds each step of a run job may take, when it says (JOB_TIMEOUT_DEFAULT otherwise). */ 47 + readonly timeout?: number; 45 48 /** The built-in step's own settings (deploy's worker, staging, live; notify's to), as written. */ 46 49 readonly with: Readonly<Record<string, unknown>>; @@ -98,7 +101,21 @@
99 102 const SIZES: readonly Size[] = ["small", "standard", "large"]; 100 103 const MACHINE_KEYS = ["image", "dockerfile", "size"] as const; 101 − const JOB_KEYS = ["needs", "run", "uses", "from", "keep", "cache", "secrets", "abso", ...MACHINE_KEYS] as const;
116 + /** A run job's step limit when it names none, and the most it may name (the customer runner's cap too). */ 117 + export const JOB_TIMEOUT_DEFAULT = 300; 118 + export const JOB_TIMEOUT_MAX = 900; 102 119 const PIPELINE_KEYS = ["on", "only", "jobs", "required"] as const; 103 120 /** avcs.json's keys for today's CI (worker/src/ci.ts) and the merge queue: read elsewhere, left alone here. */ 104 121 const AVCS_JSON_KEYS = ["setup", "check", "build", "out", "queue", "whole"] as const; @@ -299,6 +316,21 @@
299 316 else if (j.uses !== undefined) 300 317 say(`${at}.abso`, "gives a run job a key; a uses step runs on the server and has none"); 319 + const timeout = j.timeout; 321 + timeout !== undefined && 322 + typeof timeout === "number" && 323 + Number.isInteger(timeout) && 325 + timeout <= JOB_TIMEOUT_MAX && 326 + j.uses === undefined; 327 + if (timeout !== undefined && !timed) 330 + j.uses !== undefined 331 + ? "gives a run job's steps more time; a uses step runs on the server and has none" 332 + : `must be whole seconds from 1 to ${JOB_TIMEOUT_MAX}, not ${q(timeout)}`, 302 334 const withs: Record<string, unknown> = {}; 303 335 for (const k of settings) if (j[k] !== undefined) withs[k] = j[k]; 304 336 if (uses === "deploy" && typeof j.worker !== "string") @@ -327,6 +359,7 @@
327 359 cache: list(j.cache, `${at}.cache`, say, "a list of files"), 329 361 ...((j.abso === "reader" || j.abso === "writer") && j.uses === undefined ? { abso: j.abso } : {}), 362 + ...(timed ? { timeout: timeout as number } : {}), 331 364 ...machine(j, at, say, false), --- a/src/pipeline/test/pipeline.test.ts
+++ b/src/pipeline/test/pipeline.test.ts
@@ -5,7 +5,14 @@
5 5 import assert from "node:assert/strict"; 6 6 import { describe, it } from "node:test"; 7 7 import { parse } from "yaml"; 8 − import { type Checked, checkPipelines, type Problem, readPipelineFile } from "../pipeline.ts";
15 + } from "../pipeline.ts"; 10 17 /** The draft pipeline file, comments included. */ 11 18 const DRAFT = `defaults: { image: node, size: standard } # image: a menu or \`dockerfile: path\` @@ -300,14 +307,14 @@
300 307 const ps = problems( 302 309 defaults: { image: "node", colour: "blue" }, 303 − pipelines: { p: { on: ["push"], when: "always", jobs: { a: { run: "x", timeout: 5, worker: "w" } } } },
310 + pipelines: { p: { on: ["push"], when: "always", jobs: { a: { run: "x", retries: 5, worker: "w" } } } }, 307 314 has(ps, "extra", /isn't a key here/); 308 315 has(ps, "defaults.colour", /isn't a key here/); 309 316 has(ps, "pipelines.p.when", /isn't a key here \(known: on, only, jobs, required\)/); 310 − has(ps, "pipelines.p.jobs.a.timeout", /isn't a key here/);
317 + has(ps, "pipelines.p.jobs.a.retries", /isn't a key here/); 311 318 // worker is deploy's own setting, not a run job's. 312 319 has(ps, "pipelines.p.jobs.a.worker", /isn't a key here/); @@ -415,3 +422,27 @@
415 422 has(ps, "out", /must be a folder under the project/); 426 + describe("a run job's step limit", () => { 427 + it("takes whole seconds up to the most a step may run, and keeps them on the job", () => { 428 + const file = ok(checkPipelines(one({ test: { run: "npm test", timeout: 600 }, lint: { run: "npx biome ci ." } }))); 429 + const jobs = file.pipelines[0]!.jobs; 430 + assert.equal(jobs.find((j) => j.name === "test")?.timeout, 600); 431 + assert.equal(jobs.find((j) => j.name === "lint")?.timeout, undefined, "no timeout: the default, unsaid"); 432 + ok(checkPipelines(one({ a: { run: "x", timeout: JOB_TIMEOUT_MAX } }))); 434 + it("refuses a limit that isn't whole seconds from 1 to the most, and one on a uses step", () => { 435 + for (const bad of [0, -5, 901, 2.5, "600", null]) 437 + problems(checkPipelines(one({ a: { run: "x", timeout: bad } }))), 438 + "pipelines.p.jobs.a.timeout", 439 + /whole seconds from 1 to 900/, 442 + problems(checkPipelines(one({ a: { uses: "notify", to: "x", timeout: 600 } }))), 443 + "pipelines.p.jobs.a.timeout", 444 + /a uses step runs on the server/, 446 + assert.equal(JOB_TIMEOUT_DEFAULT, 300);