Skip to content

abso-core

Public

abso is version control for agents: the client, the engine and a server you can run on your own Cloudflare account.

Check passed

Versions 0 to 1

Compare

+88 −0 in 1 place
new file, 88 lines
1+// Which pipelines an event starts, and their jobs in waves (abso issue 176).
2+
3+import assert from "node:assert/strict";
4+import { describe, it } from "node:test";
5+import { type PipelineFile, readPipelineFile } from "../pipeline.ts";
6+import { plan, waves } from "../plan.ts";
7+
8+const FILE = `pipelines:
9+ ci:
10+ on: [publish, draft]
11+ jobs:
12+ setup: { run: npm ci }
13+ lint: { needs: [setup], run: npx biome ci . }
14+ test: { needs: [setup], run: npm test }
15+ bundle: { needs: [lint, test], run: npm run build, keep: ["dist/**"] }
16+ required: [lint, test]
17+ release:
18+ on: [green, hand]
19+ only: shared
20+ jobs:
21+ site: { uses: deploy, from: ci.bundle, worker: w, secrets: [CLOUDFLARE_API_TOKEN] }
22+ tell: { needs: [site], uses: notify, to: [issue] }
23+ nightly:
24+ on: [{ every: "day 06:00 UTC" }]
25+ jobs:
26+ drill: { run: node ops/restore-drill.ts }
27+`;
28+const read = (text: string): PipelineFile => {
29+ const c = readPipelineFile(text, "abso.yml");
30+ assert.ok(c.ok, c.ok ? "" : JSON.stringify(c.problems));
31+ return c.file;
32+};
33+const file = read(FILE);
34+const started = (p: ReturnType<typeof plan>) => p.start.map((s) => s.name);
36+describe("which pipelines an event starts", () => {
37+ it("a publish to shared starts ci, in waves that can run side by side", () => {
38+ const p = plan(file, { kind: "publish", space: "shared" });
39+ assert.deepEqual(started(p), ["ci"]);
40+ assert.deepEqual(p.start[0]!.waves, [["setup"], ["lint", "test"], ["bundle"]]);
41+ assert.deepEqual(p.start[0]!.required, ["lint", "test"]);
42+ assert.deepEqual(p.skip, [
43+ { name: "release", why: "doesn't run on publish" },
44+ { name: "nightly", why: "doesn't run on publish" },
45+ ]);
46+ });
48+ it("green on shared starts release; green on a named draft doesn't, since release is only shared", () => {
49+ assert.deepEqual(started(plan(file, { kind: "green", space: "shared" })), ["release"]);
50+ const p = plan(file, { kind: "green", space: "rename-59" });
51+ assert.deepEqual(started(p), []);
52+ assert.deepEqual(
53+ p.skip.find((s) => s.name === "release"),
54+ { name: "release", why: "runs only for shared, not rename-59" },
55+ );
56+ });
58+ it("by hand starts only the pipeline named, and only if it runs by hand", () => {
59+ assert.deepEqual(started(plan(file, { kind: "hand", pipeline: "release", space: "shared" })), ["release"]);
60+ const ci = plan(file, { kind: "hand", pipeline: "ci", space: "shared" });
61+ assert.deepEqual(started(ci), []);
62+ assert.deepEqual(
63+ ci.skip.find((s) => s.name === "ci"),
64+ { name: "ci", why: "doesn't run on hand" },
65+ );
66+ });
68+ it("a schedule starts the pipeline with that schedule, on shared", () => {
69+ assert.deepEqual(started(plan(file, { kind: "schedule", every: "day 06:00 UTC" })), ["nightly"]);
70+ assert.deepEqual(started(plan(file, { kind: "schedule", every: "hour" })), []);
71+ });
73+ it("a draft never starts a pipeline holding secrets, even if the file said so", () => {
74+ const unchecked: PipelineFile = {
75+ defaults: {},
76+ pipelines: [{ ...file.pipelines[1]!, on: ["draft"], only: undefined } as never],
77+ };
78+ const p = plan(unchecked, { kind: "draft", space: "shared" });
79+ assert.deepEqual(p.start, []);
80+ assert.match(p.skip[0]!.why, /holds secrets, and a draft runs unpublished code/);
81+ });
83+ it("waves stop on jobs that wait on each other rather than loop", () => {
84+ const job = (name: string, needs: string[]) =>
85+ ({ name, needs, keep: [], cache: [], secrets: [], with: {} }) as never;
86+ assert.throws(() => waves([job("a", ["b"]), job("b", ["a"])]), /jobs a, b wait on each other/);
87+ });
88+});
MCP
compare on this site's /mcp
CLI
abso diff 0 1 src/pipeline/test/plan.test.ts --json
JSON
/christopher/abso-core/compare/0..1?file=src%2Fpipeline%2Ftest%2Fplan.test.ts&format=json