@intentius/chant 0.124.63 → 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/approve.d.ts +8 -0
- package/dist/cli/handlers/approve.d.ts.map +1 -1
- package/dist/cli/handlers/approve.js +27 -4
- package/dist/cli/handlers/pr.d.ts.map +1 -1
- package/dist/cli/handlers/pr.js +2 -1
- package/dist/cli/handlers/release.d.ts +6 -4
- package/dist/cli/handlers/release.d.ts.map +1 -1
- package/dist/cli/handlers/release.js +101 -16
- 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 +34 -7
- package/dist/cli/parse-args.d.ts.map +1 -1
- package/dist/cli/parse-args.js +19 -0
- package/dist/cli/registry.d.ts +10 -2
- 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/config.d.ts +18 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +1 -0
- package/dist/gate-statement.schema.json +4 -2
- package/dist/lifecycle/delivery-metrics.d.ts.map +1 -1
- package/dist/lifecycle/delivery-metrics.js +4 -2
- package/dist/lifecycle/gate-ledger.d.ts +11 -2
- package/dist/lifecycle/gate-ledger.d.ts.map +1 -1
- package/dist/lifecycle/gate-ledger.js +6 -0
- package/dist/lifecycle/gate-seal.d.ts +20 -4
- package/dist/lifecycle/gate-seal.d.ts.map +1 -1
- package/dist/lifecycle/gate-seal.js +18 -5
- package/dist/lifecycle/gate-statement.d.ts +27 -2
- package/dist/lifecycle/gate-statement.d.ts.map +1 -1
- package/dist/lifecycle/gate-statement.js +37 -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/plan-stale.d.ts.map +1 -1
- package/dist/lifecycle/plan-stale.js +1 -2
- package/dist/lifecycle/publish-declaration.d.ts +20 -0
- package/dist/lifecycle/publish-declaration.d.ts.map +1 -1
- package/dist/lifecycle/publish-declaration.js +24 -1
- package/dist/lifecycle/publish-forge.d.ts.map +1 -1
- package/dist/lifecycle/publish-forge.js +1 -2
- package/dist/lifecycle/publish-git-ssh.d.ts +82 -0
- package/dist/lifecycle/publish-git-ssh.d.ts.map +1 -0
- package/dist/lifecycle/publish-git-ssh.js +180 -0
- package/dist/lifecycle/publish-homebrew.d.ts +11 -0
- package/dist/lifecycle/publish-homebrew.d.ts.map +1 -1
- package/dist/lifecycle/publish-homebrew.js +96 -5
- package/dist/lifecycle/publish-marketplace.d.ts +36 -2
- package/dist/lifecycle/publish-marketplace.d.ts.map +1 -1
- package/dist/lifecycle/publish-marketplace.js +173 -30
- package/dist/lifecycle/publish-tauri.d.ts.map +1 -1
- package/dist/lifecycle/publish-tauri.js +1 -2
- 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 +82 -6
- package/dist/lifecycle/release-cut.d.ts.map +1 -1
- package/dist/lifecycle/release-cut.js +209 -20
- package/dist/lifecycle/release-ledger.d.ts +11 -0
- package/dist/lifecycle/release-ledger.d.ts.map +1 -1
- package/dist/lifecycle/release-publish.d.ts +13 -0
- package/dist/lifecycle/release-publish.d.ts.map +1 -1
- package/dist/lifecycle/release-publish.js +5 -0
- package/dist/lifecycle/release-revocation.d.ts +4 -3
- package/dist/lifecycle/release-revocation.d.ts.map +1 -1
- package/dist/lifecycle/release-revocation.js +5 -4
- package/dist/lifecycle/release-store.d.ts +49 -3
- package/dist/lifecycle/release-store.d.ts.map +1 -1
- package/dist/lifecycle/release-store.js +22 -3
- package/dist/op/gate.d.ts +1 -1
- package/dist/op/gate.d.ts.map +1 -1
- package/dist/op/gate.js +2 -1
- package/dist/op/op-waves-run.js +5 -3
- package/dist/pr-forge.d.ts.map +1 -1
- package/dist/pr-forge.js +26 -6
- package/dist/release-floors.d.ts +1 -1
- package/dist/release-floors.js +1 -1
- package/dist/wave-runtime.mjs +284 -283
- package/dist/workspace/ci-green.d.ts.map +1 -1
- package/dist/workspace/ci-green.js +1 -2
- package/dist/workspace/ci-quarantine-report.d.ts.map +1 -1
- package/dist/workspace/ci-quarantine-report.js +1 -2
- package/dist/workspace/ci-quarantine.d.ts.map +1 -1
- package/dist/workspace/ci-quarantine.js +1 -2
- package/dist/workspace/delivery-metrics.schema.json +1 -1
- package/dist/workspace/intent.d.ts.map +1 -1
- package/dist/workspace/intent.js +1 -2
- package/dist/workspace/release-candidates.d.ts +9 -1
- package/dist/workspace/release-candidates.d.ts.map +1 -1
- package/dist/workspace/release-candidates.js +16 -5
- package/dist/workspace/release-candidates.schema.json +7 -0
- package/dist/workspace/releases.schema.json +54 -2
- package/package.json +1 -1
- package/src/cli/handlers/approve-external-signature.test.ts +105 -3
- package/src/cli/handlers/approve.ts +34 -4
- package/src/cli/handlers/pr.ts +2 -1
- package/src/cli/handlers/release.ts +91 -16
- package/src/cli/handlers/run-unchanged.e2e.test.ts +112 -0
- package/src/cli/handlers/run.ts +117 -7
- package/src/cli/main.ts +34 -7
- package/src/cli/parse-args.ts +15 -0
- package/src/cli/registry.ts +10 -2
- 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/config.ts +8 -0
- package/src/gate-statement.schema.json +4 -2
- package/src/lifecycle/delivery-metrics.ts +4 -2
- package/src/lifecycle/gate-ledger.ts +17 -2
- package/src/lifecycle/gate-seal.ts +24 -6
- package/src/lifecycle/gate-statement.ts +40 -4
- 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/plan-stale.test.ts +3 -4
- package/src/lifecycle/plan-stale.ts +1 -2
- package/src/lifecycle/publish-declaration.ts +24 -1
- package/src/lifecycle/publish-forge.ts +1 -2
- package/src/lifecycle/publish-git-ssh.ts +202 -0
- package/src/lifecycle/publish-homebrew.test.ts +181 -2
- package/src/lifecycle/publish-homebrew.ts +101 -6
- package/src/lifecycle/publish-marketplace.test.ts +158 -6
- package/src/lifecycle/publish-marketplace.ts +192 -31
- package/src/lifecycle/publish-resume.test.ts +40 -0
- package/src/lifecycle/publish-tauri.ts +1 -2
- package/src/lifecycle/query.ts +3 -3
- package/src/lifecycle/release-cut-lane.test.ts +195 -0
- package/src/lifecycle/release-cut-override.test.ts +225 -0
- package/src/lifecycle/release-cut.test.ts +45 -0
- package/src/lifecycle/release-cut.ts +262 -21
- package/src/lifecycle/release-ledger.ts +11 -0
- package/src/lifecycle/release-publish.ts +18 -0
- package/src/lifecycle/release-revocation.ts +5 -4
- package/src/lifecycle/release-store.ts +73 -5
- package/src/op/gate.ts +2 -1
- package/src/op/op-waves-run.ts +4 -2
- package/src/pr-forge.ts +25 -6
- package/src/pr-requires.test.ts +9 -0
- package/src/release-floors.ts +1 -1
- package/src/workspace/ci-green.ts +1 -2
- package/src/workspace/ci-quarantine-report.test.ts +2 -3
- package/src/workspace/ci-quarantine-report.ts +1 -2
- package/src/workspace/ci-quarantine.test.ts +2 -3
- package/src/workspace/ci-quarantine.ts +1 -2
- package/src/workspace/delivery-metrics.schema.json +1 -1
- package/src/workspace/delivery-metrics.test.ts +8 -0
- package/src/workspace/intent.ts +1 -2
- package/src/workspace/release-candidates.schema.json +7 -0
- package/src/workspace/release-candidates.ts +19 -5
- package/src/workspace/releases.schema.json +54 -2
- package/src/workspace/trust/gate-seal.test.ts +44 -0
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
|
@@ -451,7 +451,9 @@ CI:
|
|
|
451
451
|
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
|
-
[--actor <name>] [--sign [<key file>]] [--channel <tag>]
|
|
454
|
+
[--actor <name>] [--sign [<key file>]] [--channel <tag>]
|
|
455
|
+
[--lane <name>] [--override-green]
|
|
456
|
+
[--image <component>=<repository>@sha256:<hex>] [--json]
|
|
455
457
|
A dry run of a cut of this member from HEAD, which
|
|
456
458
|
must be clean, on trunk and pushed, and carry a
|
|
457
459
|
ci/green tag: compile every environment in the
|
|
@@ -472,10 +474,19 @@ Releases:
|
|
|
472
474
|
trunk from a temporary worktree instead of HEAD, so
|
|
473
475
|
the checkout need not be clean. The label reaches
|
|
474
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).
|
|
475
480
|
A green commit of a pushed chant/compose/<name>
|
|
476
481
|
branch is cut too, recording its base and sources.
|
|
477
482
|
--channel <tag> records the tag a publish moves in
|
|
478
|
-
place of latest.
|
|
483
|
+
place of latest. --lane <name> (or release.lane in
|
|
484
|
+
chant.config.ts) checks a ci.green lane's tag,
|
|
485
|
+
ci/green-<lane>/<sha>, in place of ci/green.
|
|
486
|
+
--override-green cuts a commit that is not green
|
|
487
|
+
under a person's override, recorded with chant
|
|
488
|
+
approve policy-override release-<sha12>; the cut
|
|
489
|
+
spends it and records who and why.
|
|
479
490
|
release compose <name> [--base <label|sha>] (--pr <n> | --work <id>)...
|
|
480
491
|
[--yes] [--json]
|
|
481
492
|
Cherry-pick the chosen trunk changes, in trunk order,
|
|
@@ -484,12 +495,14 @@ Releases:
|
|
|
484
495
|
that exists; stops on a conflict, naming the change
|
|
485
496
|
and files, and writes nothing. A dry run unless --yes,
|
|
486
497
|
which moves the branch and pushes it.
|
|
487
|
-
release candidates [--env <env>] [--forge-issues] [--json]
|
|
498
|
+
release candidates [--env <env>] [--lane <name>] [--forge-issues] [--json]
|
|
488
499
|
The green commits of trunk a release can be cut from,
|
|
489
500
|
newest first, each with the commits, work items, pull
|
|
490
501
|
requests and flags it would ship, and what each
|
|
491
|
-
environment runs. --
|
|
492
|
-
|
|
502
|
+
environment runs. --lane reads a lane's green tags,
|
|
503
|
+
as release cut --lane checks them. --forge-issues asks
|
|
504
|
+
the forge which issues each pull request closes, once
|
|
505
|
+
per pull request
|
|
493
506
|
release publish <label|digest> [--yes] [--allow-unsigned]
|
|
494
507
|
[--require-provenance] [--json]
|
|
495
508
|
Publish a cut release to the targets release.publish
|
|
@@ -603,7 +616,15 @@ Ops:
|
|
|
603
616
|
component that published a digest (default: on;
|
|
604
617
|
--no-release-record to opt out; #597).
|
|
605
618
|
--release <label|digest>: the run is of that release,
|
|
606
|
-
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)
|
|
607
628
|
--progress-json: stream one NDJSON RunProgressEvent
|
|
608
629
|
per line to stdout while the run executes, for a
|
|
609
630
|
consumer to render live wave/component/phase/step
|
|
@@ -668,7 +689,10 @@ Ops:
|
|
|
668
689
|
<file|-> --at <time> then records a signature made
|
|
669
690
|
elsewhere over them (an ssh signature, or a passkey's
|
|
670
691
|
WebAuthn assertion checked against .chant/trust.json's
|
|
671
|
-
passkeys), which counts as --sign does (#4646)
|
|
692
|
+
passkeys), which counts as --sign does (#4646).
|
|
693
|
+
--binding <text> adds a line the relay sets (a deploy
|
|
694
|
+
id and an expiry, say) that the signature covers too;
|
|
695
|
+
pass the same on --statement and --signature (#4697)
|
|
672
696
|
--resume then starts the CI job that waits at the
|
|
673
697
|
gate again (GitHub re-run, GitLab retry, Forgejo
|
|
674
698
|
dispatch) with CHANT_FORGE_TOKEN
|
|
@@ -1481,6 +1505,9 @@ Options:
|
|
|
1481
1505
|
successful \`run --components\` deploy (default: on;
|
|
1482
1506
|
also settable via chant.config.ts's
|
|
1483
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)
|
|
1484
1511
|
--no-record (run <op>, run --components) Run every step but record
|
|
1485
1512
|
nothing on chant/lifecycle and push nothing: no
|
|
1486
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",
|
|
@@ -93,6 +94,7 @@ const BOOLEAN_FLAGS = new Set([
|
|
|
93
94
|
"--allow-code",
|
|
94
95
|
"--allow-skip",
|
|
95
96
|
"--allow-unsigned",
|
|
97
|
+
"--override-green",
|
|
96
98
|
"--require-provenance",
|
|
97
99
|
"--root-only",
|
|
98
100
|
"--generated",
|
|
@@ -357,6 +359,8 @@ export function parseArgs(args: string[]): ParsedArgs {
|
|
|
357
359
|
} else if (arg === "--image") {
|
|
358
360
|
result.image = args[++i];
|
|
359
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);
|
|
360
364
|
} else if (arg === "--network") {
|
|
361
365
|
result.network = args[++i];
|
|
362
366
|
if (!result.network || result.network.startsWith("-")) throw new Error("--network needs a Docker network name: --network <name>");
|
|
@@ -564,6 +568,9 @@ export function parseArgs(args: string[]): ParsedArgs {
|
|
|
564
568
|
// `chant ci run|serve --status-url <template>` (#4097): the link a job's status carries, in place of an https --report-url.
|
|
565
569
|
result.statusUrl = args[++i];
|
|
566
570
|
if (!result.statusUrl || result.statusUrl.startsWith("-")) throw new Error("--status-url needs a URL template: --status-url https://host/reports/{key}");
|
|
571
|
+
} else if (arg === "--override-green") {
|
|
572
|
+
// `chant release cut --override-green` (#4693): cut a commit that is not green under a person's override.
|
|
573
|
+
result.overrideGreen = true;
|
|
567
574
|
} else if (arg === "--allow-unsigned") {
|
|
568
575
|
// `chant release publish --allow-unsigned` (#4049).
|
|
569
576
|
result.allowUnsigned = true;
|
|
@@ -955,6 +962,9 @@ export function parseArgs(args: string[]): ParsedArgs {
|
|
|
955
962
|
// `chant release cut --build <command>` (#4026)
|
|
956
963
|
result.buildCommand = args[++i];
|
|
957
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;
|
|
958
968
|
} else if (arg === "--artifacts") {
|
|
959
969
|
// `chant release compile --artifacts` (#4026, internal)
|
|
960
970
|
result.artifacts = true;
|
|
@@ -975,6 +985,10 @@ export function parseArgs(args: string[]): ParsedArgs {
|
|
|
975
985
|
if (!result.signature || (result.signature.startsWith("-") && result.signature !== "-")) {
|
|
976
986
|
throw new Error("--signature needs a file holding the signature, or - for stdin: --signature <file|->");
|
|
977
987
|
}
|
|
988
|
+
} else if (arg === "--binding") {
|
|
989
|
+
// `chant approve <op> <gate> --statement|--signature|--sign --binding <text>` (#4697): a line the relay sets for the signature to cover.
|
|
990
|
+
result.binding = args[++i];
|
|
991
|
+
if (!result.binding || result.binding.startsWith("-")) throw new Error("--binding needs the line the signature binds, which does not start with -: --binding <text>");
|
|
978
992
|
} else if (arg === "--relayed-by") {
|
|
979
993
|
// `chant approve <op> <gate> --relayed-by <principal>` and `workspace points answer <id> --relayed-by <principal>` (#3402):
|
|
980
994
|
// who carried the approval or answer to chant for the person it names.
|
|
@@ -1213,6 +1227,7 @@ export function parseArgs(args: string[]): ParsedArgs {
|
|
|
1213
1227
|
result.ciWait = true;
|
|
1214
1228
|
} else if (arg === "--lane") {
|
|
1215
1229
|
// `chant ci last-green --lane <name>` and `chant ci base --lane <name>` (#4662): a green lane's tags and phases.
|
|
1230
|
+
// `chant release cut|candidates --lane <name>` (#4692): a cut from that lane's green tag.
|
|
1216
1231
|
result.lane = args[++i];
|
|
1217
1232
|
} else if (arg === "--runner") {
|
|
1218
1233
|
// `chant ci quarantine filter --runner nextest|playwright|list` (#4677): the runner the filter is for.
|
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. */
|
|
@@ -377,6 +379,8 @@ export interface ParsedArgs {
|
|
|
377
379
|
prs?: number[];
|
|
378
380
|
/** `chant release cut --channel <tag>` (#4168 4.3): the tag a publish of the release moves in place of `latest`. */
|
|
379
381
|
channel?: string;
|
|
382
|
+
/** `chant release cut --override-green` (#4693): cut a commit that is not green under a person's override on the override ledger. */
|
|
383
|
+
overrideGreen?: boolean;
|
|
380
384
|
/**
|
|
381
385
|
* `chant components pr-plan|pr-apply --forge github|gitlab|forgejo` (#3183)
|
|
382
386
|
* — post the note and the commit status on this forge, with the client
|
|
@@ -707,6 +711,8 @@ export interface ParsedArgs {
|
|
|
707
711
|
statement?: boolean;
|
|
708
712
|
/** `chant approve <op> <gate> --signature <file|->` (#4646): a signature made elsewhere over the statement. */
|
|
709
713
|
signature?: string;
|
|
714
|
+
/** `chant approve <op> <gate> --binding <text>` (#4697): a line the relay sets, signed last with the statement. */
|
|
715
|
+
binding?: string;
|
|
710
716
|
/**
|
|
711
717
|
* `chant approve <op> <gate> --relayed-by <principal>` and `chant workspace
|
|
712
718
|
* points answer <id> --relayed-by <principal>` (#3402): the principal that
|
|
@@ -808,8 +814,10 @@ export interface ParsedArgs {
|
|
|
808
814
|
digest?: string;
|
|
809
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. */
|
|
810
816
|
releasePlanFile?: string;
|
|
811
|
-
/** `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). */
|
|
812
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;
|
|
813
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. */
|
|
814
822
|
buildCommand?: string;
|
|
815
823
|
/** `chant release compile --artifacts` (#4026, internal): build the artifacts of `--component` instead of compiling the environment. */
|
|
@@ -925,7 +933,7 @@ export interface ParsedArgs {
|
|
|
925
933
|
since?: string;
|
|
926
934
|
/** `chant ci verdict --wait` (#4644) — read again until no required phase is pending. */
|
|
927
935
|
ciWait?: boolean;
|
|
928
|
-
/** `chant ci last-green --lane <name>` and `chant ci base --lane <name>` (#4662) — a ci.green lane. */
|
|
936
|
+
/** `chant ci last-green --lane <name>` and `chant ci base --lane <name>` (#4662) — a ci.green lane. `chant release cut --lane <name>` and `chant release candidates --lane <name>` (#4692) — check that lane's green tags. */
|
|
929
937
|
lane?: string;
|
|
930
938
|
/** `chant ci base --phase <name>` (#4643) — the ci.green phase whose base to find. `chant ci quarantine filter --phase <name>` (#4677) — the phase whose runner takes the filter. */
|
|
931
939
|
phase?: string;
|
|
@@ -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"),
|
|
@@ -26,7 +26,7 @@ import { UnknownCanaryError } from "../gated-waves";
|
|
|
26
26
|
import { lexiconModulePath, lexiconNames, importLexiconPackage } from "../lexicon-module";
|
|
27
27
|
import { discoverComponents } from "./discover";
|
|
28
28
|
import type { BuildParamProvenance } from "../provenance";
|
|
29
|
-
import { inferArchetype, projectToJson, type Archetype, type ComponentEnvironmentDeclaration } from "./component";
|
|
29
|
+
import { inferArchetype, projectToJson, type Archetype, type ComponentEnvironmentDeclaration, type ComponentInputs } from "./component";
|
|
30
30
|
import {
|
|
31
31
|
deployContext,
|
|
32
32
|
resolveComponentGraph,
|
|
@@ -495,6 +495,19 @@ export interface RunComponentsOptions {
|
|
|
495
495
|
* a checkout. `null` passes none.
|
|
496
496
|
*/
|
|
497
497
|
revision?: string | null;
|
|
498
|
+
/**
|
|
499
|
+
* Rewrites the selected compositions before anything runs, or refuses the
|
|
500
|
+
* run (#4694): `chant run --components --release` takes out the build steps
|
|
501
|
+
* of a component the release recorded an artifact for and hands its
|
|
502
|
+
* `release-image` steps the image (./release-run.ts). Called once, with the
|
|
503
|
+
* components in run order, after their config defaults are applied, and
|
|
504
|
+
* the inputs each declares (#4695), by which a run under a release skips
|
|
505
|
+
* a component whose inputs did not change.
|
|
506
|
+
*/
|
|
507
|
+
prepare?: (
|
|
508
|
+
components: DriverComponent[],
|
|
509
|
+
declared: { inputs: Readonly<Record<string, ComponentInputs>> },
|
|
510
|
+
) => Promise<{ components: DriverComponent[] } | { error: string }>;
|
|
498
511
|
}
|
|
499
512
|
|
|
500
513
|
/** The resolved order of a list run (#3950), reported through `RunComponentsOptions.onPlan`. */
|
|
@@ -573,6 +586,8 @@ export interface ResolvedComponentTargets {
|
|
|
573
586
|
list?: { named: string[]; enabled: DriverComponent[] };
|
|
574
587
|
/** Component name to the environments it declares (#3153), for the components that declare any (#4330). */
|
|
575
588
|
sites?: Record<string, ComponentEnvironmentDeclaration[]>;
|
|
589
|
+
/** Component name to the inputs it declares (#4695), for the components that declare them. */
|
|
590
|
+
inputs?: Record<string, ComponentInputs>;
|
|
576
591
|
error?: string;
|
|
577
592
|
}
|
|
578
593
|
|
|
@@ -602,12 +617,14 @@ export async function resolveComponentTargets(
|
|
|
602
617
|
|
|
603
618
|
const discovered = [...result.components.values()].map(({ component }) => component);
|
|
604
619
|
const all = discovered.map((component) => toDriverComponent(component));
|
|
620
|
+
const inputs = Object.fromEntries(discovered.filter((c) => c.inputs !== undefined).map((c) => [c.name, c.inputs!]));
|
|
621
|
+
const declared = Object.keys(inputs).length > 0 ? { inputs } : {};
|
|
605
622
|
|
|
606
|
-
if (isComponentList(selector)) return resolveComponentList(selector, discovered, all);
|
|
623
|
+
if (isComponentList(selector)) return { ...resolveComponentList(selector, discovered, all), ...declared };
|
|
607
624
|
|
|
608
625
|
if (selector === "all") {
|
|
609
626
|
const sites = Object.fromEntries(discovered.filter((c) => c.environments && c.environments.length > 0).map((c) => [c.name, c.environments!.map((e) => ({ ...e }))]));
|
|
610
|
-
return { success: true, targets: withoutDisabled(discovered, all), ...(Object.keys(sites).length > 0 ? { sites } : {}) };
|
|
627
|
+
return { success: true, targets: withoutDisabled(discovered, all), ...(Object.keys(sites).length > 0 ? { sites } : {}), ...declared };
|
|
611
628
|
}
|
|
612
629
|
|
|
613
630
|
const found = all.find((c) => c.name === selector);
|
|
@@ -629,7 +646,7 @@ export async function resolveComponentTargets(
|
|
|
629
646
|
error: `Component "${selector}" not found.${known ? ` Known components: ${known}` : " No components discovered."}`,
|
|
630
647
|
};
|
|
631
648
|
}
|
|
632
|
-
return { success: true, targets: [found] };
|
|
649
|
+
return { success: true, targets: [found], ...declared };
|
|
633
650
|
}
|
|
634
651
|
|
|
635
652
|
/**
|
|
@@ -741,6 +758,11 @@ export async function runComponents(
|
|
|
741
758
|
const defaulted = resolved.targets.map((component) => applyConfigDefaults(component, config));
|
|
742
759
|
resolvedTargets = selector === "all" ? await withDeclaredReads(defaulted, registry, path) : defaulted;
|
|
743
760
|
}
|
|
761
|
+
if (options.prepare) {
|
|
762
|
+
const prepared = await options.prepare(resolvedTargets, { inputs: resolved.inputs ?? {} });
|
|
763
|
+
if ("error" in prepared) return { success: false, selected: [], error: prepared.error };
|
|
764
|
+
resolvedTargets = prepared.components;
|
|
765
|
+
}
|
|
744
766
|
const selected = resolvedTargets.map((c) => c.name);
|
|
745
767
|
const narrowed = options.targets ?? {};
|
|
746
768
|
const outside = Object.keys(narrowed).filter((name) => !selected.includes(name));
|
|
@@ -77,6 +77,23 @@
|
|
|
77
77
|
"lifecycle": { "type": "string", "minLength": 1, "description": "The git remote this environment's approvals, effect receipts and ledger records are pushed to." }
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
|
+
},
|
|
81
|
+
"inputs": {
|
|
82
|
+
"type": "object",
|
|
83
|
+
"description": "Optional: what a deploy of this component is made from (#4695). A run under a release (chant run --components --release) skips the component when these are the same as in the release the environment runs it from, and records the skip; --deploy-unchanged deploys it anyway. Omitted, the component deploys with every release. Read by chant 0.124.65 and newer.",
|
|
84
|
+
"additionalProperties": false,
|
|
85
|
+
"properties": {
|
|
86
|
+
"paths": {
|
|
87
|
+
"type": "array",
|
|
88
|
+
"description": "Git pathspecs, relative to the member's directory, that the component is built and deployed from. A change to any file they match between the two releases' commits deploys it. Magic such as :(exclude) and :(top) is git's.",
|
|
89
|
+
"items": { "type": "string", "minLength": 1 }
|
|
90
|
+
},
|
|
91
|
+
"params": {
|
|
92
|
+
"type": "array",
|
|
93
|
+
"description": "Build parameters, by name, whose values in the environment's target the component deploys from. A value that differs between the two releases deploys it.",
|
|
94
|
+
"items": { "type": "string", "minLength": 1 }
|
|
95
|
+
}
|
|
96
|
+
}
|
|
80
97
|
}
|
|
81
98
|
},
|
|
82
99
|
"$defs": {
|
|
@@ -194,6 +194,26 @@ export interface Component {
|
|
|
194
194
|
* environments are its member's, as before.
|
|
195
195
|
*/
|
|
196
196
|
environments?: ComponentEnvironmentDeclaration[];
|
|
197
|
+
/**
|
|
198
|
+
* Optional: what a deploy of this component is made from (#4695). A run
|
|
199
|
+
* under a release (`chant run --components --release`) skips the component
|
|
200
|
+
* when these are the same as in the release the environment runs it from,
|
|
201
|
+
* and records the skip; `--deploy-unchanged` deploys it anyway. Omitted, the
|
|
202
|
+
* component deploys with every release. See ./unchanged-inputs.ts.
|
|
203
|
+
*/
|
|
204
|
+
inputs?: ComponentInputs;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/** What a component's deploy is made from (#4695), compared between two releases. */
|
|
208
|
+
export interface ComponentInputs {
|
|
209
|
+
/**
|
|
210
|
+
* Git pathspecs, relative to the member's directory, such as
|
|
211
|
+
* `../crates/control` or `:(exclude)../web/e2e`. A change between the two
|
|
212
|
+
* releases' commits to a file they match deploys the component.
|
|
213
|
+
*/
|
|
214
|
+
paths?: string[];
|
|
215
|
+
/** Build parameters, by name. A value that differs between the two releases' targets for the environment deploys the component. */
|
|
216
|
+
params?: string[];
|
|
197
217
|
}
|
|
198
218
|
|
|
199
219
|
/** One environment a component declares it deploys to (#3153). */
|
package/src/components/index.ts
CHANGED
|
@@ -99,7 +99,7 @@ describe("createCapabilityRegistry", () => {
|
|
|
99
99
|
// for them to live in instead.
|
|
100
100
|
test("family table lists exactly the agnostic starter families plus the Cloudflare apply leaves (#1293)", () => {
|
|
101
101
|
expect(Object.keys(STARTER_VERB_FAMILIES).sort()).toEqual(
|
|
102
|
-
["build", "cloudflare", "engineOutputs", "escapeHatch", "publish", "sbom", "secrets", "supplyChainPolicy", "supplyChainSecurity", "waitVerify"].sort(),
|
|
102
|
+
["build", "cloudflare", "engineOutputs", "escapeHatch", "publish", "release", "sbom", "secrets", "supplyChainPolicy", "supplyChainSecurity", "waitVerify"].sort(),
|
|
103
103
|
);
|
|
104
104
|
});
|
|
105
105
|
|