@intentius/chant 0.124.70 → 0.124.72
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-agent.d.ts +12 -1
- package/dist/ci-agent.d.ts.map +1 -1
- package/dist/ci-agent.js +13 -8
- package/dist/ci-commit.d.ts +326 -0
- package/dist/ci-commit.d.ts.map +1 -0
- package/dist/ci-commit.js +725 -0
- package/dist/ci-estate/delivery.d.ts +75 -2
- package/dist/ci-estate/delivery.d.ts.map +1 -1
- package/dist/ci-estate/delivery.js +129 -0
- package/dist/ci-estate.d.ts +3 -1
- package/dist/ci-estate.d.ts.map +1 -1
- package/dist/ci-estate.js +4 -1
- package/dist/ci-product-words.d.ts +6 -1
- package/dist/ci-product-words.d.ts.map +1 -1
- package/dist/ci-product-words.js +3 -1
- package/dist/ci-product.d.ts +1 -1
- package/dist/ci-product.d.ts.map +1 -1
- package/dist/ci-product.js +1 -1
- package/dist/cli/handlers/approve.d.ts.map +1 -1
- package/dist/cli/handlers/approve.js +7 -2
- package/dist/cli/handlers/commit.d.ts +26 -0
- package/dist/cli/handlers/commit.d.ts.map +1 -0
- package/dist/cli/handlers/commit.js +145 -0
- package/dist/cli/handlers/notify-relay.d.ts.map +1 -1
- package/dist/cli/handlers/notify-relay.js +22 -2
- package/dist/cli/handlers/pr.d.ts +6 -0
- package/dist/cli/handlers/pr.d.ts.map +1 -1
- package/dist/cli/handlers/pr.js +16 -7
- package/dist/cli/handlers/release.d.ts +9 -0
- package/dist/cli/handlers/release.d.ts.map +1 -1
- package/dist/cli/handlers/release.js +114 -5
- package/dist/cli/main.d.ts.map +1 -1
- package/dist/cli/main.js +17 -0
- package/dist/components/product-pipeline.d.ts +33 -0
- package/dist/components/product-pipeline.d.ts.map +1 -1
- package/dist/components/product-pipeline.js +34 -1
- package/dist/components/release-compile.d.ts +2 -0
- package/dist/components/release-compile.d.ts.map +1 -1
- package/dist/components/release-compile.js +8 -4
- package/dist/config.d.ts +60 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +16 -0
- package/dist/lexicon.d.ts +54 -0
- package/dist/lexicon.d.ts.map +1 -1
- package/dist/lexicon.js +28 -0
- package/dist/lifecycle/__fixtures__/publish-fakes.d.ts +4 -0
- package/dist/lifecycle/__fixtures__/publish-fakes.d.ts.map +1 -1
- package/dist/lifecycle/__fixtures__/publish-fakes.js +6 -2
- package/dist/lifecycle/gated-request.d.ts +3 -1
- package/dist/lifecycle/gated-request.d.ts.map +1 -1
- package/dist/lifecycle/gated-request.js +5 -2
- package/dist/lifecycle/git.d.ts.map +1 -1
- package/dist/lifecycle/git.js +57 -0
- package/dist/lifecycle/publish-declaration.d.ts +16 -0
- package/dist/lifecycle/publish-declaration.d.ts.map +1 -1
- package/dist/lifecycle/publish-declaration.js +35 -3
- package/dist/lifecycle/publish-forge.d.ts +12 -0
- package/dist/lifecycle/publish-forge.d.ts.map +1 -1
- package/dist/lifecycle/publish-forge.js +102 -19
- package/dist/lifecycle/publish-npm.d.ts +15 -0
- package/dist/lifecycle/publish-npm.d.ts.map +1 -1
- package/dist/lifecycle/publish-npm.js +28 -1
- package/dist/lifecycle/publish-oci.d.ts +2 -0
- package/dist/lifecycle/publish-oci.d.ts.map +1 -1
- package/dist/lifecycle/publish-oci.js +10 -0
- package/dist/lifecycle/release-cut.d.ts +7 -1
- package/dist/lifecycle/release-cut.d.ts.map +1 -1
- package/dist/lifecycle/release-cut.js +8 -1
- package/dist/lifecycle/release-images.d.ts +87 -0
- package/dist/lifecycle/release-images.d.ts.map +1 -0
- package/dist/lifecycle/release-images.js +138 -0
- package/dist/lifecycle/release-publish.d.ts +2 -0
- package/dist/lifecycle/release-publish.d.ts.map +1 -1
- package/dist/notify-relay.d.ts +41 -1
- package/dist/notify-relay.d.ts.map +1 -1
- package/dist/notify-relay.js +40 -0
- package/dist/notify.d.ts +16 -3
- package/dist/notify.d.ts.map +1 -1
- package/dist/notify.js +16 -10
- package/dist/op/activities/review-agent.d.ts.map +1 -1
- package/dist/op/activities/review-agent.js +4 -2
- package/dist/op/gate.d.ts +5 -1
- package/dist/op/gate.d.ts.map +1 -1
- package/dist/op/gate.js +7 -2
- package/dist/op/op-waves-notify.d.ts +1 -1
- package/dist/op/op-waves-notify.d.ts.map +1 -1
- package/dist/op/op-waves-notify.js +2 -1
- package/dist/op/op-waves-run.d.ts.map +1 -1
- package/dist/op/op-waves-run.js +12 -8
- package/dist/op/op-waves.d.ts +9 -0
- package/dist/op/op-waves.d.ts.map +1 -1
- package/dist/op/op-waves.js +11 -0
- package/dist/pr-forge-base.d.ts +18 -0
- package/dist/pr-forge-base.d.ts.map +1 -0
- package/dist/pr-forge-base.js +29 -0
- package/dist/release-floors.d.ts +1 -1
- package/dist/release-floors.js +1 -1
- package/dist/wave-runtime.mjs +315 -315
- package/dist/workspace/ci-green.d.ts.map +1 -1
- package/dist/workspace/ci-green.js +1 -2
- package/dist/workspace/release-workflow.d.ts +47 -0
- package/dist/workspace/release-workflow.d.ts.map +1 -1
- package/dist/workspace/release-workflow.js +258 -14
- package/package.json +1 -1
- package/src/ci-agent.ts +13 -8
- package/src/ci-commit.test.ts +415 -0
- package/src/ci-commit.ts +901 -0
- package/src/ci-estate/__fixtures__/terragucci-dora.json +1305 -0
- package/src/ci-estate/delivery.ts +186 -2
- package/src/ci-estate/records-delivery.test.ts +55 -0
- package/src/ci-estate.ts +10 -0
- package/src/ci-product-words.ts +6 -2
- package/src/ci-product.ts +1 -0
- package/src/cli/handlers/approve.ts +6 -2
- package/src/cli/handlers/commit.ts +155 -0
- package/src/cli/handlers/notify-relay.ts +21 -2
- package/src/cli/handlers/operator.test.ts +2 -0
- package/src/cli/handlers/pr-wave-approve-lines.test.ts +32 -0
- package/src/cli/handlers/pr.ts +17 -7
- package/src/cli/handlers/release.ts +110 -5
- package/src/cli/main.ts +17 -0
- package/src/components/product-pipeline.test.ts +28 -1
- package/src/components/product-pipeline.ts +54 -1
- package/src/components/release-compile.ts +9 -3
- package/src/config.ts +31 -0
- package/src/lexicon.ts +72 -0
- package/src/lifecycle/__fixtures__/publish-fakes.ts +11 -5
- package/src/lifecycle/gated-request-spend.test.ts +115 -0
- package/src/lifecycle/gated-request.ts +5 -2
- package/src/lifecycle/git.ts +53 -0
- package/src/lifecycle/ledger-two-clones.test.ts +132 -0
- package/src/lifecycle/publish-declaration.ts +35 -3
- package/src/lifecycle/publish-forge-notes.test.ts +193 -0
- package/src/lifecycle/publish-forge.ts +100 -22
- package/src/lifecycle/publish-npm.ts +31 -2
- package/src/lifecycle/publish-oci.ts +10 -0
- package/src/lifecycle/publish-targets.test.ts +2 -1
- package/src/lifecycle/release-cut.ts +17 -1
- package/src/lifecycle/release-images.test.ts +242 -0
- package/src/lifecycle/release-images.ts +174 -0
- package/src/lifecycle/release-publish.ts +2 -0
- package/src/notify-relay.test.ts +55 -1
- package/src/notify-relay.ts +49 -1
- package/src/notify.ts +25 -12
- package/src/op/activities/review-agent.test.ts +20 -1
- package/src/op/activities/review-agent.ts +5 -2
- package/src/op/gate.ts +7 -2
- package/src/op/op-waves-approve-target.test.ts +108 -0
- package/src/op/op-waves-notify.ts +2 -2
- package/src/op/op-waves-run.ts +12 -7
- package/src/op/op-waves.ts +12 -0
- package/src/pr-forge-base.test.ts +37 -0
- package/src/pr-forge-base.ts +36 -0
- package/src/release-floors.ts +1 -1
- package/src/workspace/__fixtures__/release-workflow/forgejo-plain-member.yml +26 -0
- package/src/workspace/__fixtures__/release-workflow/forgejo-plain.yml +23 -0
- package/src/workspace/__fixtures__/release-workflow/forgejo-secure-member.yml +27 -0
- package/src/workspace/__fixtures__/release-workflow/forgejo-secure.yml +24 -0
- package/src/workspace/__fixtures__/release-workflow/github-plain-member.yml +26 -0
- package/src/workspace/__fixtures__/release-workflow/github-plain.yml +23 -0
- package/src/workspace/__fixtures__/release-workflow/github-secure-member.yml +27 -0
- package/src/workspace/__fixtures__/release-workflow/github-secure.yml +24 -0
- package/src/workspace/__fixtures__/release-workflow/gitlab-plain-member.yml +13 -0
- package/src/workspace/__fixtures__/release-workflow/gitlab-plain.yml +12 -0
- package/src/workspace/__fixtures__/release-workflow/gitlab-secure-member.yml +14 -0
- package/src/workspace/__fixtures__/release-workflow/gitlab-secure.yml +13 -0
- package/src/workspace/ci-green.ts +1 -2
- package/src/workspace/release-workflow.test.ts +199 -0
- package/src/workspace/release-workflow.ts +356 -14
package/src/cli/handlers/pr.ts
CHANGED
|
@@ -1340,7 +1340,7 @@ async function prApply(ctx: CommandContext, stage: StageEvents, beforeMerge?: Pr
|
|
|
1340
1340
|
members: applied.members,
|
|
1341
1341
|
...(resumed ? { resumed: resumed.completed } : {}),
|
|
1342
1342
|
...(applied.rounds ? { rounds: applied.rounds } : {}),
|
|
1343
|
-
...(applied.held ? { message: applied.held } : applied.leaseFailed ? { message: applied.leaseFailed } : applied.status === "waiting" ? { message: waitingMessage(op, applied.rounds) } : {}),
|
|
1343
|
+
...(applied.held ? { message: applied.held } : applied.leaseFailed ? { message: applied.leaseFailed } : applied.status === "waiting" ? { message: waitingMessage(op, p.env, applied.rounds) } : {}),
|
|
1344
1344
|
});
|
|
1345
1345
|
// A component that stopped at a gate of its own leaves the apply waiting on
|
|
1346
1346
|
// a person. A step that refused its plan because the target moved since
|
|
@@ -1734,6 +1734,8 @@ async function decideApplyGate(
|
|
|
1734
1734
|
console.error(formatInfo(`the merged changes' approvals do not cover the plan at ${green.commit.slice(0, 12)}: ${uncovered.join("; ")}`));
|
|
1735
1735
|
}
|
|
1736
1736
|
const digest = set.doc.digest;
|
|
1737
|
+
// #4574: the members fill a product's {target}, one line each, as the note names them (#4601).
|
|
1738
|
+
const approve = prApproveCommands({ op, gate: p.gate, digest, env: p.env, ...(p.member ? { member: p.member } : {}), members: set.members }).join("; ");
|
|
1737
1739
|
const check = await emitGateStep(
|
|
1738
1740
|
events?.emit,
|
|
1739
1741
|
{ op, gate: p.gate },
|
|
@@ -1742,7 +1744,7 @@ async function decideApplyGate(
|
|
|
1742
1744
|
const a = approvalOf(unapproved);
|
|
1743
1745
|
return a.status === "changed"
|
|
1744
1746
|
? describePlanChanged({ op, gate: p.gate, digest, approval: a })
|
|
1745
|
-
: `No approval stands for this plan. Approve it: ${
|
|
1747
|
+
: `No approval stands for this plan. Approve it: ${approve}`;
|
|
1746
1748
|
},
|
|
1747
1749
|
);
|
|
1748
1750
|
const approval = approvalOf(check);
|
|
@@ -1753,7 +1755,7 @@ async function decideApplyGate(
|
|
|
1753
1755
|
approval,
|
|
1754
1756
|
satisfied: false,
|
|
1755
1757
|
refusal: "not-approved",
|
|
1756
|
-
message: `No approval stands for this plan, so nothing was applied.${why} Approve it: ${
|
|
1758
|
+
message: `No approval stands for this plan, so nothing was applied.${why} Approve it: ${approve}; then run the apply again.`,
|
|
1757
1759
|
};
|
|
1758
1760
|
}
|
|
1759
1761
|
|
|
@@ -1890,14 +1892,20 @@ function reviewCheck(args: CommandContext["args"], p: Prepared, pr: number, auth
|
|
|
1890
1892
|
};
|
|
1891
1893
|
}
|
|
1892
1894
|
|
|
1895
|
+
/** A waiting wave's or round's approve lines (#4574): one per component when the product's template names `{target}`, as the note names them (#4601). */
|
|
1896
|
+
export function waveApproveLines(op: string, env: string, w: { gate: string; digest: string; components: readonly string[] }): string {
|
|
1897
|
+
const targets = activeProductWords().approve.includes("{target}") ? (w.components.length > 0 ? w.components : [env]) : [undefined];
|
|
1898
|
+
return targets.map((target) => prApproveCommand({ op, gate: w.gate, digest: w.digest, ...(target !== undefined ? { target } : {}) })).join("; ");
|
|
1899
|
+
}
|
|
1900
|
+
|
|
1893
1901
|
/** What a `waiting` apply prints (#3999): the round's gate and digest to approve, and how to carry on. */
|
|
1894
|
-
function waitingMessage(op: string, rounds: PrRound[] | undefined): string {
|
|
1902
|
+
function waitingMessage(op: string, env: string, rounds: PrRound[] | undefined): string {
|
|
1895
1903
|
const last = rounds?.at(-1);
|
|
1896
1904
|
if (!last) return "Some members were held back after an upstream applied.";
|
|
1897
1905
|
return (
|
|
1898
1906
|
`${last.components.join(", ")} ${last.components.length === 1 ? "was" : "were"} planned again after an upstream applied, ` +
|
|
1899
1907
|
`and no approval stands for that plan (${last.digest}), so ${last.components.length === 1 ? "it" : "they"} did not apply. ` +
|
|
1900
|
-
`Approve it: ${
|
|
1908
|
+
`Approve it: ${waveApproveLines(op, env, last)}; then run the apply again with the same --resume record.`
|
|
1901
1909
|
);
|
|
1902
1910
|
}
|
|
1903
1911
|
|
|
@@ -2355,7 +2363,8 @@ async function prApplyWaves(
|
|
|
2355
2363
|
setWave(entry);
|
|
2356
2364
|
// #4003: the wave's new plan beside the report, for whoever approves its gate.
|
|
2357
2365
|
if (ran.changeSet) writeWaveChangeSet(ctx, k, ran.changeSet, upload);
|
|
2358
|
-
|
|
2366
|
+
// #4574: the wave's components fill a product's {target}, as the note names them (#4601).
|
|
2367
|
+
const approveLine = waveApproveLines(op, p.env, entry);
|
|
2359
2368
|
const message =
|
|
2360
2369
|
ran.exitCode === CHANT_EXIT.moved
|
|
2361
2370
|
? `Wave ${k}'s plan changed after its approval, so nothing in it was applied.${entry.approved ? ` approved: ${entry.approved}; planned now: ${entry.digest}.` : ""} Read the new plan, and if it is right, approve it: ${approveLine}; then run the wave's apply again.`
|
|
@@ -2737,8 +2746,9 @@ async function runComponentWave(
|
|
|
2737
2746
|
// A wave that waits at its own gate is the stream's gate step there, as before op waves (#4003).
|
|
2738
2747
|
if (d && !byPullRequest && (exitCode === CHANT_EXIT.waiting || exitCode === CHANT_EXIT.moved)) {
|
|
2739
2748
|
const waiting = { satisfied: false, pending: { op: at.op }, ...(d.mismatch ? { mismatch: d.mismatch } : {}) } as unknown as GateCheck;
|
|
2749
|
+
const approve = waveApproveLines(at.op, p.env, { gate: d.gate, digest: d.digest, components: at.runs });
|
|
2740
2750
|
await emitGateStep(at.events?.emit, { op: at.op, gate: d.gate }, async () => waiting, () =>
|
|
2741
|
-
d.mismatch ? `wave ${at.k}'s plan changed after its approval. Approve the plan now: ${
|
|
2751
|
+
d.mismatch ? `wave ${at.k}'s plan changed after its approval. Approve the plan now: ${approve}` : `wave ${at.k}'s plan is not the one the pull request approved. Approve it: ${approve}`,
|
|
2742
2752
|
);
|
|
2743
2753
|
}
|
|
2744
2754
|
const read = readWaveOutputs(at.outputsFile);
|
|
@@ -43,13 +43,14 @@
|
|
|
43
43
|
|
|
44
44
|
import { execFileSync } from "node:child_process";
|
|
45
45
|
import { existsSync } from "node:fs";
|
|
46
|
-
import {
|
|
46
|
+
import { tmpdir } from "node:os";
|
|
47
|
+
import { join, relative, resolve } from "node:path";
|
|
47
48
|
import { formatBold, formatError, formatSuccess, formatWarning } from "../format";
|
|
48
49
|
import { parseParamFlags } from "../build-params-cli";
|
|
49
50
|
import type { CommandContext } from "../registry";
|
|
50
51
|
|
|
51
52
|
const USAGE =
|
|
52
|
-
"chant release cut [<label>] [--at <sha>] [--yes] [--build <command>] [--param <k=v>] [--image <component>=<repository>@sha256:<hex>] [--params-file <file>] [--src <dir>] [-o <file>] [--lexicon <name>] [--actor <name>] [--sign [<key file>]] [--channel <tag>] [--lane <name>] [--override-green] [--json] | release publish <label|digest> [--yes] [--allow-unsigned] [--require-provenance] [--json] | release verify <label|digest> [--json] | release candidates [--env <env>] [--lane <name>] [--forge-issues] [--json] | release compose <name> [--base <label|sha>] (--pr <n> | --work <id>)... [--yes] [--json] | release list [--json] | release export <label|digest> --env <env> [-o <dir>] [--json]";
|
|
53
|
+
"chant release cut [<label>] [--at <sha>] [--yes] [--build <command>] [--param <k=v>] [--image <component>=<repository>@sha256:<hex>] [--params-file <file>] [--src <dir>] [-o <file>] [--lexicon <name>] [--actor <name>] [--sign [<key file>]] [--channel <tag>] [--lane <name>] [--override-green] [--json] | release publish <label|digest> [--yes] [--allow-unsigned] [--require-provenance] [--json] | release verify <label|digest> [--json] | release images <label|digest> [-o <file>] [--json] | release candidates [--env <env>] [--lane <name>] [--forge-issues] [--json] | release compose <name> [--base <label|sha>] (--pr <n> | --work <id>)... [--yes] [--json] | release list [--json] | release export <label|digest> --env <env> [-o <dir>] [--json]";
|
|
53
54
|
|
|
54
55
|
/** The build inputs `release cut` and `release compile` share. */
|
|
55
56
|
function compileInputs(
|
|
@@ -113,6 +114,74 @@ async function laneOf(ctx: CommandContext, cwd: string): Promise<string | undefi
|
|
|
113
114
|
}
|
|
114
115
|
}
|
|
115
116
|
|
|
117
|
+
/** The member's `release.images` (#4657), or none when the config declares none. */
|
|
118
|
+
async function releaseImagesOf(cwd: string): Promise<Array<{ name: string; build: string; archive: string }>> {
|
|
119
|
+
const { loadChantConfig } = await import("../../config");
|
|
120
|
+
return (await loadChantConfig(cwd)).config.release?.images ?? [];
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/** A commit's time in seconds, the `SOURCE_DATE_EPOCH` a release's image builds run with (#4657). */
|
|
124
|
+
function commitTime(cwd: string, commit: string): number {
|
|
125
|
+
return Number(execFileSync("git", ["show", "-s", "--format=%ct", commit], { cwd, encoding: "utf-8", stdio: ["ignore", "pipe", "ignore"] }).trim());
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* `release images <label|digest> [-o <file>] [--json]` (#4657): build the
|
|
130
|
+
* images the release recorded again, from the release's commit checked out
|
|
131
|
+
* here, refuse an archive whose digest is not the recorded one, and write the
|
|
132
|
+
* recorded digests to the file the package build reads through
|
|
133
|
+
* `CHANT_RELEASE_DIGESTS` (default `.chant/release-digests.json`). The
|
|
134
|
+
* publish job runs it before the build that packs the package.
|
|
135
|
+
*/
|
|
136
|
+
export async function runReleaseImages(ctx: CommandContext): Promise<number> {
|
|
137
|
+
const { args } = ctx;
|
|
138
|
+
const ref = args.extraPositional;
|
|
139
|
+
const fail = (code: string, message: string, fix?: string): number => {
|
|
140
|
+
if (args.json) console.log(JSON.stringify({ ref: ref ?? null, error: { code, message, ...(fix ? { fix } : {}) } }, null, 2));
|
|
141
|
+
else console.error(formatError({ message: `${message} [${code}]`, ...(fix ? { hint: fix } : {}) }));
|
|
142
|
+
return 1;
|
|
143
|
+
};
|
|
144
|
+
if (!ref) return fail("release-not-named", "release images needs a release, by label or digest", USAGE);
|
|
145
|
+
const cwd = resolve(".");
|
|
146
|
+
const { resolveRelease } = await import("../../lifecycle/release-store");
|
|
147
|
+
const { buildReleaseImages, releaseImageDigests, writeReleaseDigests, ReleaseImageError, RELEASE_DIGESTS_ENV } = await import("../../lifecycle/release-images");
|
|
148
|
+
const { ociArchiveDigest } = await import("../../lifecycle/publish-oci");
|
|
149
|
+
const { getHeadCommit } = await import("../../lifecycle/git");
|
|
150
|
+
const found = await resolveRelease(ref, { cwd });
|
|
151
|
+
if (!found) return fail("release-not-found", `no release is labelled or digested "${ref}" in this member`, "Fetch chant/lifecycle (git fetch origin chant/lifecycle:chant/lifecycle), then list them with: chant release list");
|
|
152
|
+
const { release, label } = found;
|
|
153
|
+
const head = await getHeadCommit({ cwd });
|
|
154
|
+
if (head !== release.commit) return fail("release-images-wrong-commit", `the release was cut from ${release.commit.slice(0, 12)}, and this checkout is at ${head.slice(0, 12)}, so its images would not be the release's`, `Check out the release's commit: git checkout ${release.commit}`);
|
|
155
|
+
const declared = await releaseImagesOf(cwd);
|
|
156
|
+
const recorded = releaseImageDigests(release, declared.map((d) => d.name));
|
|
157
|
+
const missing = declared.filter((d) => recorded[d.name] === undefined).map((d) => d.name);
|
|
158
|
+
if (missing.length > 0) return fail("release-image-not-recorded", `release.images names ${missing.join(", ")}, which release ${release.releaseDigest} does not record`, "Cut a new release, so its cut builds every image the config declares.");
|
|
159
|
+
let built: import("../../lifecycle/release-store").ReleaseArtifact[];
|
|
160
|
+
try {
|
|
161
|
+
built = buildReleaseImages({ images: declared, cwd, sourceDateEpoch: commitTime(cwd, release.commit), label, archiveDigest: ociArchiveDigest });
|
|
162
|
+
} catch (err) {
|
|
163
|
+
if (err instanceof ReleaseImageError) return fail(err.code, err.message, err.fix);
|
|
164
|
+
throw err;
|
|
165
|
+
}
|
|
166
|
+
const differ = built.filter((a) => recorded[a.component] !== a.digest);
|
|
167
|
+
if (differ.length > 0) {
|
|
168
|
+
return fail(
|
|
169
|
+
"release-image-digest-mismatch",
|
|
170
|
+
differ.map((a) => `image "${a.component}" built to ${a.digest}, and the release records ${recorded[a.component]}`).join("; "),
|
|
171
|
+
"An image build must write the same archive from the same commit: set SOURCE_DATE_EPOCH-aware timestamps (rewrite-timestamp=true), and remove logs and caches from its layers.",
|
|
172
|
+
);
|
|
173
|
+
}
|
|
174
|
+
const file = resolve(cwd, args.output ?? ".chant/release-digests.json");
|
|
175
|
+
writeReleaseDigests(file, recorded);
|
|
176
|
+
if (args.json) console.log(JSON.stringify({ releaseDigest: release.releaseDigest, label, digests: recorded, file }, null, 2));
|
|
177
|
+
else {
|
|
178
|
+
for (const [name, digest] of Object.entries(recorded)) console.error(` ${name} ${digest}`);
|
|
179
|
+
console.error(formatSuccess(`Built ${built.length} image(s) to the digests release ${label ?? release.releaseDigest} records, and wrote them to ${relative(cwd, file) || file}`));
|
|
180
|
+
console.log(`${RELEASE_DIGESTS_ENV}=${file}`);
|
|
181
|
+
}
|
|
182
|
+
return 0;
|
|
183
|
+
}
|
|
184
|
+
|
|
116
185
|
function describeActorSource(source: import("../../lifecycle/release-workstation").ActorSource): string {
|
|
117
186
|
switch (source) {
|
|
118
187
|
case "flag":
|
|
@@ -265,7 +334,25 @@ export async function runReleaseCut(ctx: CommandContext): Promise<number> {
|
|
|
265
334
|
// --at: the cut reads, compiles and builds the commit's tree, not the checkout's.
|
|
266
335
|
if (args.at !== undefined && top && commit) checkout = at.checkoutCommit(top, cwd, commit);
|
|
267
336
|
const cutCwd = checkout?.memberDir ?? cwd;
|
|
268
|
-
|
|
337
|
+
// #4657: the images release.images declares are built first, and their digests handed to the build command.
|
|
338
|
+
const declaredImages = await releaseImagesOf(cutCwd);
|
|
339
|
+
const digestsFile = declaredImages.length > 0 ? join(tmpdir(), `chant-release-digests-${process.pid}.json`) : undefined;
|
|
340
|
+
const compiler = spawnTargetCompiler({ ...compileInputs(ctx, params, cutCwd, label), ...(digestsFile ? { releaseDigests: digestsFile } : {}) });
|
|
341
|
+
const buildImages = digestsFile
|
|
342
|
+
? async (at: string) => {
|
|
343
|
+
const { buildReleaseImages, writeReleaseDigests, ReleaseImageError } = await import("../../lifecycle/release-images");
|
|
344
|
+
const { ociArchiveDigest } = await import("../../lifecycle/publish-oci");
|
|
345
|
+
try {
|
|
346
|
+
const built = buildReleaseImages({ images: declaredImages, cwd: cutCwd, sourceDateEpoch: commitTime(cutCwd, at), label, archiveDigest: ociArchiveDigest });
|
|
347
|
+
writeReleaseDigests(digestsFile, Object.fromEntries(built.map((a) => [a.component, a.digest])));
|
|
348
|
+
return built;
|
|
349
|
+
} catch (err) {
|
|
350
|
+
const code = err instanceof ReleaseImageError ? err.code : (err as { code?: unknown }).code;
|
|
351
|
+
const fix = err instanceof ReleaseImageError ? err.fix : undefined;
|
|
352
|
+
throw new ReleaseCutError(code === "release-image-name-taken" ? "release-image-name-taken" : "release-image-build-failed", `no release was cut: ${(err as Error).message}`, fix);
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
: undefined;
|
|
269
356
|
// #4692: the lane is the commit's own config's under --at.
|
|
270
357
|
const lane = await laneOf(ctx, cutCwd);
|
|
271
358
|
const request = {
|
|
@@ -279,6 +366,7 @@ export async function runReleaseCut(ctx: CommandContext): Promise<number> {
|
|
|
279
366
|
...(lane !== undefined ? { lane } : {}),
|
|
280
367
|
...(args.overrideGreen ? { overrideGreen: true } : {}),
|
|
281
368
|
...(Object.keys(images).length > 0 ? { images } : {}),
|
|
369
|
+
...(buildImages ? { buildImages } : {}),
|
|
282
370
|
};
|
|
283
371
|
|
|
284
372
|
if (dryRun) {
|
|
@@ -565,6 +653,7 @@ export async function runReleasePublish(ctx: CommandContext): Promise<number> {
|
|
|
565
653
|
/** One item a target publishes, for a line: what, where, and the SBOM or attachment it is (#4049). */
|
|
566
654
|
function describeItem(i: import("../../lifecycle/release-publish").PublishItem): string {
|
|
567
655
|
const what = i.attachment === "sbom" ? `${i.name} (SBOM)` : i.attachment === "provenance" ? `${i.name} (provenance)` : i.name;
|
|
656
|
+
if (i.notes !== undefined) return `${i.name} to ${i.destination}:\n${i.notes.trimEnd().split("\n").map((l) => ` ${l}`.trimEnd()).join("\n")}`;
|
|
568
657
|
return `${what} to ${i.destination}${i.sbom ? `, carrying ${i.sbom}` : ""}`;
|
|
569
658
|
}
|
|
570
659
|
|
|
@@ -588,7 +677,13 @@ export async function runReleaseVerify(ctx: CommandContext): Promise<number> {
|
|
|
588
677
|
else console.error(formatError({ message: `${result.error.message} [${result.error.code}]`, ...(result.error.fix ? { hint: result.error.fix } : {}) }));
|
|
589
678
|
return 1;
|
|
590
679
|
}
|
|
591
|
-
|
|
680
|
+
let code: string | null = verificationCode(result);
|
|
681
|
+
// #4657: a package built here that pins an image digest the release does not record fails the check.
|
|
682
|
+
const pins = code ? null : await unknownPackagePins(resolve("."), result.releaseDigest);
|
|
683
|
+
if (pins) {
|
|
684
|
+
code = "release-pin-unknown";
|
|
685
|
+
result.reason = pins;
|
|
686
|
+
}
|
|
592
687
|
if (args.json) {
|
|
593
688
|
console.log(JSON.stringify({ ...result, ...(code ? { error: { code, message: result.reason } } : {}) }, null, 2));
|
|
594
689
|
return code ? 1 : 0;
|
|
@@ -601,7 +696,7 @@ export async function runReleaseVerify(ctx: CommandContext): Promise<number> {
|
|
|
601
696
|
console.error(
|
|
602
697
|
formatError({
|
|
603
698
|
message: `${name} does not verify: ${result.reason} [${code}]`,
|
|
604
|
-
hint: code === "release-digest-mismatch" ? "Do not publish or deploy it; cut the release again." : `Cut it again signed with a key ${result.signers.path} lists: chant release cut ${result.label ?? "<label>"} --sign --yes`,
|
|
699
|
+
hint: code === "release-digest-mismatch" ? "Do not publish or deploy it; cut the release again." : code === "release-pin-unknown" ? "Build the package from the digests the release records: chant release images <label>, then the build with CHANT_RELEASE_DIGESTS set." : `Cut it again signed with a key ${result.signers.path} lists: chant release cut ${result.label ?? "<label>"} --sign --yes`,
|
|
605
700
|
}),
|
|
606
701
|
);
|
|
607
702
|
return 1;
|
|
@@ -610,6 +705,16 @@ export async function runReleaseVerify(ctx: CommandContext): Promise<number> {
|
|
|
610
705
|
return 0;
|
|
611
706
|
}
|
|
612
707
|
|
|
708
|
+
/** The first package built here that pins an image digest release `digest` does not record (#4657), said in a sentence, or null. */
|
|
709
|
+
async function unknownPackagePins(cwd: string, digest: string): Promise<string | null> {
|
|
710
|
+
const { loadChantConfig } = await import("../../config");
|
|
711
|
+
const { readRelease } = await import("../../lifecycle/release-store");
|
|
712
|
+
const { packagePinProblem } = await import("../../lifecycle/release-images");
|
|
713
|
+
const targets = (await loadChantConfig(cwd).catch(() => null))?.config.release?.publish ?? [];
|
|
714
|
+
const release = await readRelease(digest, { cwd });
|
|
715
|
+
return release ? packagePinProblem(cwd, release, targets) : null;
|
|
716
|
+
}
|
|
717
|
+
|
|
613
718
|
/**
|
|
614
719
|
* `release candidates [--env <env>] [--forge-issues] [--json]` (#4168 4.2):
|
|
615
720
|
* the green commits of trunk a release can be cut from, newest first, each
|
package/src/cli/main.ts
CHANGED
|
@@ -526,6 +526,11 @@ Releases:
|
|
|
526
526
|
release verify <label|digest> [--json]
|
|
527
527
|
Check, offline, that the release was signed by a key
|
|
528
528
|
.chant/allowed_signers lists at the release's commit.
|
|
529
|
+
release images <label|digest> [-o <file>] [--json]
|
|
530
|
+
Build the images release.images declares again from
|
|
531
|
+
the release's commit, refuse one whose digest is not
|
|
532
|
+
the recorded one, and write the recorded digests to
|
|
533
|
+
the file CHANT_RELEASE_DIGESTS names for the build.
|
|
529
534
|
release workflow [--forge github|gitlab|forgejo] [--install <command>]
|
|
530
535
|
[--build <command>] [--chant <command>] [--output <file>]
|
|
531
536
|
Write the publish workflow, run on a release/** tag.
|
|
@@ -1308,6 +1313,13 @@ Component release ledger + status:
|
|
|
1308
1313
|
runs the model command with no forge token, land
|
|
1309
1314
|
pushes the change, opens or updates the pull
|
|
1310
1315
|
request and records the run (--forge <kind>)
|
|
1316
|
+
commit prepare|run|land The commit jobs (#4722) the Op generator writes for
|
|
1317
|
+
a spec's commit: prepare decides from the comment or
|
|
1318
|
+
the failed check, the ledger's run count and the
|
|
1319
|
+
head's approvals, run runs the product's command
|
|
1320
|
+
with no forge token, land pushes the change to the
|
|
1321
|
+
pull request's branch and records the run
|
|
1322
|
+
(--forge <kind>)
|
|
1311
1323
|
components pr-env An environment per open pull request (#4298): up
|
|
1312
1324
|
--base <ref> --pr <n> applies the change to pr-<n>,
|
|
1313
1325
|
derived from ci.prEnvironment.template, once an
|
|
@@ -1876,6 +1888,8 @@ export const commandRegistry: CommandDef[] = [
|
|
|
1876
1888
|
{ name: "release publish", runsNoConfig: true, handler: async (ctx) => (await import("./handlers/release")).runReleasePublish(ctx) },
|
|
1877
1889
|
// #4049: check a release's signature offline.
|
|
1878
1890
|
{ name: "release verify", runsNoConfig: true, handler: async (ctx) => (await import("./handlers/release")).runReleaseVerify(ctx) },
|
|
1891
|
+
// #4657: build a release's images again in its publish job, checked against the digests it records.
|
|
1892
|
+
{ name: "release images", runsNoConfig: true, handler: async (ctx) => (await import("./handlers/release")).runReleaseImages(ctx) },
|
|
1879
1893
|
{ name: "release workflow", runsNoConfig: true, handler: async (ctx) => (await import("../workspace/release-workflow")).runReleaseWorkflow(ctx) },
|
|
1880
1894
|
// #4168 4.3: mode (b), chosen changes composed onto a base on chant/compose/<name>.
|
|
1881
1895
|
{ name: "release compose", runsNoConfig: true, handler: async (ctx) => (await import("./handlers/release")).runReleaseCompose(ctx) },
|
|
@@ -2039,6 +2053,9 @@ export const commandRegistry: CommandDef[] = [
|
|
|
2039
2053
|
{ name: "agent prepare", handler: async (ctx) => (await import("./handlers/agent")).runAgentCommandLine(ctx) },
|
|
2040
2054
|
{ name: "agent run", handler: async (ctx) => (await import("./handlers/agent")).runAgentCommandLine(ctx) },
|
|
2041
2055
|
{ name: "agent land", handler: async (ctx) => (await import("./handlers/agent")).runAgentCommandLine(ctx) },
|
|
2056
|
+
{ name: "commit prepare", handler: async (ctx) => (await import("./handlers/commit")).runCommitCommandLine(ctx) },
|
|
2057
|
+
{ name: "commit run", handler: async (ctx) => (await import("./handlers/commit")).runCommitCommandLine(ctx) },
|
|
2058
|
+
{ name: "commit land", handler: async (ctx) => (await import("./handlers/commit")).runCommitCommandLine(ctx) },
|
|
2042
2059
|
{ name: "components pr-env", requiresPlugins: true, handler: async (ctx) => (await import("./handlers/pr-env")).runComponentsPrEnv(ctx) },
|
|
2043
2060
|
{ name: "components status", requiresPlugins: true, handler: runComponentsStatus },
|
|
2044
2061
|
{ name: "components release", handler: runComponentsReleaseRecord },
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { describe, expect, test } from "vitest";
|
|
2
|
-
import { componentWaveOutputsFile, componentWaveSteps, componentWavesSpec, productDriftAgent, productPipelineJobs, productWavesSpec } from "./product-pipeline";
|
|
2
|
+
import { componentWaveOutputsFile, componentWaveSteps, componentWavesSpec, productCheckCommit, productDriftAgent, productPipelineJobs, productWavesSpec } from "./product-pipeline";
|
|
3
3
|
import { prApplyComment, prLoopSetup, PR_LOOP_IMAGE, PR_LOOP_SETUP, withProductBin } from "./pr-pipeline";
|
|
4
4
|
import { PLYWOOD, TERRAGUCCI } from "../__fixtures__/product-words";
|
|
5
5
|
import type { OpWavesSpec } from "../op/op-waves";
|
|
@@ -198,3 +198,30 @@ describe("the note job's read of the control repo (#4619)", () => {
|
|
|
198
198
|
});
|
|
199
199
|
});
|
|
200
200
|
|
|
201
|
+
|
|
202
|
+
describe("the commit jobs (#4722)", () => {
|
|
203
|
+
const words = { ...PLYWOOD, commands: { ...PLYWOOD.commands, fmt: "commit" as const } };
|
|
204
|
+
|
|
205
|
+
test("return each comment commit job's Op spec, with the settings checked", () => {
|
|
206
|
+
const pw = productPipelineJobs("github", "production", { words: only(words, "plan", "commit"), commits: [{ word: "fmt", command: ["tofu", "fmt"], allowed: ["infra/"], tokenEnv: "PUSH_TOKEN", runner: "small" }] });
|
|
207
|
+
expect(pw.comments.commit).toBe("/plywood fmt");
|
|
208
|
+
expect(pw.commits).toEqual([
|
|
209
|
+
{
|
|
210
|
+
comment: "/plywood fmt",
|
|
211
|
+
name: "plywood-fmt",
|
|
212
|
+
spec: { name: "plywood-fmt", trigger: { kind: "pull_request" }, commit: { on: "comment", comment: "/plywood fmt", command: ["tofu", "fmt"], allowed: ["infra/"], tokenEnv: "PUSH_TOKEN" }, runner: "small" },
|
|
213
|
+
},
|
|
214
|
+
]);
|
|
215
|
+
expect(() => productPipelineJobs("github", "production", { words: only(words, "plan", "commit"), commits: [{ word: "fmt", command: ["tofu", "fmt"], allowed: [] }] })).toThrow(/allowed/);
|
|
216
|
+
expect(() => productPipelineJobs("github", "production", { words: only(words, "plan", "commit"), commits: [{ word: "lint", command: ["tofu", "fmt"], allowed: ["infra/"] }] })).toThrow(/not a command the words map onto commit/);
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
test("words that name a commit command with no commit job are refused", () => {
|
|
220
|
+
expect(() => productPipelineJobs("github", "production", { words: only(words, "plan", "commit") })).toThrow(/needs a commit job/);
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
test("a check's commit rides on the check's own spec", () => {
|
|
224
|
+
expect(productCheckCommit(words, "fmt-check", { command: ["tofu", "fmt"], allowed: ["infra/"], findings: [3] })).toEqual({ on: "check", command: ["tofu", "fmt"], allowed: ["infra/"], findings: [3] });
|
|
225
|
+
expect(() => productCheckCommit(words, "fmt-check", { command: [], allowed: ["infra/"] })).toThrow(/argv/);
|
|
226
|
+
});
|
|
227
|
+
});
|
|
@@ -39,6 +39,7 @@ import type { DriverComponent } from "./driver";
|
|
|
39
39
|
import type { ScheduledOpSpec } from "../lexicon";
|
|
40
40
|
import type { CiRunner } from "../ci-jobs";
|
|
41
41
|
import { resolveAgentSpec, type OpAgentSpec } from "../ci-agent";
|
|
42
|
+
import { resolveCommitSpec, type OpCommitSpec } from "../ci-commit";
|
|
42
43
|
import type { CiResponses } from "../ci-respond";
|
|
43
44
|
|
|
44
45
|
/** Where the generator writes a product's waves spec, which chant reads at base (#4550). */
|
|
@@ -70,6 +71,15 @@ export interface ProductPipelineOptions extends Omit<PrLoopPipelineOptions, "wor
|
|
|
70
71
|
* scheduled Ops.
|
|
71
72
|
*/
|
|
72
73
|
agent?: boolean | ProductAgentOptions;
|
|
74
|
+
/**
|
|
75
|
+
* The product's commit jobs (#4722) that answer a comment: each one's
|
|
76
|
+
* `word` maps onto `commit` in the words, and `/<product> <word>` runs its
|
|
77
|
+
* command on the pull request's head and pushes the change. The pipeline
|
|
78
|
+
* returns each one's Op spec, which the product writes and generates as
|
|
79
|
+
* it does the agent's. A commit job after a check rides on the check's own
|
|
80
|
+
* Op spec instead ({@link productCheckCommit}).
|
|
81
|
+
*/
|
|
82
|
+
commits?: ProductCommitOptions[];
|
|
73
83
|
/**
|
|
74
84
|
* The product answers its `action` command (#4654) from a workflow of its
|
|
75
85
|
* own, such as terragucci's action workflow: `true` counts the command as
|
|
@@ -152,6 +162,8 @@ export interface ProductPipelineJobs {
|
|
|
152
162
|
* job with the write token.
|
|
153
163
|
*/
|
|
154
164
|
agent?: { comment: string; name: string; spec: ScheduledOpSpec };
|
|
165
|
+
/** The comment commit jobs (#4722), with `commits`: each one's comment, `/<product> <word>`, and the Op spec whose generated workflow runs it. */
|
|
166
|
+
commits?: Array<{ comment: string; name: string; spec: ScheduledOpSpec }>;
|
|
155
167
|
/**
|
|
156
168
|
* The action job (#4654), with `actionJob`: the comment and the dispatch
|
|
157
169
|
* inputs it answers, and the product's action verb it runs. The GitHub and
|
|
@@ -168,6 +180,39 @@ export interface ProductAgentOptions extends Omit<OpAgentSpec, "on" | "comment"
|
|
|
168
180
|
runner?: CiRunner;
|
|
169
181
|
}
|
|
170
182
|
|
|
183
|
+
/** A comment commit job as a product passes it (#4722): {@link OpCommitSpec} without the trigger, with the word it answers. */
|
|
184
|
+
export interface ProductCommitOptions extends Omit<OpCommitSpec, "on" | "comment" | "findings" | "gitlabCheck"> {
|
|
185
|
+
/** The word after `/<product>`, which the words map onto `commit`: `fmt` for `/terragucci fmt`. */
|
|
186
|
+
word: string;
|
|
187
|
+
/** The job's name: its workflow, its jobs and its runs on the ledger. Default `<product>-<word>`. */
|
|
188
|
+
name?: string;
|
|
189
|
+
runner?: CiRunner;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/** A comment commit job's Op spec (#4722). The settings are checked here, so a product finds a bad one when it generates. */
|
|
193
|
+
export function productCommitSpec(wordsIn: CiProductWordsInput | CiProductWords, options: ProductCommitOptions): ScheduledOpSpec {
|
|
194
|
+
const words = assertProductWords(wordsIn);
|
|
195
|
+
const { word, name: given, runner, ...settings } = options;
|
|
196
|
+
if (words.commands[word] !== "commit") throw new Error(`the commit job's word ${JSON.stringify(word)} is not a command the words map onto commit`);
|
|
197
|
+
const name = given ?? `${words.product}-${word}`;
|
|
198
|
+
const commit: OpCommitSpec = { on: "comment", comment: `/${words.product} ${word}`, ...settings };
|
|
199
|
+
resolveCommitSpec(name, commit, words.product);
|
|
200
|
+
return { name, trigger: { kind: "pull_request" }, commit, ...(runner !== undefined ? { runner } : {}) };
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* The `commit` of a check's Op spec (#4722): after the check's run exits
|
|
205
|
+
* with one of `findings` on a pull request, the command runs on the head
|
|
206
|
+
* and its change is pushed to the pull request's branch. The check's spec
|
|
207
|
+
* needs a `pull_request` trigger.
|
|
208
|
+
*/
|
|
209
|
+
export function productCheckCommit(wordsIn: CiProductWordsInput | CiProductWords, op: string, options: Omit<OpCommitSpec, "on" | "comment">): OpCommitSpec {
|
|
210
|
+
const words = assertProductWords(wordsIn);
|
|
211
|
+
const commit: OpCommitSpec = { on: "check", ...options };
|
|
212
|
+
resolveCommitSpec(op, commit, words.product);
|
|
213
|
+
return commit;
|
|
214
|
+
}
|
|
215
|
+
|
|
171
216
|
/** The agent's Op spec for `/<product> agent <ask>` (#4616). The settings are checked here, so a product finds a bad one when it generates. */
|
|
172
217
|
export function productAgentSpec(wordsIn: CiProductWordsInput | CiProductWords, comment: string, options: ProductAgentOptions = {}): ScheduledOpSpec {
|
|
173
218
|
const words = assertProductWords(wordsIn);
|
|
@@ -219,6 +264,7 @@ export function productPipelineJobs(forge: ForgeKind, env: string, options: Prod
|
|
|
219
264
|
if (options.applyBeforeMerge || options.waves || options.componentWaves) jobs.push("apply");
|
|
220
265
|
if (options.locks === "plan") jobs.push("lock", "unlock");
|
|
221
266
|
if (options.agent) jobs.push("agent");
|
|
267
|
+
if (options.commits?.length) jobs.push("commit");
|
|
222
268
|
// #4654: the action command, answered by the product's own workflow (`actions`) or by the pipeline's action job.
|
|
223
269
|
if (options.actions || options.actionJob) jobs.push("action");
|
|
224
270
|
// #4601: the note's merge sentence follows the jobs built here: waves on merge, an apply before merge, else a record for a release.
|
|
@@ -226,7 +272,7 @@ export function productPipelineJobs(forge: ForgeKind, env: string, options: Prod
|
|
|
226
272
|
const built: CiProductApplyMode = options.waves || options.componentWaves ? "on-merge" : options.applyBeforeMerge ? "before-merge" : "release";
|
|
227
273
|
const applyMode: CiProductApplyMode = options.words.applyMode === "before-merge" && options.applyBeforeMerge ? "before-merge" : built;
|
|
228
274
|
const words = assertProductWords({ ...options.words, applyMode }, { jobs });
|
|
229
|
-
const { waves: given, wavesSpecFile, member, agent: _agent, actions: _actions, componentWaves, ...loop } = options;
|
|
275
|
+
const { waves: given, wavesSpecFile, member, agent: _agent, commits: _commits, actions: _actions, componentWaves, ...loop } = options;
|
|
230
276
|
const { respond } = options;
|
|
231
277
|
// #4629: the pull request loop puts the responses on the apply and note jobs, as `chant build --pr-loop --respond` does.
|
|
232
278
|
const prLoop: PrLoopPipelineOptions = { ...loop, words, gate: options.gate ?? words.prGate };
|
|
@@ -263,6 +309,13 @@ export function productPipelineJobs(forge: ForgeKind, env: string, options: Prod
|
|
|
263
309
|
const spec = productAgentSpec(words, agentComment, options.agent === true ? {} : options.agent);
|
|
264
310
|
out.agent = { comment: agentComment, name: spec.name, spec };
|
|
265
311
|
}
|
|
312
|
+
// #4722: each comment commit job answers its own word from a workflow of its own.
|
|
313
|
+
if (options.commits?.length) {
|
|
314
|
+
out.commits = options.commits.map((c) => {
|
|
315
|
+
const spec = productCommitSpec(words, c);
|
|
316
|
+
return { comment: spec.commit!.comment!, name: spec.name, spec };
|
|
317
|
+
});
|
|
318
|
+
}
|
|
266
319
|
// #4588: without a spec of the product's own, the component graph's waves on op waves.
|
|
267
320
|
const op = words.op ?? componentWaves?.waveGate ?? words.prGate;
|
|
268
321
|
const spec = given ?? (componentWaves
|
|
@@ -52,6 +52,7 @@ import { DriverRunFailure, runInterpretDriver, type DriverComponent, type Driver
|
|
|
52
52
|
import type { CapabilityRegistry, ReleaseInputs, ReleaseInputsUnbound } from "./capability";
|
|
53
53
|
import { memoryGateLedgerPort } from "../op/gate";
|
|
54
54
|
import type { ReleaseArtifact, ReleaseParam } from "../lifecycle/release-store";
|
|
55
|
+
import { RELEASE_DIGESTS_ENV } from "../lifecycle/release-images";
|
|
55
56
|
|
|
56
57
|
/** The deploy step fields whose literal file paths are a component's templates. */
|
|
57
58
|
export { TEMPLATE_FIELDS } from "./deploy-inputs";
|
|
@@ -297,6 +298,8 @@ export interface CompileInputs {
|
|
|
297
298
|
* reads the variable. Unset for a cut with no label.
|
|
298
299
|
*/
|
|
299
300
|
releaseLabel?: string;
|
|
301
|
+
/** The digests file of the images the cut built (#4657), passed to the build command as `CHANT_RELEASE_DIGESTS`. */
|
|
302
|
+
releaseDigests?: string;
|
|
300
303
|
}
|
|
301
304
|
|
|
302
305
|
/** The variable a cut's label reaches the build through (#4168). */
|
|
@@ -359,7 +362,7 @@ export async function compileEnvironment(inputs: CompileInputs, env: string): Pr
|
|
|
359
362
|
cwd: inputs.projectDir,
|
|
360
363
|
shell: true,
|
|
361
364
|
stdio: ["ignore", 2, 2],
|
|
362
|
-
env: { ...process.env, CHANT_ENV: env },
|
|
365
|
+
env: { ...process.env, CHANT_ENV: env, ...(inputs.releaseDigests ? { [RELEASE_DIGESTS_ENV]: inputs.releaseDigests } : {}) },
|
|
363
366
|
});
|
|
364
367
|
if (run.status !== 0) throw new ReleaseCompileError(`the build command for "${env}" exited ${run.status ?? "with a signal"}: ${inputs.buildCommand}`);
|
|
365
368
|
}
|
|
@@ -571,13 +574,16 @@ function runChild(
|
|
|
571
574
|
cwd: string,
|
|
572
575
|
env: string,
|
|
573
576
|
releaseLabel?: string,
|
|
577
|
+
releaseDigests?: string,
|
|
574
578
|
): Promise<{ code: number; stdout: string; stderr: string }> {
|
|
575
579
|
return new Promise((resolvePromise, reject) => {
|
|
576
580
|
const [bin, ...lead] = command;
|
|
577
581
|
const childEnv: NodeJS.ProcessEnv = { ...process.env, CHANT_ENV: env };
|
|
578
|
-
// A label never leaks in from the caller's shell: only the cut sets it.
|
|
582
|
+
// A label never leaks in from the caller's shell: only the cut sets it. Nor do the digests (#4657).
|
|
579
583
|
delete childEnv[RELEASE_LABEL_ENV];
|
|
584
|
+
delete childEnv[RELEASE_DIGESTS_ENV];
|
|
580
585
|
if (releaseLabel !== undefined) childEnv[RELEASE_LABEL_ENV] = releaseLabel;
|
|
586
|
+
if (releaseDigests !== undefined) childEnv[RELEASE_DIGESTS_ENV] = releaseDigests;
|
|
581
587
|
const child = spawn(bin, [...lead, ...args], { cwd, stdio: ["ignore", "pipe", "pipe"], env: childEnv });
|
|
582
588
|
const out: Buffer[] = [];
|
|
583
589
|
const err: Buffer[] = [];
|
|
@@ -607,7 +613,7 @@ export function spawnTargetCompiler(inputs: CompileInputs, command: readonly str
|
|
|
607
613
|
return args;
|
|
608
614
|
};
|
|
609
615
|
const call = async (env: string, extra: string[]): Promise<unknown> => {
|
|
610
|
-
const run = await runChild(command, ["release", "compile", "--env", env, ...common(), ...extra, "--json"], inputs.projectDir, env, inputs.releaseLabel);
|
|
616
|
+
const run = await runChild(command, ["release", "compile", "--env", env, ...common(), ...extra, "--json"], inputs.projectDir, env, inputs.releaseLabel, inputs.releaseDigests);
|
|
611
617
|
if (run.code !== 0) throw new ReleaseCompileError(`compiling "${env}" failed (exit ${run.code})`);
|
|
612
618
|
try {
|
|
613
619
|
return JSON.parse(run.stdout);
|
package/src/config.ts
CHANGED
|
@@ -109,7 +109,23 @@ export const ChantConfigSchema = z.object({
|
|
|
109
109
|
release: z.object({
|
|
110
110
|
autoRecord: z.boolean().optional(),
|
|
111
111
|
publish: z.array(PublishDeclarationSchema).optional(),
|
|
112
|
+
images: z.array(z.object({ name: z.string().min(1), build: z.string().min(1), archive: z.string().min(1) }).strict()).optional(),
|
|
112
113
|
lane: z.string().regex(/^[a-z0-9][a-z0-9-]*$/, "a ci.green lane name: lowercase letters, digits and dashes").optional(),
|
|
114
|
+
workflow: z.object({
|
|
115
|
+
trigger: z.enum(["tag", "dispatch"]).optional(),
|
|
116
|
+
gate: z.enum(["last-green", "head"]).optional(),
|
|
117
|
+
install: z.string().min(1).optional(),
|
|
118
|
+
build: z.union([z.string().min(1), z.literal(false)]).optional(),
|
|
119
|
+
chant: z.string().min(1).optional(),
|
|
120
|
+
after: z.array(z.string().min(1)).optional(),
|
|
121
|
+
permissions: z.record(z.string(), z.enum(["read", "write"])).optional(),
|
|
122
|
+
env: z.record(z.string(), z.string()).optional(),
|
|
123
|
+
setup: z.array(z.union([
|
|
124
|
+
z.object({ uses: z.string().min(1), with: z.record(z.string(), z.union([z.string(), z.number(), z.boolean()])).optional(), env: z.record(z.string(), z.string()).optional() }).strict(),
|
|
125
|
+
z.object({ run: z.string().min(1), env: z.record(z.string(), z.string()).optional() }).strict(),
|
|
126
|
+
])).optional(),
|
|
127
|
+
file: z.string().regex(/^[^/][^\0]*$/, "a path from the repository root").refine((f) => !f.split("/").includes(".."), "a path inside the repository").optional(),
|
|
128
|
+
}).strict().optional(),
|
|
113
129
|
}).optional(),
|
|
114
130
|
// Strict: a misspelt key here would leave Ops on the local runtime with
|
|
115
131
|
// nothing said (#2523).
|
|
@@ -372,6 +388,14 @@ export interface ChantConfig {
|
|
|
372
388
|
* the order given. See ./lifecycle/publish-declaration.ts.
|
|
373
389
|
*/
|
|
374
390
|
publish?: PublishDeclaration[];
|
|
391
|
+
/**
|
|
392
|
+
* Images the cut builds before the release's build command (#4657): each
|
|
393
|
+
* `build` writes the OCI archive at `archive`, and the cut records its
|
|
394
|
+
* digest and hands every digest to the build through `CHANT_RELEASE_DIGESTS`,
|
|
395
|
+
* so a package can pin the images it ships with. An `oci` target pushes
|
|
396
|
+
* the archive. See ./lifecycle/release-images.ts.
|
|
397
|
+
*/
|
|
398
|
+
images?: Array<{ name: string; build: string; archive: string }>;
|
|
375
399
|
/**
|
|
376
400
|
* The green lane `chant release cut` and `chant release candidates` check
|
|
377
401
|
* when `--lane` is not given (#4692): one `ci.green.lanes` declares in
|
|
@@ -379,6 +403,13 @@ export interface ChantConfig {
|
|
|
379
403
|
* rather than `ci/green/<sha>`.
|
|
380
404
|
*/
|
|
381
405
|
lane?: string;
|
|
406
|
+
/**
|
|
407
|
+
* The release pipeline `chant release workflow` writes (#4656): a
|
|
408
|
+
* dispatched release with gate, cut, publish and post-release jobs, the
|
|
409
|
+
* install and build commands, and the steps after the publish. See
|
|
410
|
+
* {@link import("./workspace/release-workflow").ReleasePipelineConfig}.
|
|
411
|
+
*/
|
|
412
|
+
workflow?: import("./workspace/release-workflow").ReleasePipelineConfig;
|
|
382
413
|
};
|
|
383
414
|
|
|
384
415
|
/** Defaults for `chant run` and its subcommands (#2523). */
|