@intentius/chant 0.124.56 → 0.124.58
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ci-audit/index.d.ts.map +1 -1
- package/dist/ci-audit/index.js +1 -2
- package/dist/ci-product-words.d.ts +47 -2
- package/dist/ci-product-words.d.ts.map +1 -1
- package/dist/ci-product-words.js +59 -1
- package/dist/ci-product.d.ts +26 -2
- package/dist/ci-product.d.ts.map +1 -1
- package/dist/ci-product.js +30 -7
- package/dist/cli/commands/init.d.ts +2 -0
- package/dist/cli/commands/init.d.ts.map +1 -1
- package/dist/cli/commands/init.js +1 -1
- package/dist/cli/handlers/build.d.ts.map +1 -1
- package/dist/cli/handlers/build.js +5 -1
- package/dist/cli/handlers/init.d.ts.map +1 -1
- package/dist/cli/handlers/init.js +16 -0
- package/dist/cli/handlers/lifecycle.d.ts.map +1 -1
- package/dist/cli/handlers/lifecycle.js +14 -0
- package/dist/cli/handlers/pr.d.ts.map +1 -1
- package/dist/cli/handlers/pr.js +90 -35
- package/dist/cli/handlers/serve.d.ts.map +1 -1
- package/dist/cli/handlers/serve.js +9 -0
- package/dist/cli/main.d.ts.map +1 -1
- package/dist/cli/main.js +6 -2
- package/dist/cli/mcp/product-tools.d.ts +40 -7
- package/dist/cli/mcp/product-tools.d.ts.map +1 -1
- package/dist/cli/mcp/product-tools.js +59 -15
- package/dist/cli/mcp/read-only.d.ts +2 -1
- package/dist/cli/mcp/read-only.d.ts.map +1 -1
- package/dist/cli/mcp/read-only.js +2 -1
- package/dist/cli/mcp/server.d.ts +11 -0
- package/dist/cli/mcp/server.d.ts.map +1 -1
- package/dist/cli/mcp/server.js +15 -3
- package/dist/cli/mcp-config.d.ts +4 -1
- package/dist/cli/mcp-config.d.ts.map +1 -1
- package/dist/cli/mcp-config.js +6 -2
- package/dist/cli/parse-args.d.ts.map +1 -1
- package/dist/cli/parse-args.js +9 -0
- package/dist/cli/registry.d.ts +8 -0
- package/dist/cli/registry.d.ts.map +1 -1
- package/dist/components/auto-release.d.ts +5 -2
- package/dist/components/auto-release.d.ts.map +1 -1
- package/dist/components/auto-release.js +9 -4
- package/dist/components/capability.d.ts +10 -0
- package/dist/components/capability.d.ts.map +1 -1
- package/dist/components/deploy-units.d.ts +12 -0
- package/dist/components/deploy-units.d.ts.map +1 -1
- package/dist/components/deploy-units.js +20 -1
- package/dist/components/pr-pipeline.d.ts +64 -2
- package/dist/components/pr-pipeline.d.ts.map +1 -1
- package/dist/components/pr-pipeline.js +66 -5
- package/dist/components/product-pipeline.d.ts +18 -1
- package/dist/components/product-pipeline.d.ts.map +1 -1
- package/dist/components/product-pipeline.js +8 -2
- package/dist/components/row-lease.d.ts +22 -1
- package/dist/components/row-lease.d.ts.map +1 -1
- package/dist/components/row-lease.js +32 -6
- package/dist/e2e-harness/driver.d.ts.map +1 -1
- package/dist/e2e-harness/driver.js +97 -0
- package/dist/e2e-harness/forgejo.d.ts +5 -1
- package/dist/e2e-harness/forgejo.d.ts.map +1 -1
- package/dist/e2e-harness/forgejo.js +35 -0
- package/dist/e2e-harness/index.d.ts +7 -0
- package/dist/e2e-harness/index.d.ts.map +1 -1
- package/dist/e2e-harness/index.js +11 -2
- package/dist/e2e-harness/ports.d.ts +31 -0
- package/dist/e2e-harness/ports.d.ts.map +1 -1
- package/dist/e2e-harness/scenario.d.ts.map +1 -1
- package/dist/e2e-harness/scenario.js +9 -5
- package/dist/e2e-harness/schemas/e2e-scenario.schema.json +43 -3
- package/dist/e2e-harness/schemas/index.d.ts +22 -1
- package/dist/e2e-harness/schemas/index.d.ts.map +1 -1
- package/dist/e2e-harness/schemas/index.js +1 -1
- package/dist/e2e-harness/steps.d.ts.map +1 -1
- package/dist/e2e-harness/steps.js +4 -0
- package/dist/lexicon.d.ts +9 -0
- package/dist/lexicon.d.ts.map +1 -1
- package/dist/lifecycle/git.d.ts +39 -3
- package/dist/lifecycle/git.d.ts.map +1 -1
- package/dist/lifecycle/git.js +223 -15
- package/dist/lifecycle/lock-rows.d.ts +23 -0
- package/dist/lifecycle/lock-rows.d.ts.map +1 -1
- package/dist/lifecycle/lock-rows.js +47 -8
- package/dist/lifecycle/resource-lock.d.ts +70 -0
- package/dist/lifecycle/resource-lock.d.ts.map +1 -1
- package/dist/lifecycle/resource-lock.js +241 -5
- package/dist/mcp/types.d.ts +9 -0
- package/dist/mcp/types.d.ts.map +1 -1
- package/dist/op/gate.js +21 -4
- package/dist/op/op-waves-release-port.js +1 -1
- package/dist/op/op-waves-release.d.ts +2 -1
- package/dist/op/op-waves-release.d.ts.map +1 -1
- package/dist/op/op-waves-run.d.ts +8 -0
- package/dist/op/op-waves-run.d.ts.map +1 -1
- package/dist/op/op-waves-run.js +101 -29
- package/dist/op/op-waves.d.ts +18 -0
- package/dist/op/op-waves.d.ts.map +1 -1
- package/dist/op/op-waves.js +16 -0
- package/dist/pr-loop.d.ts.map +1 -1
- package/dist/pr-loop.js +1 -2
- package/dist/release-floors.d.ts +1 -1
- package/dist/release-floors.js +1 -1
- package/dist/template-request/index.d.ts +9 -0
- package/dist/template-request/index.d.ts.map +1 -0
- package/dist/template-request/index.js +8 -0
- package/dist/template-request/request-body.d.ts +21 -0
- package/dist/template-request/request-body.d.ts.map +1 -0
- package/dist/template-request/request-body.js +86 -0
- package/dist/template-request/template-request.d.ts +100 -0
- package/dist/template-request/template-request.d.ts.map +1 -0
- package/dist/template-request/template-request.js +150 -0
- package/dist/template-request/template-request.schema.json +100 -0
- package/dist/template-request/template-spec.d.ts +83 -0
- package/dist/template-request/template-spec.d.ts.map +1 -0
- package/dist/template-request/template-spec.js +146 -0
- package/dist/template-request/template.schema.json +114 -0
- package/dist/template-request/validate.d.ts +4 -0
- package/dist/template-request/validate.d.ts.map +1 -0
- package/dist/template-request/validate.js +21 -0
- package/dist/wave-runtime.mjs +310 -300
- package/package.json +8 -1
- package/src/ci-audit/index.ts +1 -2
- package/src/ci-product-words.test.ts +23 -0
- package/src/ci-product-words.ts +68 -3
- package/src/ci-product.ts +36 -6
- package/src/cli/commands/init.ts +3 -1
- package/src/cli/handlers/build.ts +5 -1
- package/src/cli/handlers/init.ts +18 -0
- package/src/cli/handlers/lifecycle.ts +13 -0
- package/src/cli/handlers/pr-before-merge.test.ts +1 -1
- package/src/cli/handlers/pr-deploy-inputs.test.ts +1 -1
- package/src/cli/handlers/pr-endpoint.test.ts +1 -1
- package/src/cli/handlers/pr-green.test.ts +1 -1
- package/src/cli/handlers/pr-plan-comment-targets.test.ts +1 -1
- package/src/cli/handlers/pr-plan-flags.test.ts +1 -1
- package/src/cli/handlers/pr-plan-targets.test.ts +1 -1
- package/src/cli/handlers/pr-record.test.ts +34 -2
- package/src/cli/handlers/pr-waves-blocked.test.ts +1 -1
- package/src/cli/handlers/pr-waves.test.ts +1 -1
- package/src/cli/handlers/pr.test.ts +1 -1
- package/src/cli/handlers/pr.ts +86 -31
- package/src/cli/handlers/serve.ts +9 -0
- package/src/cli/main.ts +6 -2
- package/src/cli/mcp/product-tools.test.ts +57 -1
- package/src/cli/mcp/product-tools.ts +67 -15
- package/src/cli/mcp/read-only.ts +2 -1
- package/src/cli/mcp/server.ts +20 -5
- package/src/cli/mcp-config.test.ts +52 -2
- package/src/cli/mcp-config.ts +6 -3
- package/src/cli/parse-args.ts +7 -0
- package/src/cli/registry.ts +8 -0
- package/src/components/auto-release.test.ts +4 -2
- package/src/components/auto-release.ts +9 -5
- package/src/components/capability.ts +10 -0
- package/src/components/deploy-units.test.ts +18 -1
- package/src/components/deploy-units.ts +26 -1
- package/src/components/pr-pipeline.ts +99 -5
- package/src/components/product-actions.test.ts +76 -0
- package/src/components/product-pipeline.ts +21 -2
- package/src/components/row-lease.test.ts +61 -1
- package/src/components/row-lease.ts +48 -7
- package/src/e2e-harness/driver.test.ts +163 -0
- package/src/e2e-harness/driver.ts +86 -1
- package/src/e2e-harness/forgejo.ts +42 -1
- package/src/e2e-harness/index.ts +12 -2
- package/src/e2e-harness/ports.ts +33 -0
- package/src/e2e-harness/scenario.ts +8 -6
- package/src/e2e-harness/schemas/README.md +11 -2
- package/src/e2e-harness/schemas/e2e-scenario.schema.json +43 -3
- package/src/e2e-harness/schemas/index.ts +5 -1
- package/src/e2e-harness/schemas.test.ts +44 -1
- package/src/e2e-harness/steps.ts +4 -0
- package/src/lexicon.ts +9 -0
- package/src/lifecycle/git.test.ts +155 -0
- package/src/lifecycle/git.ts +213 -17
- package/src/lifecycle/lock-rows.test.ts +6 -1
- package/src/lifecycle/lock-rows.ts +58 -7
- package/src/lifecycle/resource-lock-wait.test.ts +292 -0
- package/src/lifecycle/resource-lock.ts +261 -7
- package/src/mcp/types.ts +9 -0
- package/src/op/gate.test.ts +7 -5
- package/src/op/gate.ts +20 -4
- package/src/op/op-waves-after-plan.test.ts +1 -2
- package/src/op/op-waves-ledger-lock.test.ts +208 -0
- package/src/op/op-waves-release-port.ts +1 -1
- package/src/op/op-waves-release.ts +1 -1
- package/src/op/op-waves-run.ts +104 -29
- package/src/op/op-waves.ts +18 -0
- package/src/pr-loop-bundle.test.ts +0 -2
- package/src/pr-loop.ts +1 -2
- package/src/release-floors.ts +1 -1
- package/src/template-request/__fixtures__/request-body.md +41 -0
- package/src/template-request/index.ts +8 -0
- package/src/template-request/request-body.ts +91 -0
- package/src/template-request/template-request.schema.json +100 -0
- package/src/template-request/template-request.test.ts +316 -0
- package/src/template-request/template-request.ts +235 -0
- package/src/template-request/template-spec.ts +176 -0
- package/src/template-request/template.schema.json +114 -0
- package/src/template-request/validate.ts +28 -0
|
@@ -15,6 +15,13 @@
|
|
|
15
15
|
* - A held row fails the step, or every member of the group, with a record
|
|
16
16
|
* marked `held`, so the command exits 5 (`CHANT_EXIT.held`) and nothing of
|
|
17
17
|
* that step applied.
|
|
18
|
+
* - A step on the `target` grain whose lexicon names its target's row
|
|
19
|
+
* (`targetLockRow`: a stock Pulumi stack, a Terraform root), or on the
|
|
20
|
+
* `repo` grain, waits for that row in the ledger's queue, oldest commit
|
|
21
|
+
* first, up to `CHANT_LOCK_WAIT` seconds (ruling for ci-products
|
|
22
|
+
* 2026-10-28, "Ledger lock"), and at the deadline fails with
|
|
23
|
+
* {@link LockWaitTimeoutError}, held, exit 5. A step on the resource grain
|
|
24
|
+
* never waits.
|
|
18
25
|
*
|
|
19
26
|
* The port ({@link ledgerRowLease}) writes `_locks/rows/<gate>.json` through
|
|
20
27
|
* ../lifecycle/resource-lock.ts with one holder for the whole run, and
|
|
@@ -22,7 +29,7 @@
|
|
|
22
29
|
* change one object let go of its row only once both have ended.
|
|
23
30
|
*/
|
|
24
31
|
import type { LockGrain, LockRow } from "../lifecycle/lock-rows";
|
|
25
|
-
import { lockGrainBeforePlan, resolvePlannedLock, sortedLockRows } from "../lifecycle/lock-rows";
|
|
32
|
+
import { lockGrainBeforePlan, queueRowsOf, resolvePlannedLock, sortedLockRows } from "../lifecycle/lock-rows";
|
|
26
33
|
import type { LockLiveness, LockRowHolder } from "../lifecycle/resource-lock";
|
|
27
34
|
import type { Capability, CapabilityPlan, DeployContext } from "./capability";
|
|
28
35
|
|
|
@@ -38,8 +45,10 @@ export interface RowLeasePort {
|
|
|
38
45
|
* Lease `rows` for `label` (a component, or a group's components), all or
|
|
39
46
|
* nothing. Throws {@link LockRowsHeldError} when another live run holds
|
|
40
47
|
* one, and any other error when the rows file cannot be read or written.
|
|
48
|
+
* With `wait`, waits in the queue for them instead, and throws
|
|
49
|
+
* {@link LockWaitTimeoutError} at the deadline.
|
|
41
50
|
*/
|
|
42
|
-
take(rows: readonly LockRow[], label: string): Promise<RowLease>;
|
|
51
|
+
take(rows: readonly LockRow[], label: string, opts?: { wait?: boolean }): Promise<RowLease>;
|
|
43
52
|
}
|
|
44
53
|
|
|
45
54
|
/** Another live run holds a row this apply changes (#4594), so nothing of it applied. Exit 5. */
|
|
@@ -51,6 +60,14 @@ export class LockRowsHeldError extends Error {
|
|
|
51
60
|
}
|
|
52
61
|
}
|
|
53
62
|
|
|
63
|
+
/** A wait for a target's row reached its deadline (ruling for ci-products 2026-10-28): nothing of the step applied. Exit 5, as a held row is. */
|
|
64
|
+
export class LockWaitTimeoutError extends LockRowsHeldError {
|
|
65
|
+
constructor(message: string) {
|
|
66
|
+
super(message);
|
|
67
|
+
this.name = "LockWaitTimeoutError";
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
54
71
|
/** Whether `err` is a held row ({@link LockRowsHeldError}), by its mark, so a copy from another bundle counts too. */
|
|
55
72
|
export function isLockRowsHeldError(err: unknown): err is LockRowsHeldError {
|
|
56
73
|
return typeof err === "object" && err !== null && (err as { lockRowsHeld?: unknown }).lockRowsHeld === true;
|
|
@@ -66,6 +83,12 @@ export interface LedgerRowLeaseOptions {
|
|
|
66
83
|
holder?: LockRowHolder;
|
|
67
84
|
/** Where the lease's info lines go. Default stderr. */
|
|
68
85
|
log?: (line: string) => void;
|
|
86
|
+
/** How long a waiting take waits, in seconds. Default `CHANT_LOCK_WAIT`. */
|
|
87
|
+
waitSeconds?: number;
|
|
88
|
+
/** How often a waiting take reads the rows file again, in ms. Default `CHANT_LOCK_POLL` seconds, else 10 s. */
|
|
89
|
+
pollMs?: number;
|
|
90
|
+
/** The commit time that orders this run in the queue. Default: HEAD's in `cwd`. */
|
|
91
|
+
commitAt?: string;
|
|
69
92
|
}
|
|
70
93
|
|
|
71
94
|
/**
|
|
@@ -80,14 +103,26 @@ export function ledgerRowLease(gate: string, opts: LedgerRowLeaseOptions = {}):
|
|
|
80
103
|
let holder: LockRowHolder | undefined = opts.holder;
|
|
81
104
|
const lock = () => import("../lifecycle/resource-lock");
|
|
82
105
|
return {
|
|
83
|
-
async take(rows, label) {
|
|
106
|
+
async take(rows, label, takeOpts) {
|
|
84
107
|
const wanted = sortedLockRows(rows);
|
|
85
108
|
if (wanted.length === 0) return NO_LEASE;
|
|
86
|
-
const { leaseLockRows, lockRowHolder, releaseLockRows } = await lock();
|
|
109
|
+
const { commitTimeOf, leaseLockRows, lockPollMs, lockRowHolder, lockWaitSeconds, releaseLockRows } = await lock();
|
|
87
110
|
holder ??= lockRowHolder(process.env);
|
|
88
111
|
const fresh = wanted.filter((r) => (counts.get(r.key) ?? 0) === 0);
|
|
89
112
|
if (fresh.length > 0) {
|
|
90
|
-
const
|
|
113
|
+
const commitAt = takeOpts?.wait ? (opts.commitAt ?? (await commitTimeOf(holder.sha ?? "HEAD", opts.cwd))) : undefined;
|
|
114
|
+
const wait = takeOpts?.wait
|
|
115
|
+
? {
|
|
116
|
+
wait: {
|
|
117
|
+
deadline: Date.now() + (opts.waitSeconds ?? lockWaitSeconds(process.env)) * 1000,
|
|
118
|
+
pollMs: opts.pollMs ?? lockPollMs(process.env),
|
|
119
|
+
log: (line: string) => log(`${label}: ${line}`),
|
|
120
|
+
...(commitAt ? { commitAt } : {}),
|
|
121
|
+
},
|
|
122
|
+
}
|
|
123
|
+
: {};
|
|
124
|
+
const leased = await leaseLockRows(gate, fresh, { holder, ...(opts.cwd ? { cwd: opts.cwd } : {}), ...(opts.alive ? { alive: opts.alive } : {}), ...wait });
|
|
125
|
+
if (!leased.ok && leased.timedOut) throw new LockWaitTimeoutError(`${label}: LockWaitTimeoutError: ${leased.message}, so nothing of it was applied.`);
|
|
91
126
|
if (!leased.ok) {
|
|
92
127
|
throw new LockRowsHeldError(
|
|
93
128
|
`${label}: ${leased.message}, so nothing of it was applied. Apply again once that run ends; a run that is gone, or whose lease is older than CHANT_LOCK_STALE seconds, is taken over.`,
|
|
@@ -136,8 +171,14 @@ export async function leaseCapabilityStep(
|
|
|
136
171
|
input: unknown,
|
|
137
172
|
): Promise<{ ctx: DeployContext; lease: RowLease }> {
|
|
138
173
|
const port = ctx.rowLease;
|
|
139
|
-
if (!port
|
|
140
|
-
|
|
174
|
+
if (!port) return { ctx, lease: NO_LEASE };
|
|
175
|
+
const grain = await lockGrainBeforePlan(capability, input, ctx.lockGrain);
|
|
176
|
+
if (grain !== "resource") {
|
|
177
|
+
// The ruling for ci-products (2026-10-28): the target's row (or the repo row), waited for, whether or not a plan was handed in.
|
|
178
|
+
const queue = await queueRowsOf(capability, input, ctx.component, grain);
|
|
179
|
+
return { ctx, lease: queue.length > 0 ? await port.take(queue, ctx.component, { wait: true }) : NO_LEASE };
|
|
180
|
+
}
|
|
181
|
+
if (ctx.plans !== undefined || !capability.plan) return { ctx, lease: NO_LEASE };
|
|
141
182
|
const planned: CapabilityPlan = await capability.plan(ctx, input as never);
|
|
142
183
|
const lock = await resolvePlannedLock(capability, input, planned, ctx.lockGrain);
|
|
143
184
|
const plans = planned.artifact !== undefined ? { [planned.member]: planned.artifact } : undefined;
|
|
@@ -302,3 +302,166 @@ describe("the e2e harness's driver", () => {
|
|
|
302
302
|
expect(run.reason).toBe("change-merge: Forgejo answered 500");
|
|
303
303
|
});
|
|
304
304
|
});
|
|
305
|
+
|
|
306
|
+
/**
|
|
307
|
+
* A product's pull request (chant#4650): the out-of-band command stands in
|
|
308
|
+
* for `terragucci request`, which pushes a branch and opens the pull request
|
|
309
|
+
* itself. The pipeline plans it as it would any other.
|
|
310
|
+
*/
|
|
311
|
+
function productWorld(o: { neverOpens?: boolean; files?: string[]; staleOpen?: boolean } = {}) {
|
|
312
|
+
const w = world();
|
|
313
|
+
const pulls: Array<{ number: number; title: string; branch: string; head: string; files: string[]; open: boolean }> = [];
|
|
314
|
+
const posted: Array<{ pull: number; body: string; as: string }> = [];
|
|
315
|
+
let next = 100;
|
|
316
|
+
const make = async (branch: string, title: string) => {
|
|
317
|
+
const number = next++;
|
|
318
|
+
const head = `c${String(number).padStart(39, "0")}`;
|
|
319
|
+
pulls.push({ number, title, branch, head, files: o.files ?? ["apps/orders/main.tf"], open: true });
|
|
320
|
+
await w.bucket.put(
|
|
321
|
+
reportObjectKey(PREFIX, number, head, "plan"),
|
|
322
|
+
JSON.stringify({ stage: "plan", pr: number, head, op: `pr-${number}`, gate: "pr-apply", digest: `jcs1-sha256:${number}`, status: "planned", selection: { waves: [] }, members: [] }),
|
|
323
|
+
"application/json",
|
|
324
|
+
);
|
|
325
|
+
};
|
|
326
|
+
if (o.staleOpen) void make("request/bucket/orders", "Request bucket orders");
|
|
327
|
+
const forge: DriverPorts["forge"] = {
|
|
328
|
+
...w.ports.forge,
|
|
329
|
+
openPulls: async () => pulls.filter((p) => p.open).map((p) => p.number),
|
|
330
|
+
findPull: async (branch) => {
|
|
331
|
+
const p = pulls.filter((x) => x.open && x.branch === branch).sort((a, b) => a.number - b.number)[0];
|
|
332
|
+
return p && { number: p.number, title: p.title, branch: p.branch, head: p.head };
|
|
333
|
+
},
|
|
334
|
+
pullInfo: async (n) => {
|
|
335
|
+
const p = pulls.find((x) => x.number === n);
|
|
336
|
+
return p && { number: p.number, title: p.title, branch: p.branch, head: p.head };
|
|
337
|
+
},
|
|
338
|
+
changedFiles: async (n) => pulls.find((x) => x.number === n)?.files ?? [],
|
|
339
|
+
postComment: async (pull, body, as) => void posted.push({ pull, body, as }),
|
|
340
|
+
};
|
|
341
|
+
const outOfBand = {
|
|
342
|
+
run: async (command: string[]) => {
|
|
343
|
+
if (!o.neverOpens) await make(command.at(-1)!, "Request bucket orders");
|
|
344
|
+
return 0;
|
|
345
|
+
},
|
|
346
|
+
};
|
|
347
|
+
return { ...w, pulls, posted, ports: { ...w.ports, forge, outOfBand } as DriverPorts };
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
function requestScenario(over: Partial<Scenario> = {}): Scenario {
|
|
351
|
+
return fanOut({
|
|
352
|
+
id: "tg-template-app",
|
|
353
|
+
product: "terragucci",
|
|
354
|
+
claim: "template/app-request",
|
|
355
|
+
steps: [
|
|
356
|
+
{ id: "request", do: "out-of-band", command: ["terragucci", "request", "bucket", "orders", "request/bucket/orders"], expect: [{ exit: 0 }] },
|
|
357
|
+
{ id: "pr", do: "await-pull", branch: "request/bucket/orders", title: "orders" },
|
|
358
|
+
{ id: "pr-plan", do: "plan", pull: "pr", expect: [{ report: { status: "planned" } }] },
|
|
359
|
+
],
|
|
360
|
+
...over,
|
|
361
|
+
});
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
describe("a pull request a product opened", () => {
|
|
365
|
+
test("await-pull binds the product's pull request and its head, and plan reads the report there", async () => {
|
|
366
|
+
const w = productWorld();
|
|
367
|
+
const s = requestScenario();
|
|
368
|
+
expect(lintScenario(s)).toEqual([]);
|
|
369
|
+
const run = await runArm(s, "plain", w.ports, OPTS);
|
|
370
|
+
expect(run.outcome).toBe("held");
|
|
371
|
+
expect(verdictsOf(run, run).plain).toBe("pass");
|
|
372
|
+
expect(run.steps.map((x) => [x.id, x.pull, x.commit])).toEqual([
|
|
373
|
+
["request", undefined, undefined],
|
|
374
|
+
["pr", 100, `c${"100".padStart(39, "0")}`],
|
|
375
|
+
["pr-plan", 100, `c${"100".padStart(39, "0")}`],
|
|
376
|
+
]);
|
|
377
|
+
});
|
|
378
|
+
|
|
379
|
+
test("no pull request ever opened stalls at the await-pull limit, and is not a fail of the outcome", async () => {
|
|
380
|
+
const w = productWorld({ neverOpens: true });
|
|
381
|
+
const start = w.clock.t;
|
|
382
|
+
const run = await runArm(requestScenario(), "plain", w.ports, OPTS);
|
|
383
|
+
expect(run.outcome).toBe("stalled");
|
|
384
|
+
expect(run.reason).toBe("pr: no open pull request from request/bucket/orders within 300s");
|
|
385
|
+
expect(run.steps.at(-1)).toMatchObject({ id: "pr", stopped: { outcome: "stalled" } });
|
|
386
|
+
expect(w.clock.t - start).toBeGreaterThanOrEqual(300_000);
|
|
387
|
+
});
|
|
388
|
+
|
|
389
|
+
test("the BREAK run waits for the same branch, and never binds a pull request open before it started", async () => {
|
|
390
|
+
const fresh = productWorld();
|
|
391
|
+
const brk = await runArm(requestScenario(), "break", fresh.ports, OPTS);
|
|
392
|
+
expect(brk.steps.find((x) => x.id === "pr")?.pull).toBe(100);
|
|
393
|
+
|
|
394
|
+
const stale = productWorld({ staleOpen: true, neverOpens: true });
|
|
395
|
+
const run = await runArm(requestScenario(), "break", stale.ports, OPTS);
|
|
396
|
+
expect(run.outcome).toBe("stalled");
|
|
397
|
+
expect(run.reason).toBe("pr: pull request 100 from request/bucket/orders was open before the run started, and no new one came within 300s");
|
|
398
|
+
});
|
|
399
|
+
|
|
400
|
+
test("comment posts the exact body on the bound pull request, as the author unless the step says", async () => {
|
|
401
|
+
const w = productWorld();
|
|
402
|
+
const s = requestScenario();
|
|
403
|
+
s.steps.push(
|
|
404
|
+
{ id: "invoke", do: "comment", pull: "pr", body: "/terragucci action orders rotate" },
|
|
405
|
+
{ id: "again", do: "comment", pull: "pr", body: "/terragucci action orders rotate", as: "reviewer", expect: [{ pull: { title: "orders" } }] },
|
|
406
|
+
);
|
|
407
|
+
expect(lintScenario(s)).toEqual([]);
|
|
408
|
+
const run = await runArm(s, "plain", w.ports, OPTS);
|
|
409
|
+
expect(run.outcome).toBe("held");
|
|
410
|
+
expect(w.posted).toEqual([
|
|
411
|
+
{ pull: 100, body: "/terragucci action orders rotate", as: "author" },
|
|
412
|
+
{ pull: 100, body: "/terragucci action orders rotate", as: "reviewer" },
|
|
413
|
+
]);
|
|
414
|
+
});
|
|
415
|
+
|
|
416
|
+
test("a pull outcome holds for exactly the files named, and names the extra path when there is one", async () => {
|
|
417
|
+
const outcome = { pull: { files: ["apps/orders/main.tf"], only: true } };
|
|
418
|
+
const s = () => {
|
|
419
|
+
const x = requestScenario();
|
|
420
|
+
(x.steps[1] as { expect?: unknown[] }).expect = [outcome];
|
|
421
|
+
return x;
|
|
422
|
+
};
|
|
423
|
+
expect(lintScenario(s())).toEqual([]);
|
|
424
|
+
expect((await runArm(s(), "plain", productWorld().ports, OPTS)).outcome).toBe("held");
|
|
425
|
+
|
|
426
|
+
const run = await runArm(s(), "plain", productWorld({ files: ["apps/orders/main.tf", "apps/other/main.tf"] }).ports, OPTS);
|
|
427
|
+
expect(run.outcome).toBe("broke");
|
|
428
|
+
expect(run.reason).toBe("pr: pull request 100 also changes apps/other/main.tf beyond the files named");
|
|
429
|
+
|
|
430
|
+
const missing = await runArm(s(), "plain", productWorld({ files: ["apps/other/main.tf"] }).ports, OPTS);
|
|
431
|
+
expect(missing.reason).toBe("pr: pull request 100 does not change apps/orders/main.tf");
|
|
432
|
+
|
|
433
|
+
const titled = requestScenario();
|
|
434
|
+
(titled.steps[1] as { expect?: unknown[] }).expect = [{ pull: { title: "payments" } }];
|
|
435
|
+
expect((await runArm(titled, "plain", productWorld().ports, OPTS)).reason).toBe('pr: pull request 100 is titled "Request bucket orders", which does not hold "payments"');
|
|
436
|
+
});
|
|
437
|
+
|
|
438
|
+
test("a gated outcome reads the gated requests asked since the run started: gated, then ok or failed", async () => {
|
|
439
|
+
const w = productWorld();
|
|
440
|
+
const at = (ms: number) => new Date(Date.parse("2026-10-28T10:00:00Z") + ms).toISOString();
|
|
441
|
+
const req = (ts: string, result?: "applied" | "failed") =>
|
|
442
|
+
({
|
|
443
|
+
op: "tf-action",
|
|
444
|
+
gate: "tf-action",
|
|
445
|
+
digest: `d-${ts}`,
|
|
446
|
+
request: {},
|
|
447
|
+
pending: { timestamp: ts },
|
|
448
|
+
approvals: [],
|
|
449
|
+
...(result ? { finished: { result } } : {}),
|
|
450
|
+
}) as unknown as import("../lifecycle/gated-request").GatedRequestRead;
|
|
451
|
+
const asked = [req(at(-60_000), "applied"), req(at(1000)), req(at(2000), "applied"), req(at(3000), "failed")];
|
|
452
|
+
const ports: DriverPorts = { ...w.ports, ledger: { runs: async () => [], gatedRequests: async (op) => (op === "tf-action" ? asked : []) } };
|
|
453
|
+
const s = (expect: Scenario["steps"][number]["expect"]) => fanOut({ steps: [{ id: "x", do: "out-of-band", command: ["true"], expect }] });
|
|
454
|
+
|
|
455
|
+
expect((await runArm(s([{ gated: { op: "tf-action", status: "gated", count: 1 } }, { gated: { op: "tf-action", status: "ok", count: 1 } }, { gated: { op: "tf-action", status: "failed" } }, { gated: { op: "tf-action", count: 3 } }]), "plain", ports, OPTS)).outcome).toBe("held");
|
|
456
|
+
expect((await runArm(s([{ gated: { op: "pulumi-stack-ops", status: "ok" } }]), "plain", ports, OPTS)).reason).toBe("x: no gated pulumi-stack-ops request ok on the ledger since the run started");
|
|
457
|
+
expect((await runArm(s([{ gated: { op: "tf-action", status: "ok", count: 2 } }]), "plain", ports, OPTS)).reason).toBe("x: 1 gated tf-action requests ok on the ledger, not 2");
|
|
458
|
+
expect((await runArm(s([{ gated: { op: "tf-action" } }]), "plain", w.ports, OPTS)).reason).toBe("x: a gated outcome needs the ledger's gated requests");
|
|
459
|
+
});
|
|
460
|
+
|
|
461
|
+
test("await-pull and comment stall without the forge reads they need", async () => {
|
|
462
|
+
const w = world();
|
|
463
|
+
const s = requestScenario();
|
|
464
|
+
const run = await runArm(s, "plain", { ...w.ports, outOfBand: { run: async () => 0 } }, OPTS);
|
|
465
|
+
expect(run.reason).toBe("pr: an await-pull step needs the forge's findPull");
|
|
466
|
+
});
|
|
467
|
+
});
|
|
@@ -5,14 +5,19 @@
|
|
|
5
5
|
* the BREAK run, and checks each step's outcomes against chant's own reports
|
|
6
6
|
* and run ledger, never the runner's status or logs.
|
|
7
7
|
*
|
|
8
|
+
* A pull request comes from the driver's own open step or from a product:
|
|
9
|
+
* an await-pull step waits for the one a product opened from its branch
|
|
10
|
+
* (chant#4650), and later steps name it as they name an open step's.
|
|
11
|
+
*
|
|
8
12
|
* A run ends one of three ways. Every outcome held: the plain run passes, and
|
|
9
13
|
* a BREAK run that ends so was missed. An outcome did not hold: the run stops
|
|
10
14
|
* there, the plain run fails, and the BREAK run was caught. A step did not
|
|
11
15
|
* finish (past its limit, or an error): the run stalled, which is neither.
|
|
12
16
|
*/
|
|
13
17
|
import { reportKey } from "../pr-report-url";
|
|
18
|
+
import type { GatedRequestRead } from "../lifecycle/gated-request";
|
|
14
19
|
import type { OpRunRecord } from "../op/runtime";
|
|
15
|
-
import type { Bucket, Chant, Clock, ForgeReads, Jobs, Ledger, Log, OutOfBand, PullForge } from "./ports";
|
|
20
|
+
import type { Bucket, Chant, Clock, ForgePull, ForgeReads, Jobs, Ledger, Log, OutOfBand, PullForge } from "./ports";
|
|
16
21
|
import { componentStatuses, reportObjectKey, splitReportUrl, waitForReport, type PrReportView, type ReportStage } from "./reports";
|
|
17
22
|
import type { BreakVerdict, PlainVerdict, Scenario, ScenarioOutcome, ScenarioStep, ScenarioStepKind } from "./schemas/index";
|
|
18
23
|
import { limitsFor } from "./steps";
|
|
@@ -75,6 +80,12 @@ interface Opened {
|
|
|
75
80
|
|
|
76
81
|
const iso = (ms: number) => new Date(ms).toISOString();
|
|
77
82
|
|
|
83
|
+
/** How a gated request stands: gated until a finished line names it, then ok or failed. */
|
|
84
|
+
function gatedStatus(r: GatedRequestRead): "gated" | "ok" | "failed" {
|
|
85
|
+
if (!r.finished) return "gated";
|
|
86
|
+
return r.finished.result === "applied" ? "ok" : "failed";
|
|
87
|
+
}
|
|
88
|
+
|
|
78
89
|
/** The check of one outcome, or null when it holds. */
|
|
79
90
|
async function checkOutcome(
|
|
80
91
|
o: ScenarioOutcome,
|
|
@@ -106,6 +117,36 @@ async function checkOutcome(
|
|
|
106
117
|
}
|
|
107
118
|
return matching.length > 0 ? null : `no ${o.ledger.op} run${o.ledger.status ? ` ${o.ledger.status}` : ""} on the ledger since the run started`;
|
|
108
119
|
}
|
|
120
|
+
if ("gated" in o) {
|
|
121
|
+
if (!p.ledger?.gatedRequests) throw new Stall("a gated outcome needs the ledger's gated requests");
|
|
122
|
+
const asked = (await p.ledger.gatedRequests(o.gated.op)).filter((r) => r.pending.timestamp >= ctx.since);
|
|
123
|
+
const matching = o.gated.status ? asked.filter((r) => gatedStatus(r) === o.gated.status) : asked;
|
|
124
|
+
const status = o.gated.status ? ` ${o.gated.status}` : "";
|
|
125
|
+
if (o.gated.count !== undefined) {
|
|
126
|
+
return matching.length === o.gated.count ? null : `${matching.length} gated ${o.gated.op} requests${status} on the ledger, not ${o.gated.count}`;
|
|
127
|
+
}
|
|
128
|
+
return matching.length > 0 ? null : `no gated ${o.gated.op} request${status} on the ledger since the run started`;
|
|
129
|
+
}
|
|
130
|
+
if ("pull" in o) {
|
|
131
|
+
if (ctx.pull === undefined) return "no pull request to read";
|
|
132
|
+
if (o.pull.title !== undefined) {
|
|
133
|
+
if (!p.forge.pullInfo) throw new Stall("a pull outcome with a title needs the forge's pull requests");
|
|
134
|
+
const info = await p.forge.pullInfo(ctx.pull);
|
|
135
|
+
if (!info) return `the forge does not know pull request ${ctx.pull}`;
|
|
136
|
+
if (!info.title.includes(o.pull.title)) return `pull request ${ctx.pull} is titled "${info.title}", which does not hold "${o.pull.title}"`;
|
|
137
|
+
}
|
|
138
|
+
if (o.pull.files !== undefined) {
|
|
139
|
+
if (!p.forge.changedFiles) throw new Stall("a pull outcome with files needs the forge's changed files");
|
|
140
|
+
const changed = await p.forge.changedFiles(ctx.pull);
|
|
141
|
+
const missing = o.pull.files.filter((f) => !changed.includes(f));
|
|
142
|
+
if (missing.length > 0) return `pull request ${ctx.pull} does not change ${missing.join(", ")}`;
|
|
143
|
+
if (o.pull.only) {
|
|
144
|
+
const extra = changed.filter((f) => !o.pull.files!.includes(f));
|
|
145
|
+
if (extra.length > 0) return `pull request ${ctx.pull} also changes ${extra.join(", ")} beyond the files named`;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
return null;
|
|
149
|
+
}
|
|
109
150
|
if ("comment" in o) {
|
|
110
151
|
if (!p.forge.comments) throw new Stall("a comment outcome needs the forge's comments");
|
|
111
152
|
if (ctx.pull === undefined) return "no pull request to read comments of";
|
|
@@ -175,10 +216,39 @@ export async function runArm(s: Scenario, arm: Arm, p: DriverPorts, opts: Driver
|
|
|
175
216
|
if (!o) throw new Stall(`no pull request from ${id}`);
|
|
176
217
|
return o;
|
|
177
218
|
};
|
|
219
|
+
// The pull requests open when the run started. await-pull never binds one
|
|
220
|
+
// of these, so the BREAK run cannot pick up the plain run's pull request
|
|
221
|
+
// when the reset left it open.
|
|
222
|
+
let before = new Set<number>();
|
|
223
|
+
const awaitPull = async (step: Extract<ScenarioStep, { do: "await-pull" }>): Promise<StepResult> => {
|
|
224
|
+
const find = p.forge.findPull;
|
|
225
|
+
if (!find) throw new Stall("an await-pull step needs the forge's findPull");
|
|
226
|
+
// The product picks the branch, so it is the same on both runs.
|
|
227
|
+
const deadline = deadlineOf("await-pull");
|
|
228
|
+
let seen: ForgePull | undefined;
|
|
229
|
+
for (;;) {
|
|
230
|
+
const found = await find.call(p.forge, step.branch);
|
|
231
|
+
if (found && !before.has(found.number) && (step.title === undefined || found.title.includes(step.title))) {
|
|
232
|
+
opened.set(step.id, { pull: found.number, head: found.head });
|
|
233
|
+
log(`${s.id} ${arm}: ${step.id} found pull request ${found.number} at ${found.head.slice(0, 8)}`);
|
|
234
|
+
return { id: step.id, do: step.do, pull: found.number, commit: found.head };
|
|
235
|
+
}
|
|
236
|
+
if (found) seen = found;
|
|
237
|
+
if (p.clock.now() >= deadline) break;
|
|
238
|
+
await p.clock.sleep(opts.pollMs ?? 2000);
|
|
239
|
+
}
|
|
240
|
+
const why = !seen
|
|
241
|
+
? `no open pull request from ${step.branch} within ${limits["await-pull"]}s`
|
|
242
|
+
: before.has(seen.number)
|
|
243
|
+
? `pull request ${seen.number} from ${step.branch} was open before the run started, and no new one came within ${limits["await-pull"]}s`
|
|
244
|
+
: `pull request ${seen.number} from ${step.branch} is titled "${seen.title}", which does not hold "${step.title}", after ${limits["await-pull"]}s`;
|
|
245
|
+
throw new Stall(why);
|
|
246
|
+
};
|
|
178
247
|
|
|
179
248
|
try {
|
|
180
249
|
await p.reset?.();
|
|
181
250
|
await p.arm?.(arm, arm === "break" ? { ...s.break.env } : {});
|
|
251
|
+
if (s.steps.some((x) => x.do === "await-pull")) before = new Set(await p.forge.openPulls());
|
|
182
252
|
for (let i = 0; i < s.steps.length; i++) {
|
|
183
253
|
const step = s.steps[i]!;
|
|
184
254
|
let result: StepResult;
|
|
@@ -204,6 +274,11 @@ export async function runArm(s: Scenario, arm: Arm, p: DriverPorts, opts: Driver
|
|
|
204
274
|
}
|
|
205
275
|
continue;
|
|
206
276
|
}
|
|
277
|
+
case "await-pull": {
|
|
278
|
+
result = await awaitPull(step);
|
|
279
|
+
ctx.pull = result.pull;
|
|
280
|
+
break;
|
|
281
|
+
}
|
|
207
282
|
case "plan": {
|
|
208
283
|
const o = pullOf(step.pull);
|
|
209
284
|
const r = await report("plan", o.pull, o.head, "plan");
|
|
@@ -230,6 +305,16 @@ export async function runArm(s: Scenario, arm: Arm, p: DriverPorts, opts: Driver
|
|
|
230
305
|
result = { id: step.id, do: step.do, pull: o.pull, commit };
|
|
231
306
|
break;
|
|
232
307
|
}
|
|
308
|
+
case "comment": {
|
|
309
|
+
const o = pullOf(step.pull);
|
|
310
|
+
const post = p.forge.postComment;
|
|
311
|
+
if (!post) throw new Stall("a comment step needs the forge's postComment");
|
|
312
|
+
await within("comment", post.call(p.forge, o.pull, step.body, step.as ?? "author"));
|
|
313
|
+
log(`${s.id} ${arm}: ${step.id} commented on pull request ${o.pull} as ${step.as ?? "author"}`);
|
|
314
|
+
ctx.pull = o.pull;
|
|
315
|
+
result = { id: step.id, do: step.do, pull: o.pull };
|
|
316
|
+
break;
|
|
317
|
+
}
|
|
233
318
|
case "apply": {
|
|
234
319
|
const m = merged.get(step.merge);
|
|
235
320
|
if (!m) throw new Stall(`no merge from ${step.merge}`);
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
import { mkdirSync, rmSync, writeFileSync } from "node:fs";
|
|
12
12
|
import { dirname, join } from "node:path";
|
|
13
13
|
import { guardedGit, remoteWith, type GuardedGit } from "./git";
|
|
14
|
-
import type { Clock, ForgeIssue, ForgeRun, HarnessForge } from "./ports";
|
|
14
|
+
import type { Clock, ForgeIssue, ForgePerson, ForgePull, ForgeRun, HarnessForge } from "./ports";
|
|
15
15
|
import { forgejoRunnerConfig, type RunnerConfigOptions } from "./stack";
|
|
16
16
|
|
|
17
17
|
export interface Person {
|
|
@@ -73,6 +73,16 @@ interface ActionRun {
|
|
|
73
73
|
workflow_id?: string;
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
+
/** A pull request as Forgejo's API answers, the fields read here. */
|
|
77
|
+
interface ForgejoPull {
|
|
78
|
+
number: number;
|
|
79
|
+
title: string;
|
|
80
|
+
head?: { ref?: string; sha?: string; repo?: { full_name?: string } | null };
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const pullOf = (p: ForgejoPull): ForgePull => ({ number: p.number, title: p.title, branch: p.head?.ref ?? "", head: p.head?.sha ?? "" });
|
|
84
|
+
const sameRepo = (a: string | undefined, b: string) => a !== undefined && a.toLowerCase() === b.toLowerCase();
|
|
85
|
+
|
|
76
86
|
const DONE = new Set(["success", "failure", "cancelled", "skipped"]);
|
|
77
87
|
|
|
78
88
|
export class ForgejoForge implements HarnessForge {
|
|
@@ -201,6 +211,37 @@ export class ForgejoForge implements HarnessForge {
|
|
|
201
211
|
return out;
|
|
202
212
|
}
|
|
203
213
|
|
|
214
|
+
async findPull(branch: string): Promise<ForgePull | undefined> {
|
|
215
|
+
const found: ForgePull[] = [];
|
|
216
|
+
for (let page = 1; page < 50; page++) {
|
|
217
|
+
const list = await this.api<ForgejoPull[]>(this.o.admin, "GET", `${this.r}/pulls?state=open&sort=oldest&page=${page}&limit=50`);
|
|
218
|
+
if (!list || list.length === 0) break;
|
|
219
|
+
for (const p of list) if (p.head?.ref === branch && sameRepo(p.head.repo?.full_name, this.o.repo)) found.push(pullOf(p));
|
|
220
|
+
if (list.length < 50) break;
|
|
221
|
+
}
|
|
222
|
+
return found.sort((a, b) => a.number - b.number)[0];
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
async pullInfo(pull: number): Promise<ForgePull | undefined> {
|
|
226
|
+
const p = await this.api<ForgejoPull>(this.o.admin, "GET", `${this.r}/pulls/${pull}`, undefined, true);
|
|
227
|
+
return p ? pullOf(p) : undefined;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
async changedFiles(pull: number): Promise<string[]> {
|
|
231
|
+
const out: string[] = [];
|
|
232
|
+
for (let page = 1; page < 50; page++) {
|
|
233
|
+
const list = await this.api<Array<{ filename: string }>>(this.o.admin, "GET", `${this.r}/pulls/${pull}/files?page=${page}&limit=50`);
|
|
234
|
+
if (!list || list.length === 0) break;
|
|
235
|
+
out.push(...list.map((f) => f.filename));
|
|
236
|
+
if (list.length < 50) break;
|
|
237
|
+
}
|
|
238
|
+
return out;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
async postComment(pull: number, body: string, as: ForgePerson): Promise<void> {
|
|
242
|
+
await this.api(this.o[as], "POST", `${this.r}/issues/${pull}/comments`, { body });
|
|
243
|
+
}
|
|
244
|
+
|
|
204
245
|
applyAgain(sha: string, workflow: string): Promise<ForgeRun> {
|
|
205
246
|
return this.dispatch(sha, workflow);
|
|
206
247
|
}
|
package/src/e2e-harness/index.ts
CHANGED
|
@@ -13,14 +13,24 @@
|
|
|
13
13
|
* - the no-real-cloud wrapper: ./safe-run.ts
|
|
14
14
|
*
|
|
15
15
|
* A product on a published chant without this subpath feature-detects:
|
|
16
|
-
* import it lazily, and use it when `E2E_HARNESS_FLOOR` is there.
|
|
16
|
+
* import it lazily, and use it when `E2E_HARNESS_FLOOR` is there. A scenario
|
|
17
|
+
* with await-pull or comment steps, or a pull or gated outcome, needs
|
|
18
|
+
* `E2E_HARNESS_PULL_STEPS_FLOOR` as well.
|
|
17
19
|
*/
|
|
18
20
|
import { existsSync } from "node:fs";
|
|
19
21
|
import { join } from "node:path";
|
|
20
22
|
import { NEXT_RELEASE } from "../release-floors";
|
|
21
23
|
|
|
22
24
|
/** The first chant with the e2e harness. */
|
|
23
|
-
export const E2E_HARNESS_FLOOR =
|
|
25
|
+
export const E2E_HARNESS_FLOOR = "0.124.56";
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* The first chant whose harness follows a pull request a product opened
|
|
29
|
+
* (chant#4650): the await-pull and comment steps, the pull and gated
|
|
30
|
+
* outcomes, and the forge reads under them. A scenario that uses one needs
|
|
31
|
+
* this chant or newer.
|
|
32
|
+
*/
|
|
33
|
+
export const E2E_HARNESS_PULL_STEPS_FLOOR = NEXT_RELEASE;
|
|
24
34
|
|
|
25
35
|
/**
|
|
26
36
|
* The harness's chant docker-lexicon project, to `chant build <dir>/src
|
package/src/e2e-harness/ports.ts
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* chant's reports land, chant run outside the pipeline, the ledger, and time.
|
|
5
5
|
* The real ones are ./forgejo.ts and ./bucket.ts; tests pass fakes.
|
|
6
6
|
*/
|
|
7
|
+
import type { GatedRequestRead } from "../lifecycle/gated-request";
|
|
7
8
|
import type { OpRunRecord } from "../op/runtime";
|
|
8
9
|
|
|
9
10
|
/** A forge repository as the author, the reviewer and the admin: the pull request loop. */
|
|
@@ -48,6 +49,19 @@ export interface ForgeIssue {
|
|
|
48
49
|
open: boolean;
|
|
49
50
|
}
|
|
50
51
|
|
|
52
|
+
/** An open pull request as the forge reads it. */
|
|
53
|
+
export interface ForgePull {
|
|
54
|
+
number: number;
|
|
55
|
+
title: string;
|
|
56
|
+
/** Its head branch. */
|
|
57
|
+
branch: string;
|
|
58
|
+
/** Its head commit's sha. */
|
|
59
|
+
head: string;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** Who on the forge a comment comes from. */
|
|
63
|
+
export type ForgePerson = "author" | "reviewer" | "admin";
|
|
64
|
+
|
|
51
65
|
/**
|
|
52
66
|
* sql-yodeler's Forge verbs (scenarios/forges/forge.ts:26-61) that the pull
|
|
53
67
|
* request loop lacks. `openPr` and `merge` there are `openPull` and
|
|
@@ -59,6 +73,18 @@ export interface ForgeReads {
|
|
|
59
73
|
comments(pull: number): Promise<string[]>;
|
|
60
74
|
/** The repository's issues, open and closed, without pull requests. */
|
|
61
75
|
issues(): Promise<ForgeIssue[]>;
|
|
76
|
+
/**
|
|
77
|
+
* The OPEN pull request from `branch` in this repository (a fork's branch
|
|
78
|
+
* of the same name is not it), or undefined. The oldest when there are
|
|
79
|
+
* several. A product opens it, and the await-pull step finds it.
|
|
80
|
+
*/
|
|
81
|
+
findPull(branch: string): Promise<ForgePull | undefined>;
|
|
82
|
+
/** Pull request `pull`, open or not, or undefined when the forge does not know it. */
|
|
83
|
+
pullInfo(pull: number): Promise<ForgePull | undefined>;
|
|
84
|
+
/** The repo-relative paths pull request `pull` changes, a renamed file under its new path. */
|
|
85
|
+
changedFiles(pull: number): Promise<string[]>;
|
|
86
|
+
/** Post `body` as a comment on pull request `pull`, as `as`. */
|
|
87
|
+
postComment(pull: number, body: string, as: ForgePerson): Promise<void>;
|
|
62
88
|
}
|
|
63
89
|
|
|
64
90
|
export interface ForgeRuns {
|
|
@@ -107,6 +133,13 @@ export interface Chant {
|
|
|
107
133
|
/** The run ledger of the scenario's repo (`chant/lifecycle`), read. */
|
|
108
134
|
export interface Ledger {
|
|
109
135
|
runs(env: string, op: string): Promise<OpRunRecord[]>;
|
|
136
|
+
/**
|
|
137
|
+
* The gated requests of `op`, oldest first, for the gated outcome. A gated
|
|
138
|
+
* request writes no op-run record, so `runs` never sees it. The real one
|
|
139
|
+
* is `readGatedRequests(op, location)` from the lifecycle module, on the
|
|
140
|
+
* scenario repo's ledger.
|
|
141
|
+
*/
|
|
142
|
+
gatedRequests?(op: string): Promise<GatedRequestRead[]>;
|
|
110
143
|
}
|
|
111
144
|
|
|
112
145
|
/** Work outside the forge and chant: a change made out of band. */
|
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
* a repo tree, an ordered list of pull request steps, and the outcomes each
|
|
4
4
|
* step must show. The lint refuses one that cannot record a row: no claim
|
|
5
5
|
* id, no BREAK arm, nothing to check, or a step that names a pull request or
|
|
6
|
-
* a merge no earlier step made.
|
|
6
|
+
* a merge no earlier step made. An await-pull step makes a pull request as
|
|
7
|
+
* an open step does.
|
|
7
8
|
*/
|
|
8
9
|
import { readFileSync } from "node:fs";
|
|
9
10
|
import { validateScenario, type Scenario, type ScenarioStep } from "./schemas/index";
|
|
@@ -41,7 +42,7 @@ export function lintScenario(data: unknown): ScenarioFinding[] {
|
|
|
41
42
|
if (seen.has(step.id)) out.push({ at: `${at}/id`, message: `step id ${step.id} is used twice` });
|
|
42
43
|
const opened = (id: string) => {
|
|
43
44
|
const o = seen.get(id);
|
|
44
|
-
return o !== undefined && (o.do === "open" || o.do === "open-concurrent");
|
|
45
|
+
return o !== undefined && (o.do === "open" || o.do === "open-concurrent" || o.do === "await-pull");
|
|
45
46
|
};
|
|
46
47
|
switch (step.do) {
|
|
47
48
|
case "open-concurrent": {
|
|
@@ -54,7 +55,8 @@ export function lintScenario(data: unknown): ScenarioFinding[] {
|
|
|
54
55
|
case "plan":
|
|
55
56
|
case "approve":
|
|
56
57
|
case "merge":
|
|
57
|
-
|
|
58
|
+
case "comment":
|
|
59
|
+
if (!opened(step.pull)) out.push({ at: `${at}/pull`, message: `${step.do} names ${step.pull}, which is not an earlier open or await-pull step` });
|
|
58
60
|
break;
|
|
59
61
|
case "apply": {
|
|
60
62
|
const m = seen.get(step.merge);
|
|
@@ -69,9 +71,9 @@ export function lintScenario(data: unknown): ScenarioFinding[] {
|
|
|
69
71
|
if ("report" in e && step.do !== "plan" && step.do !== "apply") {
|
|
70
72
|
out.push({ at: `${at}/expect/${j}`, message: `a report outcome belongs on a plan or apply step, not ${step.do}` });
|
|
71
73
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}
|
|
74
|
+
const hasPull = "pull" in step || step.do === "open" || step.do === "open-concurrent" || step.do === "await-pull";
|
|
75
|
+
if ("comment" in e && !hasPull) out.push({ at: `${at}/expect/${j}`, message: "a comment outcome belongs on a step with a pull request" });
|
|
76
|
+
if ("pull" in e && !hasPull) out.push({ at: `${at}/expect/${j}`, message: "a pull outcome belongs on a step with a pull request" });
|
|
75
77
|
if ("exit" in e && step.do !== "out-of-band") out.push({ at: `${at}/expect/${j}`, message: "an exit outcome belongs on an out-of-band step" });
|
|
76
78
|
}
|
|
77
79
|
seen.set(step.id, step);
|
|
@@ -48,10 +48,19 @@ JSON Schemas (draft 2020-12) of the e2e harness (chant#4587). `index.ts` exports
|
|
|
48
48
|
| `reportUrl` | yes | The pipeline's `--report-url`, `s3://<bucket>/<prefix>`. |
|
|
49
49
|
| `env` | no | The chant environment the ledger records runs under. Default `local`. |
|
|
50
50
|
| `limits` | no | Seconds per kind of step, over the defaults in `steps.ts`. |
|
|
51
|
-
| `steps` | yes | In order. `do` is open, open-concurrent, plan, approve, merge, apply, out-of-band or kill-job; each may carry `expect`. |
|
|
51
|
+
| `steps` | yes | In order. `do` is open, open-concurrent, await-pull, plan, approve, merge, comment, apply, out-of-band or kill-job; each may carry `expect`. |
|
|
52
52
|
| `break` | yes | The BREAK arm: `env` with `BREAK: "1"`, and an optional `overlay` copied over every pull request of the break run. |
|
|
53
53
|
|
|
54
|
-
An outcome in `expect` has one key: `report` (`status`, `components`, `only`) on a plan or apply step, `ledger` (`op`, `status`, `count`), `comment`, `issue` (`title`, `open`), or `exit` on an out-of-band step.
|
|
54
|
+
An outcome in `expect` has one key: `report` (`status`, `components`, `only`) on a plan or apply step, `ledger` (`op`, `status`, `count`), `gated` (`op`, `status`, `count`), `comment`, `pull` (`title`, `files`, `only`) on a step with a pull request, `issue` (`title`, `open`), or `exit` on an out-of-band step.
|
|
55
|
+
|
|
56
|
+
The steps a product's pull request needs:
|
|
57
|
+
|
|
58
|
+
| Step | Fields | Does |
|
|
59
|
+
|---|---|---|
|
|
60
|
+
| `await-pull` | `branch`, `title`? | Waits, within its limit (300 s by default), for an open pull request from exactly `branch` whose title holds `title`, and binds it to the step's id. A product's command in an earlier `out-of-band` step opens it. Both runs wait for the same branch, and a pull request already open when the run started is never bound. |
|
|
61
|
+
| `comment` | `pull`, `body`, `as`? | Posts `body` on the pull request of the open or await-pull step `pull`, as `author` (the default), `reviewer` or `admin`. Limit 60 s. |
|
|
62
|
+
|
|
63
|
+
`plan`, `approve` and `merge` name an await-pull step in `pull` as they name an open step. The `pull` outcome reads the step's pull request: its title holds `title`, it changes every path in `files`, and with `only: true` it changes no other path. The `gated` outcome counts the gated requests of `op` asked since the run started, which write no op-run record and so never reach `ledger`: `gated` until a finished line names one, then `ok` when it applied or `failed`. These steps and outcomes were added within contract 1 by chant 0.124.58.
|
|
55
64
|
|
|
56
65
|
## e2e-claim-row/v1 and e2e-claims/v1
|
|
57
66
|
|