@intentius/chant 0.124.64 → 0.124.65
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/cli/handlers/release.d.ts.map +1 -1
- package/dist/cli/handlers/release.js +20 -2
- package/dist/cli/handlers/run.d.ts +30 -1
- package/dist/cli/handlers/run.d.ts.map +1 -1
- package/dist/cli/handlers/run.js +108 -7
- package/dist/cli/main.d.ts.map +1 -1
- package/dist/cli/main.js +17 -2
- package/dist/cli/parse-args.d.ts.map +1 -1
- package/dist/cli/parse-args.js +7 -0
- package/dist/cli/registry.d.ts +5 -1
- package/dist/cli/registry.d.ts.map +1 -1
- package/dist/components/cli-support.d.ts +19 -1
- package/dist/components/cli-support.d.ts.map +1 -1
- package/dist/components/cli-support.js +11 -3
- package/dist/components/component.d.ts +19 -0
- package/dist/components/component.d.ts.map +1 -1
- package/dist/components/component.schema.json +17 -0
- package/dist/components/index.d.ts +1 -1
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/release-run.d.ts +48 -0
- package/dist/components/release-run.d.ts.map +1 -0
- package/dist/components/release-run.js +166 -0
- package/dist/components/starter-plugin.d.ts +1 -0
- package/dist/components/starter-plugin.d.ts.map +1 -1
- package/dist/components/starter-plugin.js +5 -1
- package/dist/components/unchanged-inputs.d.ts +81 -0
- package/dist/components/unchanged-inputs.d.ts.map +1 -0
- package/dist/components/unchanged-inputs.js +122 -0
- package/dist/components/verbs/index.d.ts +1 -0
- package/dist/components/verbs/index.d.ts.map +1 -1
- package/dist/components/verbs/index.js +1 -0
- package/dist/components/verbs/release-image.d.ts +36 -0
- package/dist/components/verbs/release-image.d.ts.map +1 -0
- package/dist/components/verbs/release-image.js +33 -0
- package/dist/lifecycle/delivery-metrics.d.ts.map +1 -1
- package/dist/lifecycle/delivery-metrics.js +4 -2
- package/dist/lifecycle/gate-statement.d.ts.map +1 -1
- package/dist/lifecycle/gate-statement.js +1 -2
- package/dist/lifecycle/git.d.ts.map +1 -1
- package/dist/lifecycle/git.js +6 -1
- package/dist/lifecycle/ledger-read.js +1 -1
- package/dist/lifecycle/publish-homebrew.d.ts.map +1 -1
- package/dist/lifecycle/publish-homebrew.js +1 -2
- package/dist/lifecycle/publish-marketplace.d.ts.map +1 -1
- package/dist/lifecycle/publish-marketplace.js +2 -3
- package/dist/lifecycle/query.d.ts +2 -2
- package/dist/lifecycle/query.d.ts.map +1 -1
- package/dist/lifecycle/query.js +3 -3
- package/dist/lifecycle/release-cut.d.ts +32 -2
- package/dist/lifecycle/release-cut.d.ts.map +1 -1
- package/dist/lifecycle/release-cut.js +47 -7
- package/dist/lifecycle/release-ledger.d.ts +11 -0
- package/dist/lifecycle/release-ledger.d.ts.map +1 -1
- package/dist/lifecycle/release-store.d.ts +17 -3
- package/dist/lifecycle/release-store.d.ts.map +1 -1
- package/dist/lifecycle/release-store.js +11 -3
- package/dist/op/activities/activity-contracts.d.ts +4 -4
- package/dist/op/op-waves-run.js +5 -3
- package/dist/release-floors.d.ts +1 -1
- package/dist/release-floors.js +1 -1
- package/dist/wave-runtime.mjs +237 -237
- package/dist/workspace/delivery-metrics.schema.json +1 -1
- package/dist/workspace/release-candidates.d.ts.map +1 -1
- package/dist/workspace/release-candidates.js +1 -2
- package/dist/workspace/releases.schema.json +7 -2
- package/package.json +1 -1
- package/src/cli/handlers/release.ts +18 -2
- package/src/cli/handlers/run-unchanged.e2e.test.ts +112 -0
- package/src/cli/handlers/run.ts +117 -7
- package/src/cli/main.ts +17 -2
- package/src/cli/parse-args.ts +6 -0
- package/src/cli/registry.ts +5 -1
- package/src/components/cli-support.test.ts +53 -0
- package/src/components/cli-support.ts +26 -4
- package/src/components/component.schema.json +17 -0
- package/src/components/component.ts +20 -0
- package/src/components/index.ts +1 -0
- package/src/components/registry.test.ts +1 -1
- package/src/components/release-run.test.ts +127 -0
- package/src/components/release-run.ts +188 -0
- package/src/components/starter-plugin.ts +5 -0
- package/src/components/unchanged-inputs.test.ts +98 -0
- package/src/components/unchanged-inputs.ts +151 -0
- package/src/components/verbs/index.ts +1 -0
- package/src/components/verbs/release-image.ts +52 -0
- package/src/lifecycle/delivery-metrics.ts +4 -2
- package/src/lifecycle/gate-statement.ts +1 -2
- package/src/lifecycle/git.test.ts +15 -0
- package/src/lifecycle/git.ts +5 -1
- package/src/lifecycle/ledger-read.ts +1 -1
- package/src/lifecycle/publish-homebrew.ts +1 -2
- package/src/lifecycle/publish-marketplace.ts +2 -3
- package/src/lifecycle/query.ts +3 -3
- package/src/lifecycle/release-cut-lane.test.ts +18 -0
- package/src/lifecycle/release-cut-override.test.ts +12 -0
- package/src/lifecycle/release-cut.test.ts +45 -0
- package/src/lifecycle/release-cut.ts +67 -7
- package/src/lifecycle/release-ledger.ts +11 -0
- package/src/lifecycle/release-store.ts +29 -5
- package/src/op/op-waves-run.ts +4 -2
- package/src/release-floors.ts +1 -1
- package/src/workspace/delivery-metrics.schema.json +1 -1
- package/src/workspace/delivery-metrics.test.ts +8 -0
- package/src/workspace/release-candidates.ts +1 -2
- package/src/workspace/releases.schema.json +7 -2
|
@@ -191,7 +191,7 @@
|
|
|
191
191
|
"count": {
|
|
192
192
|
"type": "integer",
|
|
193
193
|
"minimum": 0,
|
|
194
|
-
"description": "Deploy records whose timestamp is in the window, leaving out redeploys. Rollbacks count."
|
|
194
|
+
"description": "Deploy records whose timestamp is in the window, leaving out redeploys. Rollbacks count. A record with unchangedSince (#4695) deployed nothing and is in no metric."
|
|
195
195
|
},
|
|
196
196
|
"redeploys": {
|
|
197
197
|
"type": "integer",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"release-candidates.d.ts","sourceRoot":"","sources":["../../src/workspace/release-candidates.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;
|
|
1
|
+
{"version":3,"file":"release-candidates.d.ts","sourceRoot":"","sources":["../../src/workspace/release-candidates.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;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AM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,GAAG,MAAM,GAAG,IAAI,CAGlF;AAED;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,SAAS,eAAe,EAAE,GAAG,cAAc,EAAE,CAsBlF;AAED,gEAAgE;AAChE,wBAAsB,yBAAyB,CAAC,KAAK,EAAE,sBAAsB,GAAG,OAAO,CAAC,yBAAyB,CAAC,CAoJjH"}
|
|
@@ -43,7 +43,6 @@
|
|
|
43
43
|
*/
|
|
44
44
|
import { execFileSync } from "node:child_process";
|
|
45
45
|
import { relative, resolve, sep } from "node:path";
|
|
46
|
-
import { NEXT_RELEASE } from "../release-floors.js";
|
|
47
46
|
import { latestPerComponent, readReleaseLedger } from "../lifecycle/release-ledger.js";
|
|
48
47
|
import { readAllReleases, readCuts } from "../lifecycle/release-store.js";
|
|
49
48
|
import { resolveMemberLedger } from "../lifecycle/member-ledger.js";
|
|
@@ -53,7 +52,7 @@ export const RELEASE_CANDIDATES_CONTRACT_VERSION = 1;
|
|
|
53
52
|
/** The first chant whose candidates carry `changes[].closes` and `groups[].issue` (#4649). */
|
|
54
53
|
export const RELEASE_CANDIDATES_CLOSES_FLOOR = "0.124.63";
|
|
55
54
|
/** The first chant whose candidates document carries `lane` and reads a lane's tags (#4692). */
|
|
56
|
-
export const RELEASE_CANDIDATES_LANE_FLOOR =
|
|
55
|
+
export const RELEASE_CANDIDATES_LANE_FLOOR = "0.124.64";
|
|
57
56
|
export const RELEASE_CANDIDATES_SCHEMA_ID = "https://intentius.io/chant/schemas/workspace/release-candidates/v1/release-candidates.schema.json";
|
|
58
57
|
/** Why the read stopped. Closed; each code is in `reason-codes.ts`. */
|
|
59
58
|
export const RELEASE_CANDIDATES_ERROR_CODES = ["not-a-git-repository", "ledger-unreadable"];
|
|
@@ -113,7 +113,7 @@
|
|
|
113
113
|
},
|
|
114
114
|
"artifactDigests": {
|
|
115
115
|
"type": "array",
|
|
116
|
-
"description": "Each image and asset built once from the commit, sorted by component, then path. A config-only release carries the previous release's entries.",
|
|
116
|
+
"description": "Each image and asset built once from the commit, or handed to the cut by digest, sorted by component, then path. A config-only release carries the previous release's entries.",
|
|
117
117
|
"items": {
|
|
118
118
|
"type": "object",
|
|
119
119
|
"required": [
|
|
@@ -133,11 +133,16 @@
|
|
|
133
133
|
]
|
|
134
134
|
},
|
|
135
135
|
"path": {
|
|
136
|
-
"type": "string"
|
|
136
|
+
"type": "string",
|
|
137
|
+
"description": "The archive path the build step wrote. Empty for an image handed to the cut."
|
|
137
138
|
},
|
|
138
139
|
"digest": {
|
|
139
140
|
"type": "string",
|
|
140
141
|
"minLength": 1
|
|
142
|
+
},
|
|
143
|
+
"ref": {
|
|
144
|
+
"type": "string",
|
|
145
|
+
"description": "An image handed to the cut by digest (chant release cut --image, #4694), as <repository>@<digest>: the image a deploy under the release runs. Absent on an artifact the cut built. Written by chant 0.124.65 and newer."
|
|
141
146
|
}
|
|
142
147
|
}
|
|
143
148
|
}
|
package/package.json
CHANGED
|
@@ -49,7 +49,7 @@ import { parseParamFlags } from "../build-params-cli";
|
|
|
49
49
|
import type { CommandContext } from "../registry";
|
|
50
50
|
|
|
51
51
|
const USAGE =
|
|
52
|
-
"chant release cut [<label>] [--at <sha>] [--yes] [--build <command>] [--param <k=v>] [--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]";
|
|
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
53
|
|
|
54
54
|
/** The build inputs `release cut` and `release compile` share. */
|
|
55
55
|
function compileInputs(
|
|
@@ -249,6 +249,19 @@ export async function runReleaseCut(ctx: CommandContext): Promise<number> {
|
|
|
249
249
|
const tag = label !== null && commit !== null && top ? { name: ws.releaseTagName(member, label), state: ws.checkReleaseTag(top, ws.releaseTagName(member, label), commit) } : null;
|
|
250
250
|
const ci = resolveCiRun(process.env);
|
|
251
251
|
const params = parseParamFlags(args.param);
|
|
252
|
+
// #4694: images built elsewhere, handed to the cut by digest, one per component.
|
|
253
|
+
const images: Record<string, string> = {};
|
|
254
|
+
for (const value of args.images ?? []) {
|
|
255
|
+
const eq = value.indexOf("=");
|
|
256
|
+
const component = eq > 0 ? value.slice(0, eq) : "";
|
|
257
|
+
if (!component || eq === value.length - 1) {
|
|
258
|
+
return fail("release-image-invalid", `--image ${value}: name the component and the image, as --image <component>=<repository>@sha256:<hex>`);
|
|
259
|
+
}
|
|
260
|
+
if (images[component] !== undefined && images[component] !== value.slice(eq + 1)) {
|
|
261
|
+
return fail("release-image-invalid", `--image names two images for "${component}"; a release records one image per component`);
|
|
262
|
+
}
|
|
263
|
+
images[component] = value.slice(eq + 1);
|
|
264
|
+
}
|
|
252
265
|
// --at: the cut reads, compiles and builds the commit's tree, not the checkout's.
|
|
253
266
|
if (args.at !== undefined && top && commit) checkout = at.checkoutCommit(top, cwd, commit);
|
|
254
267
|
const cutCwd = checkout?.memberDir ?? cwd;
|
|
@@ -265,6 +278,7 @@ export async function runReleaseCut(ctx: CommandContext): Promise<number> {
|
|
|
265
278
|
...(args.channel ? { channel: args.channel } : {}),
|
|
266
279
|
...(lane !== undefined ? { lane } : {}),
|
|
267
280
|
...(args.overrideGreen ? { overrideGreen: true } : {}),
|
|
281
|
+
...(Object.keys(images).length > 0 ? { images } : {}),
|
|
268
282
|
};
|
|
269
283
|
|
|
270
284
|
if (dryRun) {
|
|
@@ -333,6 +347,7 @@ export async function runReleaseCut(ctx: CommandContext): Promise<number> {
|
|
|
333
347
|
}
|
|
334
348
|
for (const b of plan.build) console.log(` ${b.component}: artifacts built in ${b.env}`);
|
|
335
349
|
for (const r of plan.reused) console.log(` ${r.component}: artifacts unchanged, carried from ${r.from}`);
|
|
350
|
+
for (const h of plan.handed) console.log(` ${h.component}: image ${h.ref}, handed to the cut, not built`);
|
|
336
351
|
console.log(` digest ${plan.releaseDigest ?? "decided when the artifacts are built"}`);
|
|
337
352
|
console.log("What will be published where:");
|
|
338
353
|
if (plan.publishSteps.length === 0) console.log(" no component declares a publish step");
|
|
@@ -374,7 +389,7 @@ export async function runReleaseCut(ctx: CommandContext): Promise<number> {
|
|
|
374
389
|
if (args.json) {
|
|
375
390
|
console.log(
|
|
376
391
|
JSON.stringify(
|
|
377
|
-
{ dryRun: false, release: result.release, label: result.label, cut: result.cut, stored: result.stored, reused: result.reused, actor, actorSource: who.source, tag: tagged, composed: composed ?? null, channel: args.channel ?? null, lane: lane ?? null, next },
|
|
392
|
+
{ dryRun: false, release: result.release, label: result.label, cut: result.cut, stored: result.stored, reused: result.reused, handed: result.handed, actor, actorSource: who.source, tag: tagged, composed: composed ?? null, channel: args.channel ?? null, lane: lane ?? null, next },
|
|
378
393
|
null,
|
|
379
394
|
2,
|
|
380
395
|
),
|
|
@@ -389,6 +404,7 @@ export async function runReleaseCut(ctx: CommandContext): Promise<number> {
|
|
|
389
404
|
if (result.cut) console.error(` ${result.cut.signature ? `signed by ${result.cut.actor}` : `not signed; actor ${result.cut.actor}`}, run ${result.cut.runId}`);
|
|
390
405
|
console.error(` artifacts ${result.release.artifactDigests.length}, targets ${result.release.targets.map((t) => `${t.env} (${t.templates.length} template${t.templates.length === 1 ? "" : "s"})`).join(", ")}`);
|
|
391
406
|
for (const r of result.reused) console.error(` ${r.component}: artifacts unchanged, carried from ${r.from}`);
|
|
407
|
+
for (const h of result.handed) console.error(` ${h.component}: image ${h.ref}, handed to the cut`);
|
|
392
408
|
if (tagged) console.error(` tag ${tagged.name}${tagged.created ? "" : " (already there)"}, not pushed`);
|
|
393
409
|
console.error(`Next: ${next[0]}`);
|
|
394
410
|
for (const n of next.slice(1)) console.error(` or: ${n}`);
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A run under a release skips a component whose declared inputs did not
|
|
3
|
+
* change since the release the environment runs it from, and records the
|
|
4
|
+
* skip (#4695). A temp repo with no remote, real cuts and a real ledger.
|
|
5
|
+
*/
|
|
6
|
+
import { describe, expect, test } from "vitest";
|
|
7
|
+
import { withTestDir } from "@intentius/chant-test-utils";
|
|
8
|
+
import { spawnSync } from "node:child_process";
|
|
9
|
+
import { mkdirSync, writeFileSync } from "node:fs";
|
|
10
|
+
import { join } from "node:path";
|
|
11
|
+
import { cutRelease } from "../../lifecycle/release-cut";
|
|
12
|
+
import { appendReleaseRecord, latestPerComponent, readReleaseLedger } from "../../lifecycle/release-ledger";
|
|
13
|
+
import type { CompiledTarget, TargetCompiler } from "../../components/release-compile";
|
|
14
|
+
import type { DriverComponent } from "../../components/driver";
|
|
15
|
+
import { recordSkips, releaseRunPrepare, type Skipped } from "./run";
|
|
16
|
+
|
|
17
|
+
function git(dir: string, ...args: string[]): string {
|
|
18
|
+
const r = spawnSync("git", args, { cwd: dir, encoding: "utf-8" });
|
|
19
|
+
if (r.status !== 0) throw new Error(`git ${args.join(" ")}: ${r.stderr}`);
|
|
20
|
+
return r.stdout.trim();
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function commit(dir: string, file: string, content: string): string {
|
|
24
|
+
mkdirSync(join(dir, file, ".."), { recursive: true });
|
|
25
|
+
writeFileSync(join(dir, file), content);
|
|
26
|
+
git(dir, "add", ".");
|
|
27
|
+
git(dir, "commit", "-q", "-m", `change ${file}`);
|
|
28
|
+
const sha = git(dir, "rev-parse", "HEAD");
|
|
29
|
+
git(dir, "tag", `ci/green/${sha}`, sha);
|
|
30
|
+
return sha;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const compiler: TargetCompiler = {
|
|
34
|
+
async compile(env): Promise<CompiledTarget> {
|
|
35
|
+
return {
|
|
36
|
+
env,
|
|
37
|
+
params: [],
|
|
38
|
+
components: ["control"],
|
|
39
|
+
buildSteps: {},
|
|
40
|
+
buildInputs: {},
|
|
41
|
+
componentFiles: { control: "control.component.ts" },
|
|
42
|
+
templates: [{ component: "control", path: "dist/fly.json", content: `{"app":"illogical-control"}\n` }],
|
|
43
|
+
};
|
|
44
|
+
},
|
|
45
|
+
async buildArtifacts() {
|
|
46
|
+
return [];
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const image = (c: string) => `registry.fly.io/illogical-control@sha256:${c.repeat(64)}`;
|
|
51
|
+
const cut = (dir: string, label: string, digest: string) => cutRelease({ cwd: dir, compiler, label, actor: "ci", env: {}, images: { control: image(digest) } });
|
|
52
|
+
|
|
53
|
+
const control: DriverComponent = {
|
|
54
|
+
name: "control",
|
|
55
|
+
dependsOn: [],
|
|
56
|
+
deploy: [
|
|
57
|
+
{ phase: "Image", steps: [{ kind: "release-image" }] },
|
|
58
|
+
{ phase: "Release", steps: [{ kind: "fly-release", plan: "dist/fly.json", image: "@Image.uri", digest: "@Image.digest" }] },
|
|
59
|
+
],
|
|
60
|
+
};
|
|
61
|
+
const declared = { inputs: { control: { paths: ["crates/control"] } } };
|
|
62
|
+
|
|
63
|
+
describe("run --components --release with declared inputs (#4695)", () => {
|
|
64
|
+
test("skips and records a component whose inputs are unchanged; deploys one whose inputs changed, or with --deploy-unchanged", async () => {
|
|
65
|
+
await withTestDir(async (dir) => {
|
|
66
|
+
git(dir, "init", "-q", "-b", "main");
|
|
67
|
+
git(dir, "config", "user.email", "test@chant.dev");
|
|
68
|
+
git(dir, "config", "user.name", "Test");
|
|
69
|
+
writeFileSync(join(dir, "chant.config.ts"), `export default { environments: ["prod"] };\n`);
|
|
70
|
+
commit(dir, "crates/control/main.rs", "fn main() {}\n");
|
|
71
|
+
const r1 = await cut(dir, "v1", "a");
|
|
72
|
+
await appendReleaseRecord(
|
|
73
|
+
{ component: "control", env: "prod", digest: `sha256:${"a".repeat(64)}`, gitSha: r1.release.commit, runId: "run-1", timestamp: "2026-11-01T10:00:00.000Z", actor: "ci", releaseDigest: r1.release.releaseDigest },
|
|
74
|
+
{ cwd: dir },
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
// A commit outside the hub's inputs: the next release leaves it alone.
|
|
78
|
+
commit(dir, "web/index.html", "<p>hi</p>\n");
|
|
79
|
+
const r2 = await cut(dir, "v2", "b");
|
|
80
|
+
const skipped: Skipped = new Map();
|
|
81
|
+
const prepare = releaseRunPrepare({ releaseDigest: r2.release.releaseDigest, label: "v2", release: r2.release }, dir, "prod", { deployUnchanged: false, skipped });
|
|
82
|
+
const prepared = await prepare([control], declared);
|
|
83
|
+
expect(prepared).toEqual({ components: [{ ...control, deploy: [] }] });
|
|
84
|
+
expect([...skipped.keys()]).toEqual(["control"]);
|
|
85
|
+
|
|
86
|
+
const written = await recordSkips(skipped, r2.release.releaseDigest, { runId: "run-2" }, dir);
|
|
87
|
+
expect(written).toHaveLength(1);
|
|
88
|
+
const latest = latestPerComponent((await readReleaseLedger("prod", { cwd: dir })).records).get("control")!;
|
|
89
|
+
expect(latest).toMatchObject({
|
|
90
|
+
digest: `sha256:${"a".repeat(64)}`,
|
|
91
|
+
gitSha: r1.release.commit,
|
|
92
|
+
runId: "run-2",
|
|
93
|
+
releaseDigest: r2.release.releaseDigest,
|
|
94
|
+
unchangedSince: { env: "prod", runId: "run-1", timestamp: "2026-11-01T10:00:00.000Z" },
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
// --deploy-unchanged deploys it with the image v2 recorded.
|
|
98
|
+
const forced: Skipped = new Map();
|
|
99
|
+
const deployed = await releaseRunPrepare({ releaseDigest: r2.release.releaseDigest, label: "v2", release: r2.release }, dir, "prod", { deployUnchanged: true, skipped: forced })([control], declared);
|
|
100
|
+
expect(forced.size).toBe(0);
|
|
101
|
+
expect(deployed).toMatchObject({ components: [{ deploy: [{ phase: "Image", steps: [{ kind: "release-image", uri: image("b") }] }, control.deploy[1]] }] });
|
|
102
|
+
|
|
103
|
+
// A change to an input deploys it, compared against v2, which the skip record names.
|
|
104
|
+
commit(dir, "crates/control/main.rs", "fn main() { println!(); }\n");
|
|
105
|
+
const r3 = await cut(dir, "v3", "c");
|
|
106
|
+
const again: Skipped = new Map();
|
|
107
|
+
const changed = await releaseRunPrepare({ releaseDigest: r3.release.releaseDigest, label: "v3", release: r3.release }, dir, "prod", { deployUnchanged: false, skipped: again })([control], declared);
|
|
108
|
+
expect(again.size).toBe(0);
|
|
109
|
+
expect(changed).toMatchObject({ components: [{ deploy: [{ phase: "Image", steps: [{ kind: "release-image", uri: image("c") }] }, control.deploy[1]] }] });
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
});
|
package/src/cli/handlers/run.ts
CHANGED
|
@@ -1075,8 +1075,9 @@ function refusesNoRecordOn(runtime: Pick<OpRuntimeProvider, "name">): boolean {
|
|
|
1075
1075
|
|
|
1076
1076
|
/**
|
|
1077
1077
|
* Resolve the release `chant run --components --release` names (#4043), or the
|
|
1078
|
-
* reason it can't be used. The run
|
|
1078
|
+
* reason it can't be used. The run's compositions are the checkout's, so the
|
|
1079
1079
|
* release's commit must be HEAD, and the release needs a target for `env`.
|
|
1080
|
+
* The artifacts it deploys are the release's own (#4694, ../../components/release-run.ts).
|
|
1080
1081
|
*/
|
|
1081
1082
|
export async function resolveRunRelease(ref: string, env: string, cwd: string) {
|
|
1082
1083
|
const { fetchLifecycle, getHeadCommit } = await import("../../lifecycle/git");
|
|
@@ -1088,14 +1089,13 @@ export async function resolveRunRelease(ref: string, env: string, cwd: string) {
|
|
|
1088
1089
|
const name = found.label ?? found.release.releaseDigest;
|
|
1089
1090
|
const head = await getHeadCommit({ cwd });
|
|
1090
1091
|
if (found.release.commit !== head) {
|
|
1091
|
-
return `release ${name} was cut from ${found.release.commit.slice(0, 12)} and this checkout is at ${head.slice(0, 12)}; run
|
|
1092
|
+
return `release ${name} was cut from ${found.release.commit.slice(0, 12)} and this checkout is at ${head.slice(0, 12)}; run deploys the checkout's components, so check out the release's commit, or deploy it with \`chant components promote --release\``;
|
|
1092
1093
|
}
|
|
1093
1094
|
const target = targetFor(found.release, env);
|
|
1094
1095
|
if ("error" in target) return target.error;
|
|
1095
1096
|
return { releaseDigest: found.release.releaseDigest, label: found.label, release: found.release };
|
|
1096
1097
|
}
|
|
1097
1098
|
|
|
1098
|
-
/** A rebuilt image need not digest as the release's own did; say so, as promote does. Never fails the run. */
|
|
1099
1099
|
/** #4222: a component's templates digest in the release's target for `env`, or null when the release has no such target. */
|
|
1100
1100
|
async function releaseTemplatesDigestOf(release: import("../../lifecycle/release-store").Release, env: string): Promise<(component: string) => string | null> {
|
|
1101
1101
|
const { targetFor, releaseTemplatesDigest } = await import("../../components/release-promote");
|
|
@@ -1103,6 +1103,7 @@ async function releaseTemplatesDigestOf(release: import("../../lifecycle/release
|
|
|
1103
1103
|
return (component) => ("target" in found ? releaseTemplatesDigest(found.target, component) : null);
|
|
1104
1104
|
}
|
|
1105
1105
|
|
|
1106
|
+
/** A rebuilt image need not digest as the release's own did; say so, as promote does. Never fails the run. */
|
|
1106
1107
|
async function warnOnArtifactMismatch(release: import("../../lifecycle/release-store").Release, recorded: readonly ReleaseRecord[]): Promise<void> {
|
|
1107
1108
|
try {
|
|
1108
1109
|
const { releaseArtifactMismatches } = await import("../../components/release-promote");
|
|
@@ -1118,6 +1119,103 @@ async function warnOnArtifactMismatch(release: import("../../lifecycle/release-s
|
|
|
1118
1119
|
}
|
|
1119
1120
|
}
|
|
1120
1121
|
|
|
1122
|
+
/**
|
|
1123
|
+
* Record each component the run left alone (#4695): a record of the release
|
|
1124
|
+
* repeating the deploy that stays, named in `unchangedSince`. One whose
|
|
1125
|
+
* latest record already names the release gets none. Never fails the run.
|
|
1126
|
+
*/
|
|
1127
|
+
export async function recordSkips(
|
|
1128
|
+
skipped: Skipped,
|
|
1129
|
+
releaseDigest: string,
|
|
1130
|
+
run: { runId: string; runOrigin?: RunOrigin },
|
|
1131
|
+
cwd: string,
|
|
1132
|
+
): Promise<ReleaseRecord[]> {
|
|
1133
|
+
const fresh = [...skipped.values()].filter((v) => !v.recorded);
|
|
1134
|
+
if (fresh.length === 0) return [];
|
|
1135
|
+
const actor = process.env.GITHUB_ACTOR ?? process.env.GITLAB_USER_LOGIN ?? process.env.USER;
|
|
1136
|
+
if (!actor) {
|
|
1137
|
+
console.error(formatWarning({ message: `the skips of ${fresh.map((v) => v.since.component).join(", ")} were not recorded: no actor (GITHUB_ACTOR, GITLAB_USER_LOGIN or USER)` }));
|
|
1138
|
+
return [];
|
|
1139
|
+
}
|
|
1140
|
+
const { unchangedRecord } = await import("../../components/unchanged-inputs");
|
|
1141
|
+
const { appendReleaseRecord } = await import("../../lifecycle/release-ledger");
|
|
1142
|
+
const { pushLifecycleRebasing } = await import("../../lifecycle/git");
|
|
1143
|
+
const timestamp = new Date().toISOString();
|
|
1144
|
+
const written: ReleaseRecord[] = [];
|
|
1145
|
+
try {
|
|
1146
|
+
for (const v of fresh) {
|
|
1147
|
+
const { record } = await appendReleaseRecord(unchangedRecord(v.since, { releaseDigest, runId: run.runId, ...(run.runOrigin ? { runOrigin: run.runOrigin } : {}), timestamp, actor }), { cwd });
|
|
1148
|
+
written.push(record);
|
|
1149
|
+
console.error(`Recorded skip: ${formatBold(record.component)}@${record.env} keeps ${record.digest} under release ${releaseDigest}`);
|
|
1150
|
+
}
|
|
1151
|
+
await pushLifecycleRebasing({ cwd });
|
|
1152
|
+
} catch (err) {
|
|
1153
|
+
console.error(formatWarning({ message: `a skip was not recorded: ${err instanceof Error ? err.message : String(err)}` }));
|
|
1154
|
+
}
|
|
1155
|
+
return written;
|
|
1156
|
+
}
|
|
1157
|
+
|
|
1158
|
+
/** A component a run under a release left alone (#4695), and the deploy that stays. */
|
|
1159
|
+
export type Skipped = Map<string, import("../../components/unchanged-inputs").InputsVerdict & { unchanged: true }>;
|
|
1160
|
+
|
|
1161
|
+
/**
|
|
1162
|
+
* The compositions of a run under a release (#4694): each component the release
|
|
1163
|
+
* recorded an artifact for runs from it, with what was taken out printed to
|
|
1164
|
+
* stderr, or the run is refused with every reason. Unless `deployUnchanged`,
|
|
1165
|
+
* a component whose declared inputs are the same as in the release `env` runs
|
|
1166
|
+
* it from runs nothing and is added to `skipped` (#4695).
|
|
1167
|
+
*/
|
|
1168
|
+
export function releaseRunPrepare(
|
|
1169
|
+
under: { releaseDigest: string; label: string | null; release: import("../../lifecycle/release-store").Release },
|
|
1170
|
+
projectPath: string,
|
|
1171
|
+
env: string,
|
|
1172
|
+
skip: { deployUnchanged: boolean; skipped: Skipped },
|
|
1173
|
+
): NonNullable<import("../../components/cli-support").RunComponentsOptions["prepare"]> {
|
|
1174
|
+
return async (all, declared) => {
|
|
1175
|
+
let components = all;
|
|
1176
|
+
const declaring = components.filter((c) => declared.inputs[c.name] !== undefined);
|
|
1177
|
+
if (declaring.length > 0 && skip.deployUnchanged) {
|
|
1178
|
+
console.error(formatInfo(`--deploy-unchanged: deploying ${declaring.map((c) => c.name).join(", ")} whatever their inputs`));
|
|
1179
|
+
} else if (declaring.length > 0) {
|
|
1180
|
+
const { compareInputs, gitChangedPaths } = await import("../../components/unchanged-inputs");
|
|
1181
|
+
const { readReleaseLedger, latestPerComponent } = await import("../../lifecycle/release-ledger");
|
|
1182
|
+
const { readRelease } = await import("../../lifecycle/release-store");
|
|
1183
|
+
const current = latestPerComponent((await readReleaseLedger(env, { cwd: projectPath }).catch(() => ({ records: [] }))).records);
|
|
1184
|
+
for (const c of declaring) {
|
|
1185
|
+
const verdict = await compareInputs({
|
|
1186
|
+
component: c.name,
|
|
1187
|
+
inputs: declared.inputs[c.name]!,
|
|
1188
|
+
env,
|
|
1189
|
+
release: under.release,
|
|
1190
|
+
current: current.get(c.name),
|
|
1191
|
+
readRelease: (digest) => readRelease(digest, { cwd: projectPath }),
|
|
1192
|
+
changedPaths: gitChangedPaths(projectPath),
|
|
1193
|
+
});
|
|
1194
|
+
if (verdict.unchanged) {
|
|
1195
|
+
skip.skipped.set(c.name, verdict);
|
|
1196
|
+
console.error(formatInfo(`${c.name}: inputs unchanged since the deploy "${env}" runs (run ${verdict.since.runId}); not deploying it (--deploy-unchanged deploys it)`));
|
|
1197
|
+
} else {
|
|
1198
|
+
console.error(formatInfo(`${c.name}: deploying, since ${verdict.reason}`));
|
|
1199
|
+
}
|
|
1200
|
+
}
|
|
1201
|
+
// A skipped component stays in the run, so its dependents keep their order, and runs nothing.
|
|
1202
|
+
components = components.map((c) => (skip.skipped.has(c.name) ? { ...c, deploy: [] } : c));
|
|
1203
|
+
}
|
|
1204
|
+
const { releaseRunComponents } = await import("../../components/release-run");
|
|
1205
|
+
const result = releaseRunComponents(components, under.release, projectPath, under.label);
|
|
1206
|
+
if ("errors" in result) return { error: `${result.errors.join("\n")}\nnothing was deployed` };
|
|
1207
|
+
const name = under.label ?? under.releaseDigest;
|
|
1208
|
+
for (const note of result.notes) {
|
|
1209
|
+
const parts = [
|
|
1210
|
+
...(note.removed.length > 0 ? [`not building (${note.removed.join(", ")})`] : []),
|
|
1211
|
+
...(note.image ? [`image ${note.image}`] : []),
|
|
1212
|
+
];
|
|
1213
|
+
console.error(formatInfo(`${note.component}: release ${name}'s own artifact${parts.length > 0 ? `; ${parts.join("; ")}` : ""}`));
|
|
1214
|
+
}
|
|
1215
|
+
return { components: result.components };
|
|
1216
|
+
};
|
|
1217
|
+
}
|
|
1218
|
+
|
|
1121
1219
|
async function runComponentSelection(ctx: CommandContext): Promise<number> {
|
|
1122
1220
|
const selector = ctx.args.path;
|
|
1123
1221
|
if (!selector || selector === ".") {
|
|
@@ -1159,11 +1257,18 @@ async function runComponentSelection(ctx: CommandContext): Promise<number> {
|
|
|
1159
1257
|
const env = ctx.args.env ?? "local";
|
|
1160
1258
|
|
|
1161
1259
|
// #4043: `--release <label|digest>` says this run deploys that release. The
|
|
1162
|
-
// run
|
|
1163
|
-
// from it, and must have a target for the environment. Both are
|
|
1164
|
-
// before anything deploys; nothing is inferred when the flag is
|
|
1260
|
+
// run's compositions are the checked-out commit's, so the release must have
|
|
1261
|
+
// been cut from it, and must have a target for the environment. Both are
|
|
1262
|
+
// checked before anything deploys; nothing is inferred when the flag is
|
|
1263
|
+
// absent. #4694: a component the release recorded an artifact for runs from
|
|
1264
|
+
// it, without its build steps.
|
|
1165
1265
|
let underRelease: { releaseDigest: string; label: string | null; release: import("../../lifecycle/release-store").Release } | undefined;
|
|
1166
1266
|
if (ctx.args.release) {
|
|
1267
|
+
// #4694: the compositions are rewritten in this process, so a runtime that runs them elsewhere would build again.
|
|
1268
|
+
if (runtime.name !== "local") {
|
|
1269
|
+
console.error(formatError({ message: `--release runs the release's own artifacts on the local runtime, not on "${runtime.name}"`, hint: "Omit --on to run it here." }));
|
|
1270
|
+
return 1;
|
|
1271
|
+
}
|
|
1167
1272
|
const refused = await resolveRunRelease(ctx.args.release, env, projectPath);
|
|
1168
1273
|
if (typeof refused === "string") {
|
|
1169
1274
|
console.error(formatError({ message: refused, hint: "List the releases with: chant release list" }));
|
|
@@ -1235,6 +1340,8 @@ async function runComponentSelection(ctx: CommandContext): Promise<number> {
|
|
|
1235
1340
|
return 1;
|
|
1236
1341
|
}
|
|
1237
1342
|
}
|
|
1343
|
+
// #4695: the components a run under a release left alone, recorded after a successful run.
|
|
1344
|
+
const skipped: Skipped = new Map();
|
|
1238
1345
|
let result: RunComponentsResult;
|
|
1239
1346
|
try {
|
|
1240
1347
|
// #4594: ci.lockGrain, and on the resource grain each step's row lease in the pull-request loop's rows file.
|
|
@@ -1251,6 +1358,7 @@ async function runComponentSelection(ctx: CommandContext): Promise<number> {
|
|
|
1251
1358
|
sandbox: ctx.args.sandbox,
|
|
1252
1359
|
buildParams: paramsResolution.provenance,
|
|
1253
1360
|
...(onPlan ? { onPlan } : {}),
|
|
1361
|
+
...(underRelease ? { prepare: releaseRunPrepare(underRelease, projectPath, env, { deployUnchanged: ctx.args.deployUnchanged === true, skipped }) } : {}),
|
|
1254
1362
|
});
|
|
1255
1363
|
} catch (err) {
|
|
1256
1364
|
events?.settle("failed", err instanceof Error ? err.message : String(err));
|
|
@@ -1335,7 +1443,9 @@ async function runComponentSelection(ctx: CommandContext): Promise<number> {
|
|
|
1335
1443
|
const templatesDigestOf = underRelease ? await releaseTemplatesDigestOf(underRelease.release, env) : undefined;
|
|
1336
1444
|
// #4274: a component that publishes nothing is recorded by its deploy-input digest.
|
|
1337
1445
|
const appliedOf = result.components ? appliedDigestOf({ components: result.components, env, projectRoot: projectPath }) : undefined;
|
|
1338
|
-
const
|
|
1446
|
+
const deployed = result.run.results.filter((r) => !skipped.has(r.component));
|
|
1447
|
+
const recorded = await recordAutoReleasesForRun(deployed, env, release.runId, disabled, release.runOrigin, underRelease?.releaseDigest, templatesDigestOf, appliedOf);
|
|
1448
|
+
if (underRelease && !disabled) recorded.push(...(await recordSkips(skipped, underRelease.releaseDigest, release, projectPath)));
|
|
1339
1449
|
// A generated promote job promotes artifacts; an apply has none to name.
|
|
1340
1450
|
const promotable = recorded.filter((r) => !isApplyRecord(r));
|
|
1341
1451
|
if (underRelease) await warnOnArtifactMismatch(underRelease.release, recorded);
|
package/src/cli/main.ts
CHANGED
|
@@ -452,7 +452,8 @@ Releases:
|
|
|
452
452
|
release cut [<label>] [--at <sha>] [--yes] [--build <command>] [--param <k=v>]
|
|
453
453
|
[--params-file <file>] [--src <dir>] [-o <file>] [--lexicon <name>]
|
|
454
454
|
[--actor <name>] [--sign [<key file>]] [--channel <tag>]
|
|
455
|
-
[--lane <name>] [--override-green]
|
|
455
|
+
[--lane <name>] [--override-green]
|
|
456
|
+
[--image <component>=<repository>@sha256:<hex>] [--json]
|
|
456
457
|
A dry run of a cut of this member from HEAD, which
|
|
457
458
|
must be clean, on trunk and pushed, and carry a
|
|
458
459
|
ci/green tag: compile every environment in the
|
|
@@ -473,6 +474,9 @@ Releases:
|
|
|
473
474
|
trunk from a temporary worktree instead of HEAD, so
|
|
474
475
|
the checkout need not be clean. The label reaches
|
|
475
476
|
every compile and build as CHANT_RELEASE_LABEL.
|
|
477
|
+
--image, repeatable, hands the cut a component's image
|
|
478
|
+
built elsewhere, by digest: the release records it and
|
|
479
|
+
the cut builds nothing for that component (#4694).
|
|
476
480
|
A green commit of a pushed chant/compose/<name>
|
|
477
481
|
branch is cut too, recording its base and sources.
|
|
478
482
|
--channel <tag> records the tag a publish moves in
|
|
@@ -612,7 +616,15 @@ Ops:
|
|
|
612
616
|
component that published a digest (default: on;
|
|
613
617
|
--no-release-record to opt out; #597).
|
|
614
618
|
--release <label|digest>: the run is of that release,
|
|
615
|
-
cut from this checkout's commit; the records name it (#4043)
|
|
619
|
+
cut from this checkout's commit; the records name it (#4043).
|
|
620
|
+
A component the release recorded an artifact for runs
|
|
621
|
+
without its build steps, from that artifact; a
|
|
622
|
+
release-image step gets the image handed to the cut,
|
|
623
|
+
and a component whose artifact is missing is refused
|
|
624
|
+
before anything runs (#4694). A component whose
|
|
625
|
+
declared inputs are the same as in the release the
|
|
626
|
+
environment runs it from is skipped and the skip
|
|
627
|
+
recorded; --deploy-unchanged deploys it (#4695)
|
|
616
628
|
--progress-json: stream one NDJSON RunProgressEvent
|
|
617
629
|
per line to stdout while the run executes, for a
|
|
618
630
|
consumer to render live wave/component/phase/step
|
|
@@ -1493,6 +1505,9 @@ Options:
|
|
|
1493
1505
|
successful \`run --components\` deploy (default: on;
|
|
1494
1506
|
also settable via chant.config.ts's
|
|
1495
1507
|
release.autoRecord: false; #597)
|
|
1508
|
+
--deploy-unchanged (run --components --release) Deploy a component that
|
|
1509
|
+
declares inputs even when they are the same as in
|
|
1510
|
+
the release the environment runs it from (#4695)
|
|
1496
1511
|
--no-record (run <op>, run --components) Run every step but record
|
|
1497
1512
|
nothing on chant/lifecycle and push nothing: no
|
|
1498
1513
|
release, run record, receipt or gate fact. A gate
|
package/src/cli/parse-args.ts
CHANGED
|
@@ -60,6 +60,7 @@ const BOOLEAN_FLAGS = new Set([
|
|
|
60
60
|
"--check",
|
|
61
61
|
"--bump",
|
|
62
62
|
"--no-release-record",
|
|
63
|
+
"--deploy-unchanged",
|
|
63
64
|
"--no-record",
|
|
64
65
|
"--fold",
|
|
65
66
|
"--no-fold",
|
|
@@ -358,6 +359,8 @@ export function parseArgs(args: string[]): ParsedArgs {
|
|
|
358
359
|
} else if (arg === "--image") {
|
|
359
360
|
result.image = args[++i];
|
|
360
361
|
if (!result.image || result.image.startsWith("-")) throw new Error("--image needs an image reference: --image <name>:<tag>");
|
|
362
|
+
// `chant release cut --image <component>=<ref>` (#4694) is repeatable.
|
|
363
|
+
(result.images ??= []).push(result.image);
|
|
361
364
|
} else if (arg === "--network") {
|
|
362
365
|
result.network = args[++i];
|
|
363
366
|
if (!result.network || result.network.startsWith("-")) throw new Error("--network needs a Docker network name: --network <name>");
|
|
@@ -959,6 +962,9 @@ export function parseArgs(args: string[]): ParsedArgs {
|
|
|
959
962
|
// `chant release cut --build <command>` (#4026)
|
|
960
963
|
result.buildCommand = args[++i];
|
|
961
964
|
if (!result.buildCommand) throw new Error("--build needs a shell command: --build '<command>'");
|
|
965
|
+
} else if (arg === "--deploy-unchanged") {
|
|
966
|
+
// `chant run --components --release --deploy-unchanged` (#4695): deploy a component whose inputs did not change.
|
|
967
|
+
result.deployUnchanged = true;
|
|
962
968
|
} else if (arg === "--artifacts") {
|
|
963
969
|
// `chant release compile --artifacts` (#4026, internal)
|
|
964
970
|
result.artifacts = true;
|
package/src/cli/registry.ts
CHANGED
|
@@ -219,6 +219,8 @@ export interface ParsedArgs {
|
|
|
219
219
|
* (#4002): the image every generated job runs in.
|
|
220
220
|
*/
|
|
221
221
|
image?: string;
|
|
222
|
+
/** Every `--image` value, in order. `chant release cut --image <component>=<repository>@sha256:<hex>` (#4694) is repeatable, one per component: an image built elsewhere, handed to the cut by digest. */
|
|
223
|
+
images?: string[];
|
|
222
224
|
/** `chant build --components --generate --before-script <line>`, repeatable (#4002): shell lines every generated job runs before its command. */
|
|
223
225
|
beforeScript?: string[];
|
|
224
226
|
/** `chant emulator up --network <name>` (#3952): the Docker network each started container joins. */
|
|
@@ -812,8 +814,10 @@ export interface ParsedArgs {
|
|
|
812
814
|
digest?: string;
|
|
813
815
|
/** `chant components release record --release-plan <file>` (ws-055, #2733) — path to a release plan JSON file, persisted content-addressed to `_plans/<digest>.json` on chant/lifecycle and read back through the read contract (`chant workspace status --json`). The plan's own `digest` field supplies `--digest` when it is omitted, and must match it when both are given. Distinct from `--plan` (#2300, below), the Op gate-approval plan digest. */
|
|
814
816
|
releasePlanFile?: string;
|
|
815
|
-
/** `chant components promote --release <label|digest>` (#4026): deploy under that release, reading the templates its target for `--to` recorded. `chant run --components --release <label|digest>` (#4043): the run is of that release, which must have been cut from the checked-out commit and have a target for `--env`; the release records the run writes name it. */
|
|
817
|
+
/** `chant components promote --release <label|digest>` (#4026): deploy under that release, reading the templates its target for `--to` recorded. `chant run --components --release <label|digest>` (#4043): the run is of that release, which must have been cut from the checked-out commit and have a target for `--env`; the release records the run writes name it, and a component the release recorded an artifact for is deployed from it without a build (#4694). */
|
|
816
818
|
release?: string;
|
|
819
|
+
/** `chant run --components --release --deploy-unchanged` (#4695): deploy every component, also one whose declared inputs are the same as in the release the environment runs it from. */
|
|
820
|
+
deployUnchanged?: boolean;
|
|
817
821
|
/** `chant release cut --build <command>` (#4026): the shell command run in the member's directory before each environment's templates are read, with `CHANT_ENV` set to the environment. */
|
|
818
822
|
buildCommand?: string;
|
|
819
823
|
/** `chant release compile --artifacts` (#4026, internal): build the artifacts of `--component` instead of compiling the environment. */
|
|
@@ -553,6 +553,59 @@ describe("runComponents", () => {
|
|
|
553
553
|
expect(capability.calls[0].ctx.env).toBe("local");
|
|
554
554
|
});
|
|
555
555
|
|
|
556
|
+
test("prepare rewrites the compositions before they run, or refuses the run (#4694)", async () => {
|
|
557
|
+
await writeFile(
|
|
558
|
+
join(testDir, "svc.component.ts"),
|
|
559
|
+
`export const svc = { name: "svc", dependsOn: [], deploy: [{ phase: "Build", steps: [{ kind: "build-thing" }] }, { phase: "Apply", steps: [{ kind: "deploy-thing" }] }] };`,
|
|
560
|
+
);
|
|
561
|
+
const build = fakeCapability("build-thing");
|
|
562
|
+
const deploy = fakeCapability("deploy-thing");
|
|
563
|
+
const registry = new CapabilityRegistry();
|
|
564
|
+
registry.register(build);
|
|
565
|
+
registry.register(deploy);
|
|
566
|
+
|
|
567
|
+
const seen: string[][] = [];
|
|
568
|
+
const result = await runComponents(testDir, "svc", {
|
|
569
|
+
registry,
|
|
570
|
+
prepare: async (components) => {
|
|
571
|
+
seen.push(components.map((c) => c.name));
|
|
572
|
+
return { components: components.map((c) => ({ ...c, deploy: c.deploy.filter((p) => p.phase !== "Build") })) };
|
|
573
|
+
},
|
|
574
|
+
});
|
|
575
|
+
expect(result.success).toBe(true);
|
|
576
|
+
expect(seen).toEqual([["svc"]]);
|
|
577
|
+
expect(build.calls).toHaveLength(0);
|
|
578
|
+
expect(deploy.calls).toHaveLength(1);
|
|
579
|
+
|
|
580
|
+
const refused = await runComponents(testDir, "svc", { registry, prepare: async () => ({ error: "no artifact" }) });
|
|
581
|
+
expect(refused).toMatchObject({ success: false, error: "no artifact" });
|
|
582
|
+
expect(deploy.calls).toHaveLength(1);
|
|
583
|
+
});
|
|
584
|
+
|
|
585
|
+
test("prepare sees the inputs a component declares, and a component left with no phases runs nothing while its dependents run (#4695)", async () => {
|
|
586
|
+
await writeFile(
|
|
587
|
+
join(testDir, "svc.component.ts"),
|
|
588
|
+
`export const hub = { name: "hub", dependsOn: [], inputs: { paths: ["src"] }, deploy: [{ phase: "Apply", steps: [{ kind: "deploy-thing" }] }] };
|
|
589
|
+
export const web = { name: "web", dependsOn: ["hub"], deploy: [{ phase: "Apply", steps: [{ kind: "deploy-thing" }] }] };`,
|
|
590
|
+
);
|
|
591
|
+
const deploy = fakeCapability("deploy-thing");
|
|
592
|
+
const registry = new CapabilityRegistry();
|
|
593
|
+
registry.register(deploy);
|
|
594
|
+
let inputs: unknown;
|
|
595
|
+
const skip = async (components: DriverComponent[], declared: { inputs: Readonly<Record<string, unknown>> }) => {
|
|
596
|
+
inputs = declared.inputs;
|
|
597
|
+
return { components: components.map((c) => (c.name === "hub" ? { ...c, deploy: [] } : c)) };
|
|
598
|
+
};
|
|
599
|
+
for (const selector of ["hub", "hub,web", "all"]) {
|
|
600
|
+
deploy.calls.length = 0;
|
|
601
|
+
const result = await runComponents(testDir, selector, { registry, prepare: skip });
|
|
602
|
+
expect(result.success).toBe(true);
|
|
603
|
+
expect(inputs).toEqual({ hub: { paths: ["src"] } });
|
|
604
|
+
expect(deploy.calls.map((c) => c.ctx.component)).toEqual(selector === "hub" ? [] : ["web"]);
|
|
605
|
+
}
|
|
606
|
+
});
|
|
607
|
+
|
|
608
|
+
|
|
556
609
|
test("runs a component whose dependsOn names infra outside the discovered set (no UnknownDependencyError)", async () => {
|
|
557
610
|
await writeFile(
|
|
558
611
|
join(testDir, "svc.component.ts"),
|