@intentius/chant 0.124.103 → 0.124.104
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/audit/secrets.d.ts +6 -0
- package/dist/audit/secrets.js +9 -2
- package/dist/cli/commands/import-index.d.ts +15 -0
- package/dist/cli/commands/import-index.js +37 -3
- package/dist/cli/handlers/lifecycle.js +6 -0
- package/dist/cli/handlers/release-config.d.ts +15 -0
- package/dist/cli/handlers/release-config.js +58 -0
- package/dist/cli/handlers/release.js +36 -3
- package/dist/cli/main.js +12 -2
- package/dist/cli/parse-args.js +7 -0
- package/dist/cli/registry.d.ts +2 -0
- package/dist/cli/release-commands/cut.js +3 -0
- package/dist/config-import.js +26 -4
- package/dist/config.d.ts +14 -0
- package/dist/config.js +4 -0
- package/dist/floor-table.data.js +7 -6
- package/dist/floor-table.js +3 -1
- package/dist/graph-refs.d.ts +9 -0
- package/dist/graph-refs.js +9 -7
- package/dist/lifecycle/cloud-index.d.ts +6 -0
- package/dist/lifecycle/cloud-index.js +32 -5
- package/dist/lifecycle/identity-match.d.ts +18 -2
- package/dist/lifecycle/identity-match.js +10 -5
- package/dist/lifecycle/index-drift.d.ts +13 -0
- package/dist/lifecycle/index-drift.js +21 -3
- package/dist/lifecycle/index-import.d.ts +15 -0
- package/dist/lifecycle/index-import.js +25 -2
- package/dist/lifecycle/index-join.d.ts +1 -1
- package/dist/lifecycle/index-join.js +1 -1
- package/dist/lifecycle/publish-declaration.d.ts +6 -0
- package/dist/lifecycle/publish-declaration.js +18 -1
- package/dist/lifecycle/publish-forge.d.ts +2 -0
- package/dist/lifecycle/publish-forge.js +3 -1
- package/dist/lifecycle/publish-oci.d.ts +27 -0
- package/dist/lifecycle/publish-oci.js +63 -8
- package/dist/lifecycle/release-changelog.d.ts +18 -5
- package/dist/lifecycle/release-changelog.js +22 -10
- package/dist/lifecycle/release-cut.d.ts +13 -1
- package/dist/lifecycle/release-cut.js +3 -0
- package/dist/lifecycle/release-images.d.ts +32 -2
- package/dist/lifecycle/release-images.js +70 -2
- package/dist/lifecycle/release-init-goreleaser-images.d.ts +21 -0
- package/dist/lifecycle/release-init-goreleaser-images.js +160 -0
- package/dist/lifecycle/release-init.d.ts +22 -0
- package/dist/lifecycle/release-init.js +86 -7
- package/dist/local-chant.d.ts +3 -0
- package/dist/local-chant.js +28 -2
- package/dist/release-floors.d.ts +10 -6
- package/dist/release-floors.js +10 -6
- package/dist/ts-loader.d.ts +12 -3
- package/dist/ts-loader.js +27 -11
- package/dist/wave-runtime.mjs +291 -290
- package/dist/workspace/catalog-edges.d.ts +22 -0
- package/dist/workspace/catalog-edges.js +23 -0
- package/dist/workspace/release-steps/goreleaser.d.ts +6 -3
- package/dist/workspace/release-steps/goreleaser.js +12 -6
- package/dist/workspace/release-toolchains.d.ts +6 -0
- package/dist/workspace/release-toolchains.js +8 -0
- package/dist/workspace/release-train-workflow.d.ts +18 -0
- package/dist/workspace/release-train-workflow.js +135 -7
- package/dist/workspace/release-train.js +1 -1
- package/dist/workspace/release-workflow.d.ts +26 -0
- package/dist/workspace/release-workflow.js +60 -12
- package/dist/workspace/train-artifacts.js +3 -4
- package/dist/workspace/train-cut.d.ts +22 -1
- package/dist/workspace/train-cut.js +78 -14
- package/package.json +2 -2
|
@@ -46,15 +46,15 @@
|
|
|
46
46
|
import { readFileSync } from "node:fs";
|
|
47
47
|
import { ACTION_PINS, tagComments, usesRef } from "../action-pins.js";
|
|
48
48
|
import { TOOL_PINS } from "../tool-pins.js";
|
|
49
|
-
import { releaseImagePlatforms, resolveReleaseImages } from "../lifecycle/release-images.js";
|
|
49
|
+
import { placeReleaseImages, releaseImagePlatforms, resolveReleaseImages } from "../lifecycle/release-images.js";
|
|
50
50
|
import { GENERATED_MARKER } from "../discovery/files.js";
|
|
51
51
|
import { tagShape } from "../lifecycle/release-tag.js";
|
|
52
|
-
import { checkBuilds, releaseBuildArchive, releaseBuildArtifact, resolveToolchains, toolchainLines } from "./release-toolchains.js";
|
|
52
|
+
import { buildJobToolchains, checkBuilds, releaseBuildArchive, releaseBuildArtifact, resolveToolchains, toolchainLines } from "./release-toolchains.js";
|
|
53
53
|
import { releaseJobSteps, releaseSetupSteps } from "./release-steps/index.js";
|
|
54
54
|
import { packLine } from "./release-steps/builds.js";
|
|
55
55
|
import { RELEASE_BINFMT_IMAGE, qemuArchitectures } from "./release-steps/qemu.js";
|
|
56
56
|
import { targetExtras } from "./release-steps/targets.js";
|
|
57
|
-
import { goreleaserSetup } from "./release-steps/goreleaser.js";
|
|
57
|
+
import { goreleaserSetup, setsUpGo } from "./release-steps/goreleaser.js";
|
|
58
58
|
import { renderTrainWorkflow } from "./release-train-workflow.js";
|
|
59
59
|
export const RELEASE_WORKFLOW_FORGES = ["github", "forgejo", "gitlab"];
|
|
60
60
|
/** Where each forge's publish workflow is written, relative to the repository root. */
|
|
@@ -96,7 +96,7 @@ export function renderReleaseWorkflow(input) {
|
|
|
96
96
|
throw new Error("release.workflow.toolchains: a GitLab job runs in its runner's image, which brings the toolchain; name the image in .gitlab-ci.yml (default: image:) and leave toolchains out");
|
|
97
97
|
}
|
|
98
98
|
const chantSetup = toolchainLines(resolveToolchains(p.toolchains === false ? false : (p.toolchains ?? []).filter((t) => (typeof t === "string" ? t : t.name) === "node"), new Set(), root, p.toolchains !== false));
|
|
99
|
-
const fullSetup = toolchainLines(
|
|
99
|
+
const fullSetup = toolchainLines(buildJobToolchains(p.toolchains, input.projectFiles, root));
|
|
100
100
|
const builds = p.builds ?? [];
|
|
101
101
|
if (builds.length > 0) {
|
|
102
102
|
if (p.trigger !== "dispatch")
|
|
@@ -145,10 +145,31 @@ export function renderReleaseWorkflow(input) {
|
|
|
145
145
|
// #5154: the root's members released as a train.
|
|
146
146
|
if (input.train) {
|
|
147
147
|
if (builds.length > 0)
|
|
148
|
-
throw new Error("release.workflow.builds: a train
|
|
148
|
+
throw new Error("release.workflow.builds at the root: a train releases its members, not the root; declare each build in the release.workflow.builds of the member whose files it builds");
|
|
149
149
|
if (images || input.artifacts)
|
|
150
150
|
throw new Error("release.images and release.artifacts at the root: a train releases its members, not the root; declare them in the member that publishes them");
|
|
151
151
|
const t = input.train;
|
|
152
|
+
// #5237: the members' per-platform builds, each run with the label the gate's plan gives its member.
|
|
153
|
+
const memberBuilds = t.builds ?? [];
|
|
154
|
+
if (memberBuilds.length > 0) {
|
|
155
|
+
if (p.trigger !== "dispatch")
|
|
156
|
+
throw new Error('release.workflow.builds in a member: the tag trigger publishes a train cut before the workflow ran, so nothing built here would be in it; use trigger: "dispatch"');
|
|
157
|
+
try {
|
|
158
|
+
checkBuilds(memberBuilds.map((b) => b.build));
|
|
159
|
+
}
|
|
160
|
+
catch (err) {
|
|
161
|
+
throw new Error(`${err instanceof Error ? err.message : String(err)} (a train runs every member's builds in one workflow, so each job name is used once across the members)`);
|
|
162
|
+
}
|
|
163
|
+
if (input.forge === "gitlab" && memberBuilds.some((b) => b.build.toolchains && b.build.toolchains.length > 0))
|
|
164
|
+
throw new Error("release.workflow.builds: toolchains: a GitLab job runs in its runner's image, which brings the toolchain; leave toolchains out");
|
|
165
|
+
}
|
|
166
|
+
const trainBuilds = memberBuilds.map((b) => {
|
|
167
|
+
const dir = [root, b.dir].filter((d) => !!d && d !== ".").join("/") || ".";
|
|
168
|
+
// The toolchains the build names, else those the member's files name, else the root's.
|
|
169
|
+
const own = (b.files ?? []).length > 0;
|
|
170
|
+
const setup = toolchainLines(resolveToolchains(b.build.toolchains !== undefined ? b.build.toolchains : p.toolchains === false ? false : own ? undefined : p.toolchains, own ? new Set(b.files) : files, own ? (dir === "." ? null : dir) : root, false));
|
|
171
|
+
return { ...b.build, member: b.member, memberDir: b.dir, path: dir, setup };
|
|
172
|
+
});
|
|
152
173
|
const trainContext = { forge: input.forge, shape: "dispatch", input: { ...input, imagePlatforms: t.imagePlatforms ?? [] }, pipeline: p, chant, root, verify: false, images: t.images === true, archives: [], artifacts: false, version: false, doctor: false, signing: input.signing === true, green, builds: [] };
|
|
153
174
|
return renderTrainWorkflow({
|
|
154
175
|
forge: input.forge,
|
|
@@ -170,11 +191,12 @@ export function renderReleaseWorkflow(input) {
|
|
|
170
191
|
...(input.lane ? { lane: input.lane } : {}),
|
|
171
192
|
// #5216: the members' images and files, from the cut to the publish; the doctor before the cut; verify before the publish.
|
|
172
193
|
files: t.images === true || t.artifacts === true,
|
|
173
|
-
...(t.artifacts && t.goreleaser ? { goreleaser: ((g) => (input.forge === "gitlab" ? g.gitlab : g.github))(goreleaserSetup(input.forge, [root, t.goreleaserDir].filter((d) => !!d && d !== ".").join("/") || null, p)) } : {}),
|
|
194
|
+
...(t.artifacts && t.goreleaser ? { goreleaser: ((g) => (input.forge === "gitlab" ? g.gitlab : g.github))(goreleaserSetup(input.forge, [root, t.goreleaserDir].filter((d) => !!d && d !== ".").join("/") || null, p, setsUpGo(p, input.projectFiles, root))) } : {}),
|
|
174
195
|
...(input.signing ? { signing: true } : {}),
|
|
175
196
|
...(input.forge === "gitlab" ? { idTokens: stepLines(releaseJobSteps({ ...trainContext, job: "publish", label: '"$CHANT_RELEASE_TRAIN"' })("idTokens"), (l) => l) } : {}),
|
|
176
197
|
doctor: p.trigger === "dispatch" && p.doctor !== false,
|
|
177
198
|
verify: input.groups.has("verified-releases"),
|
|
199
|
+
...(trainBuilds.length > 0 ? { builds: trainBuilds } : {}),
|
|
178
200
|
});
|
|
179
201
|
}
|
|
180
202
|
if (shape === "dispatch") {
|
|
@@ -439,6 +461,21 @@ export function jobExtras(p, forge) {
|
|
|
439
461
|
gitlabScript: setup.flatMap((s) => ("uses" in s ? [] : [...Object.entries(s.env ?? {}).map(([k, v]) => `export ${k}=${q(v)}`), s.run])),
|
|
440
462
|
};
|
|
441
463
|
}
|
|
464
|
+
/**
|
|
465
|
+
* A job that uploads a workflow artifact checks out without persisting the
|
|
466
|
+
* token in `.git/config` (#5268), where the upload could sweep it up, and
|
|
467
|
+
* these lines give its git the job's token instead: a credential helper for
|
|
468
|
+
* the forge's own host only, read from the job's environment, which no
|
|
469
|
+
* upload carries. The cut's fetches, the ledger push and the tag push use it.
|
|
470
|
+
*/
|
|
471
|
+
export const GIT_TOKEN_ENV = [
|
|
472
|
+
" CHANT_RELEASE_GIT_TOKEN: ${{ github.token }}",
|
|
473
|
+
' GIT_CONFIG_COUNT: "1"',
|
|
474
|
+
" GIT_CONFIG_KEY_0: credential.${{ github.server_url }}.helper",
|
|
475
|
+
` GIT_CONFIG_VALUE_0: ${JSON.stringify('!f() { test "$1" = get && echo username=x-access-token && echo "password=$CHANT_RELEASE_GIT_TOKEN"; }; f')}`,
|
|
476
|
+
];
|
|
477
|
+
/** The job's steps upload a workflow artifact (#5268). */
|
|
478
|
+
export const uploadsArtifact = (steps) => steps.some((l) => /uses:\s*actions\/upload-artifact@/.test(l));
|
|
442
479
|
/** The checkout and toolchain setup a GitHub or Forgejo job starts with (#5152); `ref` checks out that commit. */
|
|
443
480
|
export function githubSetup(ref, setup, persist = true) {
|
|
444
481
|
return [
|
|
@@ -570,6 +607,8 @@ function renderGithubDispatch(o) {
|
|
|
570
607
|
const cutStep = (slot) => stepLines(cut(slot), run);
|
|
571
608
|
const publishStep = (slot) => stepLines(publish(slot), run);
|
|
572
609
|
const built = o.builds.map((b) => `build-${b.name}`);
|
|
610
|
+
// #5268: a cut that hands files on keeps no token in .git/config.
|
|
611
|
+
const cutUploads = uploadsArtifact(cutStep("afterCut"));
|
|
573
612
|
const lines = [
|
|
574
613
|
"name: chant release",
|
|
575
614
|
"on:",
|
|
@@ -607,9 +646,9 @@ function renderGithubDispatch(o) {
|
|
|
607
646
|
" runs-on: ubuntu-latest",
|
|
608
647
|
...jobPermissions(o.extra, { contents: "write", ...(o.context.signing && o.context.doctor ? { "id-token": "write" } : {}) }, "cut"),
|
|
609
648
|
...defaults,
|
|
610
|
-
...o.extra.githubEnv([` CHANT_RELEASE_COMMIT: ${commit}`, ` CHANT_RELEASE_LABEL: ${GATE_LABEL}`, ...cutEnvToken(o)]),
|
|
649
|
+
...o.extra.githubEnv([` CHANT_RELEASE_COMMIT: ${commit}`, ` CHANT_RELEASE_LABEL: ${GATE_LABEL}`, ...cutEnvToken(o), ...(cutUploads ? GIT_TOKEN_ENV : [])]),
|
|
611
650
|
" steps:",
|
|
612
|
-
...githubSetup(commit, o.fullSetup),
|
|
651
|
+
...githubSetup(commit, o.fullSetup, !cutUploads),
|
|
613
652
|
...installLines,
|
|
614
653
|
...o.extra.githubSteps,
|
|
615
654
|
...cutStep("prepare"),
|
|
@@ -809,6 +848,8 @@ export async function runReleaseWorkflow(ctx) {
|
|
|
809
848
|
// #5154: a train publishes its members' targets, so their credentials, tools and signing are the workflow's.
|
|
810
849
|
const memberReleases = [];
|
|
811
850
|
let goreleaserDir;
|
|
851
|
+
// #5237: the members' per-platform builds, each with its member.
|
|
852
|
+
const memberBuilds = [];
|
|
812
853
|
if (release?.train) {
|
|
813
854
|
const { locateWorkspace } = await import("./which-chant.js");
|
|
814
855
|
const { readDeclaration } = await import("./declaration.js");
|
|
@@ -819,6 +860,12 @@ export async function runReleaseWorkflow(ctx) {
|
|
|
819
860
|
const r = (await loadChantConfig(join(root, m.dir))).config.release;
|
|
820
861
|
if (r)
|
|
821
862
|
memberReleases.push(r);
|
|
863
|
+
if ((r?.workflow?.builds?.length ?? 0) > 0) {
|
|
864
|
+
const { TOOLCHAIN_MARKERS } = await import("./release-toolchains.js");
|
|
865
|
+
const files = TOOLCHAIN_MARKERS.filter((f) => existsSync(join(root, m.dir, f)));
|
|
866
|
+
for (const build of r.workflow.builds)
|
|
867
|
+
memberBuilds.push({ member: m.name, dir: m.dir.split(sep).join("/"), files, build });
|
|
868
|
+
}
|
|
822
869
|
if (r?.artifacts && goreleaserDir === undefined && (await import("../lifecycle/release-artifacts.js")).usesGoreleaser(r.artifacts))
|
|
823
870
|
goreleaserDir = m.dir.split(sep).join("/");
|
|
824
871
|
}
|
|
@@ -827,18 +874,18 @@ export async function runReleaseWorkflow(ctx) {
|
|
|
827
874
|
return 1;
|
|
828
875
|
}
|
|
829
876
|
}
|
|
830
|
-
// #5216: a member's files are built by its cut, in the train's cut job;
|
|
877
|
+
// #5216: a member's files are built by its cut, in the train's cut job; #5237: or by the member's own release.workflow.builds, which builtBy names.
|
|
831
878
|
const { checkReleaseArtifacts, ReleaseArtifactError } = await import("../lifecycle/release-artifacts.js");
|
|
832
879
|
for (const r of memberReleases) {
|
|
833
880
|
if ((r.artifacts?.length ?? 0) === 0)
|
|
834
881
|
continue;
|
|
835
882
|
try {
|
|
836
|
-
checkReleaseArtifacts(r.artifacts, { builds: [] });
|
|
883
|
+
checkReleaseArtifacts(r.artifacts, { builds: r.workflow?.builds ?? [] });
|
|
837
884
|
}
|
|
838
885
|
catch (err) {
|
|
839
886
|
if (!(err instanceof ReleaseArtifactError))
|
|
840
887
|
throw err;
|
|
841
|
-
console.error(formatError({ message: `release.train: a member's ${err.message} [${err.code}]`, hint:
|
|
888
|
+
console.error(formatError({ message: `release.train: a member's ${err.message} [${err.code}]`, hint: err.fix ?? "Fix release.artifacts in the member's chant.config.ts." }));
|
|
842
889
|
return 1;
|
|
843
890
|
}
|
|
844
891
|
}
|
|
@@ -877,7 +924,7 @@ export async function runReleaseWorkflow(ctx) {
|
|
|
877
924
|
workspaceRoot,
|
|
878
925
|
tags,
|
|
879
926
|
...(release?.workflow ? { pipeline: release.workflow } : {}),
|
|
880
|
-
...((release?.images?.length ?? 0) > 0 ? { images: true, imageArchives: resolveReleaseImages(release.images).map((i) => i.archive), imagePlatforms: releaseImagePlatforms(release.images) } : {}),
|
|
927
|
+
...((release?.images?.length ?? 0) > 0 ? { images: true, imageArchives: resolveReleaseImages(placeReleaseImages(release.images, release.artifacts ?? [])).map((i) => i.archive), imagePlatforms: releaseImagePlatforms(release.images) } : {}),
|
|
881
928
|
...((release?.artifacts?.length ?? 0) > 0 ? { artifacts: true, ...((await import("../lifecycle/release-artifacts.js")).usesGoreleaser(release.artifacts) ? { goreleaser: true } : {}), ...((await import("../lifecycle/release-artifacts.js")).usesNfpm(release.artifacts) ? { nfpm: true } : {}) } : {}),
|
|
882
929
|
...(release?.lane ? { lane: release.lane } : {}),
|
|
883
930
|
green: await (async () => {
|
|
@@ -902,6 +949,7 @@ export async function runReleaseWorkflow(ctx) {
|
|
|
902
949
|
env: release.train.env,
|
|
903
950
|
...(memberImages.length > 0 ? { images: true, imagePlatforms: releaseImagePlatforms(memberImages) } : {}),
|
|
904
951
|
...(memberArtifacts.length > 0 ? { artifacts: true, ...((await import("../lifecycle/release-artifacts.js")).usesGoreleaser(memberArtifacts) ? { goreleaser: true, ...(goreleaserDir ? { goreleaserDir } : {}) } : {}) } : {}),
|
|
952
|
+
...(memberBuilds.length > 0 ? { builds: memberBuilds } : {}),
|
|
905
953
|
},
|
|
906
954
|
}
|
|
907
955
|
: {}),
|
|
@@ -32,9 +32,8 @@ import { readDeclaration } from "./declaration.js";
|
|
|
32
32
|
import { findTrain, readReleaseTrains } from "./release-train.js";
|
|
33
33
|
import { ownChant, TrainCutError } from "./train-cut.js";
|
|
34
34
|
import { locateWorkspace } from "./which-chant.js";
|
|
35
|
-
import { NEXT_RELEASE } from "../release-floors.js";
|
|
36
35
|
/** The first chant with `chant workspace train artifacts`, `train verify` and `train cut --doctor`, and a train publish that gives a member with images its digests in `CHANT_RELEASE_DIGESTS` (#5216): what the train workflow's cut and publish jobs run. */
|
|
37
|
-
export const TRAIN_ARTIFACTS_FLOOR =
|
|
36
|
+
export const TRAIN_ARTIFACTS_FLOOR = "0.124.103";
|
|
38
37
|
/** The file `-o` writes beside the staged files, naming the members staged. */
|
|
39
38
|
export const TRAIN_ARTIFACTS_INDEX = "chant-train-artifacts.json";
|
|
40
39
|
/** The train, and its members cut from the commit checked out at the workspace root. */
|
|
@@ -77,7 +76,7 @@ export async function trainArtifacts(q) {
|
|
|
77
76
|
const { loadChantConfig } = await import("../config.js");
|
|
78
77
|
const { resolveRelease } = await import("../lifecycle/release-store.js");
|
|
79
78
|
const { releaseArtifactFiles } = await import("../lifecycle/release-artifacts.js");
|
|
80
|
-
const { resolveReleaseImages } = await import("../lifecycle/release-images.js");
|
|
79
|
+
const { placeReleaseImages, resolveReleaseImages } = await import("../lifecycle/release-images.js");
|
|
81
80
|
const chant = q.chant ?? spawnMemberChant;
|
|
82
81
|
const say = q.say ?? (() => undefined);
|
|
83
82
|
const out = [];
|
|
@@ -91,7 +90,7 @@ export async function trainArtifacts(q) {
|
|
|
91
90
|
const found = await resolveRelease(m.releaseDigest, { cwd: m.dir });
|
|
92
91
|
if (!found)
|
|
93
92
|
throw new TrainCutError("release-not-found", `${m.member}: the train pins release ${m.releaseDigest}, which no cut in the member names`, `Fetch chant/lifecycle (git fetch origin chant/lifecycle:chant/lifecycle) in the train's checkout.`);
|
|
94
|
-
const images = resolveReleaseImages(declaredImages).map((i) => i.archive.replace(/^\.\//, ""));
|
|
93
|
+
const images = resolveReleaseImages(placeReleaseImages(declaredImages, declaredFiles)).map((i) => i.archive.replace(/^\.\//, ""));
|
|
95
94
|
const files = releaseArtifactFiles(found.release, declaredFiles.map((d) => d.name)).map((f) => f.path);
|
|
96
95
|
let copied = 0;
|
|
97
96
|
if (q.from !== undefined) {
|
|
@@ -37,9 +37,17 @@
|
|
|
37
37
|
* the commit. A workflow on that tag publishes the train.
|
|
38
38
|
*
|
|
39
39
|
* Without `--yes` it plans: it prints the members and labels, runs each
|
|
40
|
-
* cut's dry run, and cuts, records, tags and pushes nothing.
|
|
40
|
+
* cut's dry run, and cuts, records, tags and pushes nothing. `--plan-only`
|
|
41
|
+
* (#5237) prints the members and labels and runs no member's dry run: what
|
|
42
|
+
* a workflow's gate reads to give each per-platform build job its member's
|
|
43
|
+
* label. `--planned "<member>=<label> ..."` (or `none`) then makes the cut
|
|
44
|
+
* refuse (`train-plan-changed`) unless it plans exactly those members at
|
|
45
|
+
* those labels, so the files the build jobs made carry the labels the cut
|
|
46
|
+
* records.
|
|
41
47
|
*/
|
|
42
48
|
import { type ReleaseBump } from "./release-changed.js";
|
|
49
|
+
/** The first chant with `chant workspace train cut --plan-only` and `--planned` (#5237): what the train workflow's gate and cut jobs run when a member declares `release.workflow.builds`. */
|
|
50
|
+
export declare const TRAIN_BUILDS_FLOOR = "0.124.104";
|
|
43
51
|
/** `release.train` in a workspace root's `chant.config.ts` (#5154). */
|
|
44
52
|
export interface ReleaseTrainConfig {
|
|
45
53
|
/** The environment the train is recorded for, and the middle of its tag `release-train/<env>/<id>`. */
|
|
@@ -126,6 +134,12 @@ export interface TrainCutQuery {
|
|
|
126
134
|
/** The commit; the trunk's tip without it. */
|
|
127
135
|
at?: string;
|
|
128
136
|
levels?: TrainLevels;
|
|
137
|
+
/**
|
|
138
|
+
* The members and labels a plan made earlier gave (#5237), by member: the
|
|
139
|
+
* cut refuses (`train-plan-changed`) unless its own plan names exactly
|
|
140
|
+
* these, before any check, doctor or cut runs. Empty for a plan of nothing.
|
|
141
|
+
*/
|
|
142
|
+
planned?: Record<string, string>;
|
|
129
143
|
/** Reads the registry's versions. Default: {@link npmVersions}. */
|
|
130
144
|
registry?: NpmVersionsReader;
|
|
131
145
|
}
|
|
@@ -187,6 +201,13 @@ export interface TrainCutOutcome extends TrainCutPlan {
|
|
|
187
201
|
/** Why the record did not reach the remote, when it did not. */
|
|
188
202
|
pushWarning?: string;
|
|
189
203
|
}
|
|
204
|
+
/**
|
|
205
|
+
* Parse `--planned` (#5237): `<member>=<label>` words separated by spaces or
|
|
206
|
+
* commas, as a plan's members give them, or `none` for a plan of nothing.
|
|
207
|
+
*/
|
|
208
|
+
export declare function parseTrainPlanned(text: string): Record<string, string>;
|
|
209
|
+
/** The members and labels of a plan, as `--planned` takes them: `none` for a plan of nothing. */
|
|
210
|
+
export declare function plannedText(plan: Pick<TrainCutPlan, "members">): string;
|
|
190
211
|
/** Plan, and with `yes` cut, record, tag and push, a release train (#5154). */
|
|
191
212
|
export declare function cutTrain(q: TrainCutRun): Promise<TrainCutOutcome>;
|
|
192
213
|
/** `chant workspace train cut <env>` (#5154). */
|
|
@@ -37,7 +37,13 @@
|
|
|
37
37
|
* the commit. A workflow on that tag publishes the train.
|
|
38
38
|
*
|
|
39
39
|
* Without `--yes` it plans: it prints the members and labels, runs each
|
|
40
|
-
* cut's dry run, and cuts, records, tags and pushes nothing.
|
|
40
|
+
* cut's dry run, and cuts, records, tags and pushes nothing. `--plan-only`
|
|
41
|
+
* (#5237) prints the members and labels and runs no member's dry run: what
|
|
42
|
+
* a workflow's gate reads to give each per-platform build job its member's
|
|
43
|
+
* label. `--planned "<member>=<label> ..."` (or `none`) then makes the cut
|
|
44
|
+
* refuse (`train-plan-changed`) unless it plans exactly those members at
|
|
45
|
+
* those labels, so the files the build jobs made carry the labels the cut
|
|
46
|
+
* records.
|
|
41
47
|
*/
|
|
42
48
|
import { execFileSync, spawnSync } from "node:child_process";
|
|
43
49
|
import { runToStderr } from "./train-shell.js";
|
|
@@ -50,6 +56,8 @@ import { readDeclaration } from "./declaration.js";
|
|
|
50
56
|
import { bumpLabel, parseVersion, RELEASE_BUMPS } from "./release-changed.js";
|
|
51
57
|
import { appendReleaseTrain, pickTrain, readMemberReleases, readReleaseTrains, trainDigest } from "./release-train.js";
|
|
52
58
|
import { locateWorkspace } from "./which-chant.js";
|
|
59
|
+
/** The first chant with `chant workspace train cut --plan-only` and `--planned` (#5237): what the train workflow's gate and cut jobs run when a member declares `release.workflow.builds`. */
|
|
60
|
+
export const TRAIN_BUILDS_FLOOR = "0.124.104";
|
|
53
61
|
/** Why a train cut stopped. */
|
|
54
62
|
export class TrainCutError extends Error {
|
|
55
63
|
constructor(code, message, fix) {
|
|
@@ -351,10 +359,58 @@ const defaultDoctor = (dir) => {
|
|
|
351
359
|
const [bin, ...pre] = ownChant();
|
|
352
360
|
return spawnSync(bin, [...pre, "release", "doctor"], { cwd: dir, stdio: ["ignore", 2, 2] }).status ?? 1;
|
|
353
361
|
};
|
|
362
|
+
/**
|
|
363
|
+
* Parse `--planned` (#5237): `<member>=<label>` words separated by spaces or
|
|
364
|
+
* commas, as a plan's members give them, or `none` for a plan of nothing.
|
|
365
|
+
*/
|
|
366
|
+
export function parseTrainPlanned(text) {
|
|
367
|
+
const out = {};
|
|
368
|
+
const words = text.split(/[\s,]+/).filter(Boolean);
|
|
369
|
+
if (words.length === 1 && words[0] === "none")
|
|
370
|
+
return out;
|
|
371
|
+
if (words.length === 0)
|
|
372
|
+
throw new TrainCutError("train-planned-invalid", "--planned names no member", 'Give the plan\'s members as <member>=<label>, separated by spaces, or none for a plan of nothing.');
|
|
373
|
+
for (const word of words) {
|
|
374
|
+
const at = word.indexOf("=");
|
|
375
|
+
if (at <= 0 || at === word.length - 1)
|
|
376
|
+
throw new TrainCutError("train-planned-invalid", `--planned ${JSON.stringify(word)}: each word is <member>=<label>`);
|
|
377
|
+
const m = word.slice(0, at);
|
|
378
|
+
if (out[m] !== undefined)
|
|
379
|
+
throw new TrainCutError("train-planned-invalid", `--planned names ${m} twice`);
|
|
380
|
+
out[m] = word.slice(at + 1);
|
|
381
|
+
}
|
|
382
|
+
return out;
|
|
383
|
+
}
|
|
384
|
+
/** The members and labels of a plan, as `--planned` takes them: `none` for a plan of nothing. */
|
|
385
|
+
export function plannedText(plan) {
|
|
386
|
+
return plan.members.map((m) => `${m.member}=${m.label}`).join(",") || "none";
|
|
387
|
+
}
|
|
388
|
+
/** Refuse a plan that differs from the one `--planned` gave (#5237). */
|
|
389
|
+
function checkPlanned(plan, planned) {
|
|
390
|
+
const got = new Map(plan.members.map((m) => [m.member, m.label]));
|
|
391
|
+
const diffs = [];
|
|
392
|
+
for (const [m, label] of Object.entries(planned)) {
|
|
393
|
+
const now = got.get(m);
|
|
394
|
+
if (now === undefined)
|
|
395
|
+
diffs.push(`${m} was planned at ${label} and is not in the train now`);
|
|
396
|
+
else if (now !== label)
|
|
397
|
+
diffs.push(`${m} was planned at ${label} and is labelled ${now} now`);
|
|
398
|
+
}
|
|
399
|
+
for (const [m, label] of got)
|
|
400
|
+
if (planned[m] === undefined)
|
|
401
|
+
diffs.push(`${m} is in the train now at ${label}, and was not planned`);
|
|
402
|
+
if (plan.released !== null && Object.keys(planned).length > 0)
|
|
403
|
+
diffs.unshift(`${plan.commit.slice(0, 12)} is released now as ${plan.released}`);
|
|
404
|
+
if (diffs.length > 0) {
|
|
405
|
+
throw new TrainCutError("train-plan-changed", `the train differs from the plan the build jobs built for: ${diffs.join("; ")}`, "Nothing was cut. A release or a tag landed between the plan and the cut; start the train again, so the builds run with the labels it cuts.");
|
|
406
|
+
}
|
|
407
|
+
}
|
|
354
408
|
/** Plan, and with `yes` cut, record, tag and push, a release train (#5154). */
|
|
355
409
|
export async function cutTrain(q) {
|
|
356
410
|
const root = locateWorkspace(q.cwd).rootOnDisk;
|
|
357
411
|
const plan = await planTrainCut(q);
|
|
412
|
+
if (q.planned !== undefined)
|
|
413
|
+
checkPlanned(plan, q.planned);
|
|
358
414
|
const say = q.say ?? (() => undefined);
|
|
359
415
|
const base = { ...plan, tags: {}, train: null, trainTag: null, pushed: false };
|
|
360
416
|
if (plan.released !== null || plan.members.length === 0)
|
|
@@ -453,7 +509,7 @@ export async function cutTrain(q) {
|
|
|
453
509
|
}
|
|
454
510
|
return { ...out, pushed: true };
|
|
455
511
|
}
|
|
456
|
-
const CUT_USAGE = "chant workspace train cut <env> [--at <sha>] [--levels <levels>] [--doctor] [--yes] [--no-push] [--json]";
|
|
512
|
+
const CUT_USAGE = "chant workspace train cut <env> [--at <sha>] [--levels <levels>] [--plan-only] [--planned <member=label ...|none>] [--doctor] [--yes] [--no-push] [--json]";
|
|
457
513
|
/** `chant workspace train cut <env>` (#5154). */
|
|
458
514
|
export async function runTrainCut(ctx, words) {
|
|
459
515
|
const { formatError, formatSuccess, formatWarning } = await import("../cli/format.js");
|
|
@@ -471,18 +527,22 @@ export async function runTrainCut(ctx, words) {
|
|
|
471
527
|
await fetchLifecycle({ cwd }).catch(() => false);
|
|
472
528
|
spawnSync("git", ["fetch", "--quiet", "origin", "refs/tags/*:refs/tags/*"], { cwd, stdio: "ignore" });
|
|
473
529
|
let outcome;
|
|
530
|
+
const planOnly = args.planOnly === true;
|
|
474
531
|
try {
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
532
|
+
if (planOnly && (args.yes === true || args.planned !== undefined))
|
|
533
|
+
throw new TrainCutError("train-plan-only", `--plan-only prints the plan and cuts nothing, so it takes no ${args.yes === true ? "--yes" : "--planned"}`, CUT_USAGE);
|
|
534
|
+
const query = { cwd, env, ...(args.at ? { at: args.at } : {}), levels: parseTrainLevels(args.levels) };
|
|
535
|
+
outcome = planOnly
|
|
536
|
+
? { ...(await planTrainCut(query)), tags: {}, train: null, trainTag: null, pushed: false }
|
|
537
|
+
: await cutTrain({
|
|
538
|
+
...query,
|
|
539
|
+
...(args.planned !== undefined ? { planned: parseTrainPlanned(args.planned) } : {}),
|
|
540
|
+
yes: args.yes === true && args.dryRun !== true,
|
|
541
|
+
noPush: args.noPush === true,
|
|
542
|
+
doctor: args.doctor === true,
|
|
543
|
+
...(args.actor ? { actor: args.actor } : {}),
|
|
544
|
+
say: (line) => (json ? undefined : console.error(line)),
|
|
545
|
+
});
|
|
486
546
|
}
|
|
487
547
|
catch (err) {
|
|
488
548
|
if (err instanceof TrainCutError) {
|
|
@@ -498,7 +558,7 @@ export async function runTrainCut(ctx, words) {
|
|
|
498
558
|
throw err;
|
|
499
559
|
}
|
|
500
560
|
if (json) {
|
|
501
|
-
console.log(JSON.stringify({ dryRun: args.yes !== true || args.dryRun === true, ...outcome }, null, 2));
|
|
561
|
+
console.log(JSON.stringify({ dryRun: planOnly || args.yes !== true || args.dryRun === true, ...(planOnly ? { planOnly: true, planned: plannedText(outcome) } : {}), ...outcome }, null, 2));
|
|
502
562
|
return 0;
|
|
503
563
|
}
|
|
504
564
|
const short = outcome.commit.slice(0, 12);
|
|
@@ -513,6 +573,10 @@ export async function runTrainCut(ctx, words) {
|
|
|
513
573
|
console.log(`Release train for ${env} from ${short}${outcome.first ? " (the first: every member at one label)" : ""}:`);
|
|
514
574
|
for (const m of outcome.members)
|
|
515
575
|
console.log(` ${m.member.padEnd(24)} ${m.label.padEnd(12)} ${m.why}${m.bump ? `; ${m.bump} from ${m.bumpFrom}` : ""}${m.floor ? `; floor ${m.floor}` : ""}`);
|
|
576
|
+
if (planOnly) {
|
|
577
|
+
console.error(`Plan only: no member's dry run ran, and nothing was cut. Cut it as planned with --planned ${JSON.stringify(plannedText(outcome))}.`);
|
|
578
|
+
return 0;
|
|
579
|
+
}
|
|
516
580
|
if (args.yes !== true || args.dryRun === true) {
|
|
517
581
|
console.error("Dry run: nothing was cut, recorded, tagged or pushed. Run again with --yes to cut the train.");
|
|
518
582
|
return 0;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intentius/chant",
|
|
3
|
-
"version": "0.124.
|
|
3
|
+
"version": "0.124.104",
|
|
4
4
|
"description": "Declarative infrastructure-as-code toolkit — TypeScript on Node.js",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"homepage": "https://intentius.io/chant",
|
|
@@ -175,7 +175,7 @@
|
|
|
175
175
|
},
|
|
176
176
|
"scripts": {
|
|
177
177
|
"build": "../../scripts/tsc7.sh -p tsconfig.build.json --sourceMap false && tsc-alias -p tsconfig.build.json && node scripts/copy-assets.mjs && node scripts/build-wave-runtime.mjs",
|
|
178
|
-
"prepack": "npm run build"
|
|
178
|
+
"prepack": "tsx ../../scripts/release-floors.ts --pack npm run build"
|
|
179
179
|
},
|
|
180
180
|
"dependencies": {
|
|
181
181
|
"@dagrejs/dagre": "^3.0.0",
|