@intentius/chant 0.124.64 → 0.124.66
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/pr.d.ts.map +1 -1
- package/dist/cli/handlers/pr.js +3 -1
- 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 +121 -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 +10 -3
- package/dist/op/activities/activity-contracts.d.ts +4 -4
- package/dist/op/op-waves-run.js +5 -3
- package/dist/pr-forge.d.ts.map +1 -1
- package/dist/pr-forge.js +3 -1
- package/dist/release-floors.d.ts +1 -1
- package/dist/release-floors.js +1 -1
- package/dist/wave-runtime.mjs +311 -311
- 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/pr.ts +3 -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 +150 -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 +28 -5
- package/src/op/op-waves-run.ts +4 -2
- package/src/pr-forge.ts +3 -1
- package/src/pr-requires.test.ts +10 -0
- 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
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A component a release leaves alone (#4695): one whose declared inputs are
|
|
3
|
+
* the same as in the release the environment runs it from.
|
|
4
|
+
*
|
|
5
|
+
* Some deploys cost something even when nothing changed. Arugula's hub drops
|
|
6
|
+
* every relayed terminal when it restarts, and `fly-release` stamps each
|
|
7
|
+
* release's commit on the Machine, so every release would restart it. A
|
|
8
|
+
* component declares what it is made from (`inputs` on the component):
|
|
9
|
+
*
|
|
10
|
+
* ```ts
|
|
11
|
+
* inputs: {
|
|
12
|
+
* paths: ["../crates/control", "../web", ":(exclude)../web/e2e", "../Cargo.lock", "src/control.component.ts", "src/control.fly.ts"],
|
|
13
|
+
* params: ["region"],
|
|
14
|
+
* }
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* and a run under a release (`chant run --components --release`) compares
|
|
18
|
+
* them with the release named by the environment's latest record of the
|
|
19
|
+
* component. The component is unchanged when:
|
|
20
|
+
*
|
|
21
|
+
* - git sees no change between the two releases' commits to a file the
|
|
22
|
+
* `paths` match, read as pathspecs from the member's directory;
|
|
23
|
+
* - each of the `params` has the same value in the two releases' targets for
|
|
24
|
+
* the environment;
|
|
25
|
+
* - the deploy files the two targets record for the component
|
|
26
|
+
* (`releaseTemplatesDigest`) are the same, so a change to what the
|
|
27
|
+
* component deploys is never skipped for want of a listed path.
|
|
28
|
+
*
|
|
29
|
+
* Anything that can't be compared deploys: no record of the component in the
|
|
30
|
+
* environment, a record made from no release, a release that isn't stored, a
|
|
31
|
+
* commit git doesn't have. `--deploy-unchanged` deploys it anyway.
|
|
32
|
+
*
|
|
33
|
+
* A skip is recorded ({@link unchangedRecord}): a release record of this
|
|
34
|
+
* release for the component that repeats the digest of the deploy it keeps
|
|
35
|
+
* and names that deploy in `unchangedSince`.
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
import { execFileSync } from "node:child_process";
|
|
39
|
+
import type { ComponentInputs } from "./component";
|
|
40
|
+
import type { Release } from "../lifecycle/release-store";
|
|
41
|
+
import type { ReleaseRecord, ReleaseRecordInput, RunOrigin } from "../lifecycle/release-ledger";
|
|
42
|
+
import { releaseTemplatesDigest } from "./release-promote";
|
|
43
|
+
|
|
44
|
+
/** The first chant that reads a component's `inputs` and writes `unchangedSince` on a release record (#4695). */
|
|
45
|
+
export const UNCHANGED_INPUTS_FLOOR = "0.124.65";
|
|
46
|
+
|
|
47
|
+
/** Whether a component's inputs are the same as in the release the environment runs it from. */
|
|
48
|
+
export type InputsVerdict =
|
|
49
|
+
| {
|
|
50
|
+
unchanged: true;
|
|
51
|
+
/** The environment's record of the deploy that stays. */
|
|
52
|
+
since: ReleaseRecord;
|
|
53
|
+
/** The environment's record already names this release: there is nothing new to record. */
|
|
54
|
+
recorded: boolean;
|
|
55
|
+
}
|
|
56
|
+
| { unchanged: false; reason: string };
|
|
57
|
+
|
|
58
|
+
/** The files `paths` match that differ between two commits, or null when git can't tell. */
|
|
59
|
+
export type ChangedPaths = (from: string, to: string, paths: readonly string[]) => string[] | null;
|
|
60
|
+
|
|
61
|
+
/** {@link ChangedPaths} through `git diff`, with the pathspecs read from `memberDir`. */
|
|
62
|
+
export function gitChangedPaths(memberDir: string): ChangedPaths {
|
|
63
|
+
return (from, to, paths) => {
|
|
64
|
+
try {
|
|
65
|
+
const out = execFileSync("git", ["diff", "--name-only", "--no-renames", from, to, "--", ...paths], {
|
|
66
|
+
cwd: memberDir,
|
|
67
|
+
encoding: "utf-8",
|
|
68
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
69
|
+
});
|
|
70
|
+
return out.split("\n").filter((l) => l !== "");
|
|
71
|
+
} catch {
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const shortDigest = (d: string): string => d.replace(/^jcs1-sha256:/, "").slice(0, 12);
|
|
78
|
+
|
|
79
|
+
/** Compare `component`'s declared inputs in `release` with the release the environment's `current` record names. */
|
|
80
|
+
export async function compareInputs(input: {
|
|
81
|
+
component: string;
|
|
82
|
+
inputs: ComponentInputs;
|
|
83
|
+
env: string;
|
|
84
|
+
release: Release;
|
|
85
|
+
/** The environment's latest record of the component, if it has one. */
|
|
86
|
+
current: ReleaseRecord | undefined;
|
|
87
|
+
readRelease: (digest: string) => Promise<Release | null>;
|
|
88
|
+
changedPaths: ChangedPaths;
|
|
89
|
+
}): Promise<InputsVerdict> {
|
|
90
|
+
const { component, inputs, env, release, current } = input;
|
|
91
|
+
const paths = inputs.paths ?? [];
|
|
92
|
+
const params = inputs.params ?? [];
|
|
93
|
+
if (paths.length === 0 && params.length === 0) return { unchanged: false, reason: "it declares no paths or params in inputs" };
|
|
94
|
+
if (!current) return { unchanged: false, reason: `"${env}" has no deploy of it` };
|
|
95
|
+
if (current.releaseDigest === undefined) return { unchanged: false, reason: `the deploy "${env}" runs (run ${current.runId}) was not made from a release` };
|
|
96
|
+
if (current.releaseDigest === release.releaseDigest) return { unchanged: true, since: current, recorded: true };
|
|
97
|
+
|
|
98
|
+
const prior = await input.readRelease(current.releaseDigest).catch(() => null);
|
|
99
|
+
if (!prior) return { unchanged: false, reason: `release ${shortDigest(current.releaseDigest)}, which "${env}" runs it from, is not stored here` };
|
|
100
|
+
const before = prior.targets.find((t) => t.env === env);
|
|
101
|
+
const now = release.targets.find((t) => t.env === env);
|
|
102
|
+
if (!before || !now) return { unchanged: false, reason: `release ${shortDigest((before ? release : prior).releaseDigest)} has no target for "${env}"` };
|
|
103
|
+
|
|
104
|
+
for (const name of params) {
|
|
105
|
+
const a = before.params.find((p) => p.name === name)?.value;
|
|
106
|
+
const b = now.params.find((p) => p.name === name)?.value;
|
|
107
|
+
if (a !== b) return { unchanged: false, reason: `param ${name} is ${JSON.stringify(b)}, was ${JSON.stringify(a)}` };
|
|
108
|
+
}
|
|
109
|
+
if (releaseTemplatesDigest(before, component) !== releaseTemplatesDigest(now, component)) {
|
|
110
|
+
return { unchanged: false, reason: `the files its deploy reads in the "${env}" target changed` };
|
|
111
|
+
}
|
|
112
|
+
if (paths.length > 0 && prior.commit !== release.commit) {
|
|
113
|
+
const changed = input.changedPaths(prior.commit, release.commit, paths);
|
|
114
|
+
if (changed === null) {
|
|
115
|
+
return { unchanged: false, reason: `git can't compare ${prior.commit.slice(0, 12)} and ${release.commit.slice(0, 12)} here; fetch the history between them` };
|
|
116
|
+
}
|
|
117
|
+
if (changed.length > 0) {
|
|
118
|
+
return { unchanged: false, reason: `${changed.length} input file(s) changed since ${prior.commit.slice(0, 12)}, such as ${changed[0]}` };
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
return { unchanged: true, since: current, recorded: false };
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* The record of a skip (#4695): this release, for `since`'s component in its
|
|
126
|
+
* environment, repeating what that deploy recorded of its artifact and naming
|
|
127
|
+
* it in `unchangedSince`. Who approved that deploy is not repeated, since
|
|
128
|
+
* nothing was approved now.
|
|
129
|
+
*/
|
|
130
|
+
export function unchangedRecord(
|
|
131
|
+
since: ReleaseRecord,
|
|
132
|
+
run: { releaseDigest: string; runId: string; runOrigin?: RunOrigin; timestamp: string; actor: string },
|
|
133
|
+
): ReleaseRecordInput {
|
|
134
|
+
return {
|
|
135
|
+
component: since.component,
|
|
136
|
+
env: since.env,
|
|
137
|
+
digest: since.digest,
|
|
138
|
+
gitSha: since.gitSha,
|
|
139
|
+
...(since.manifestDigest !== undefined ? { manifestDigest: since.manifestDigest } : {}),
|
|
140
|
+
...(since.inputDigest !== undefined ? { inputDigest: since.inputDigest } : {}),
|
|
141
|
+
...(since.digestKind !== undefined ? { digestKind: since.digestKind } : {}),
|
|
142
|
+
...(since.releaseVersion !== undefined ? { releaseVersion: since.releaseVersion } : {}),
|
|
143
|
+
runId: run.runId,
|
|
144
|
+
...(run.runOrigin ? { runOrigin: run.runOrigin } : {}),
|
|
145
|
+
timestamp: run.timestamp,
|
|
146
|
+
actor: run.actor,
|
|
147
|
+
releaseDigest: run.releaseDigest,
|
|
148
|
+
unchangedSince: { env: since.env, runId: since.runId, timestamp: since.timestamp },
|
|
149
|
+
};
|
|
150
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `release-image`: the image a release recorded for this component (#4694).
|
|
3
|
+
*
|
|
4
|
+
* A component whose image is built elsewhere, as by a CI job with a toolchain
|
|
5
|
+
* the deploy machine lacks, declares no build and no publish. The image is
|
|
6
|
+
* handed to the cut by digest (`chant release cut --image
|
|
7
|
+
* <component>=<repository>@sha256:<hex>`), and the step stands where a publish
|
|
8
|
+
* step would, so the steps after it read the image as they would a publish's:
|
|
9
|
+
*
|
|
10
|
+
* ```ts
|
|
11
|
+
* phase("Image", [{ kind: "release-image" }]),
|
|
12
|
+
* phase("Release", [{ kind: "fly-release", plan: "dist/fly.json", image: "@Image.uri", digest: "@Image.digest" }]),
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* The step has nothing of its own to give. A run under a release
|
|
16
|
+
* (`chant run --components <c> --env <e> --release <label>`) fills in the
|
|
17
|
+
* image the release recorded (../release-run.ts), and a run of a release
|
|
18
|
+
* that recorded none is refused before anything runs. Outside a release the
|
|
19
|
+
* step fails, so a deploy never runs an image no release named.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
import type { Capability } from "../capability";
|
|
23
|
+
|
|
24
|
+
export interface ReleaseImageInput {
|
|
25
|
+
/** The image, `<repository>@sha256:<hex>`. Filled in by a run under a release; not written by the component. */
|
|
26
|
+
uri?: string;
|
|
27
|
+
/** The image's digest. Filled in with `uri`. */
|
|
28
|
+
digest?: string;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface ReleaseImageOutput {
|
|
32
|
+
/** The image reference a deploy step runs. */
|
|
33
|
+
uri: string;
|
|
34
|
+
digest: string;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** The kind of the step. */
|
|
38
|
+
export const RELEASE_IMAGE_KIND = "release-image";
|
|
39
|
+
|
|
40
|
+
export const releaseImageCapability: Capability<ReleaseImageInput, ReleaseImageOutput> = {
|
|
41
|
+
kind: RELEASE_IMAGE_KIND,
|
|
42
|
+
rollbackPolicy: "none-by-design",
|
|
43
|
+
async run(ctx, input) {
|
|
44
|
+
if (typeof input?.uri !== "string" || typeof input.digest !== "string") {
|
|
45
|
+
throw new Error(
|
|
46
|
+
`release-image: "${ctx.component}" deploys the image a release recorded for it, and this run names no release. ` +
|
|
47
|
+
`Run it under one: chant run --components ${ctx.component} --env ${ctx.env} --release <label>`,
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
return { uri: input.uri, digest: input.digest };
|
|
51
|
+
},
|
|
52
|
+
};
|
|
@@ -169,8 +169,10 @@ export function environmentMetrics(
|
|
|
169
169
|
window: MetricsWindow,
|
|
170
170
|
failureWindowDays: number = DEFAULT_FAILURE_WINDOW_DAYS,
|
|
171
171
|
): EnvironmentMetrics {
|
|
172
|
-
// Ledger order breaks timestamp ties, as `latestPerComponent` does.
|
|
173
|
-
|
|
172
|
+
// Ledger order breaks timestamp ties, as `latestPerComponent` does. A
|
|
173
|
+
// release that skipped a component (#4695) deployed nothing: its record is
|
|
174
|
+
// in no metric.
|
|
175
|
+
const sorted = records.filter((r) => r.unchangedSince === undefined).map((r, i) => ({ r, i })).sort((a, b) => at(a.r.timestamp) - at(b.r.timestamp) || a.i - b.i).map((x) => x.r);
|
|
174
176
|
const since = at(window.since);
|
|
175
177
|
const until = at(window.until);
|
|
176
178
|
const failureMs = failureWindowDays * DAY_MS;
|
|
@@ -19,7 +19,6 @@
|
|
|
19
19
|
*/
|
|
20
20
|
|
|
21
21
|
import { createHash } from "node:crypto";
|
|
22
|
-
import { NEXT_RELEASE } from "../release-floors";
|
|
23
22
|
import { GATE_SEAL_NAMESPACE, gateSealPayload, gateSealVersion, isWebAuthnAssertion, webAuthnChallenge, type SealedGateApproval, type WebAuthnAssertion } from "./gate-seal";
|
|
24
23
|
|
|
25
24
|
/**
|
|
@@ -37,7 +36,7 @@ export const GATE_EXTERNAL_SIGNATURE_FLOOR = "0.124.63";
|
|
|
37
36
|
* checks, so it finds a version 3 seal doesn't verify and counts nothing for
|
|
38
37
|
* it, whatever the gate.
|
|
39
38
|
*/
|
|
40
|
-
export const GATE_BINDING_FLOOR =
|
|
39
|
+
export const GATE_BINDING_FLOOR = "0.124.64";
|
|
41
40
|
|
|
42
41
|
/** The longest binding `--binding` takes, in UTF-8 bytes (#4697). */
|
|
43
42
|
export const GATE_BINDING_MAX_BYTES = 512;
|
|
@@ -587,6 +587,21 @@ describe("lifecycle/git", () => {
|
|
|
587
587
|
}
|
|
588
588
|
});
|
|
589
589
|
|
|
590
|
+
test("a change set the other writer stored under the same digest stays as it is there, and the rest of the commit lands", async () => {
|
|
591
|
+
const { a, b, remotePath, done } = await twoWriters();
|
|
592
|
+
try {
|
|
593
|
+
await advance(a, "_change-sets/jcs1-sha256_abc.json", '{"digest":"abc","graph":"theirs"}');
|
|
594
|
+
await writeBlobToPath("_change-sets", "jcs1-sha256_abc.json", '{"digest":"abc","graph":"ours"}', "Change set abc", { cwd: b });
|
|
595
|
+
await writeBlobToPath("prod", "release.jsonl", '{"released":1}\n', "Release record", { cwd: b });
|
|
596
|
+
|
|
597
|
+
expect(await pushLifecycleRebasing({ cwd: b })).toEqual({ pushed: true });
|
|
598
|
+
const tip = git(["rev-parse", "refs/heads/chant/lifecycle"], remotePath).stdout.trim();
|
|
599
|
+
expect(git(["show", `${tip}:prod/_change-sets/jcs1-sha256_abc.json`], remotePath).stdout).toBe('{"digest":"abc","graph":"theirs"}');
|
|
600
|
+
} finally {
|
|
601
|
+
await done();
|
|
602
|
+
}
|
|
603
|
+
});
|
|
604
|
+
|
|
590
605
|
test("a commit that changes the file the other writer changed is refused by name, and the local write is kept", async () => {
|
|
591
606
|
const { a, b, done } = await twoWriters();
|
|
592
607
|
try {
|
package/src/lifecycle/git.ts
CHANGED
|
@@ -1018,7 +1018,9 @@ async function rebaseLifecycleOnRemote(remote: string, cwd?: string): Promise<{
|
|
|
1018
1018
|
* line `onto` already holds. A run record, a release record and a gate line
|
|
1019
1019
|
* are such appends, so two writers to one environment's file no longer lose
|
|
1020
1020
|
* one of them on a replay. Any other change, or a file the commit rewrote
|
|
1021
|
-
* rather than appended to, returns why, and the replay stops as before.
|
|
1021
|
+
* rather than appended to, returns why, and the replay stops as before. A
|
|
1022
|
+
* change set the other writer already stored under the same digest stays as
|
|
1023
|
+
* it is there.
|
|
1022
1024
|
*/
|
|
1023
1025
|
async function replayAppends(parent: string, commit: string, onto: string, cwd?: string): Promise<{ tree: string } | { error: string }> {
|
|
1024
1026
|
const rt = getRuntime();
|
|
@@ -1036,6 +1038,8 @@ async function replayAppends(parent: string, commit: string, onto: string, cwd?:
|
|
|
1036
1038
|
};
|
|
1037
1039
|
const files: Array<{ path: string; content: string }> = [];
|
|
1038
1040
|
for (const { status, path } of changes) {
|
|
1041
|
+
// #4022: a stored change set is written once under its digest, so a copy already there is the same document, whatever graph it carries.
|
|
1042
|
+
if (status === "A" && /(^|\/)_change-sets\/[^/]+\.json$/.test(path) && (await blob(onto, path)) !== null) continue;
|
|
1039
1043
|
if (!path.endsWith(".jsonl") || (status !== "M" && status !== "A")) return { error: `${path} is not a ledger line file this replay appends to` };
|
|
1040
1044
|
const ours = (await blob(commit, path)) ?? "";
|
|
1041
1045
|
const base = status === "M" ? ((await blob(parent, path)) ?? "") : "";
|
|
@@ -47,7 +47,7 @@ export const LEDGER_TIME_COLUMN: Record<QueryTable, string | null> = {
|
|
|
47
47
|
};
|
|
48
48
|
|
|
49
49
|
/** The columns that hold JSON, which this read prints parsed. */
|
|
50
|
-
const JSON_COLUMNS = new Set(["attributes", "labels", "outcomes", "promoted_from", "restores", "redeploys", "artifacts", "wave", "request", "detail", "components", "approvers", "settings", "estates"]);
|
|
50
|
+
const JSON_COLUMNS = new Set(["attributes", "labels", "outcomes", "promoted_from", "restores", "redeploys", "unchanged_since", "artifacts", "wave", "request", "detail", "components", "approvers", "settings", "estates"]);
|
|
51
51
|
/** The columns that hold an ISO instant. */
|
|
52
52
|
const TIME_COLUMNS = new Set(["last_updated", "observed_at", "started", "ended", "timestamp", "expires_at", "approved_at", "finished_at"]);
|
|
53
53
|
/** INTEGER columns that hold 0 or 1, which this read prints as booleans. */
|
|
@@ -56,13 +56,12 @@ import { SshGitRepo } from "./publish-git-ssh";
|
|
|
56
56
|
import { GitHubRepo, githubApi } from "./publish-github";
|
|
57
57
|
import { bytesDigest, checkReleaseDigest, memberFile, publishTargetKey } from "./publish-targets";
|
|
58
58
|
import { PublishTargetError, type PublishContext, type PublishDeps, type PublishFetch, type PublishItem, type PublishTarget } from "./release-publish";
|
|
59
|
-
import { NEXT_RELEASE } from "../release-floors";
|
|
60
59
|
|
|
61
60
|
/** The first chant that publishes a `homebrew` target (#4676). */
|
|
62
61
|
export const PUBLISH_HOMEBREW_FLOOR = "0.124.63";
|
|
63
62
|
|
|
64
63
|
/** The first chant that reads a homebrew target's `sshKeyEnv` (#4699). */
|
|
65
|
-
export const PUBLISH_HOMEBREW_SSH_KEY_FLOOR =
|
|
64
|
+
export const PUBLISH_HOMEBREW_SSH_KEY_FLOOR = "0.124.64";
|
|
66
65
|
|
|
67
66
|
/** The variable the tap token is read from when the declaration names none. */
|
|
68
67
|
export const HOMEBREW_TOKEN_ENV = "HOMEBREW_TAP_TOKEN";
|
|
@@ -73,16 +73,15 @@ import {
|
|
|
73
73
|
type PublishTarget,
|
|
74
74
|
type StagedTarget,
|
|
75
75
|
} from "./release-publish";
|
|
76
|
-
import { NEXT_RELEASE } from "../release-floors";
|
|
77
76
|
|
|
78
77
|
/** The first chant that publishes a `marketplace` target (#4676). */
|
|
79
78
|
export const PUBLISH_MARKETPLACE_FLOOR = "0.124.63";
|
|
80
79
|
|
|
81
80
|
/** The first chant that reads a marketplace target's `auth` (#4698). */
|
|
82
|
-
export const PUBLISH_MARKETPLACE_AUTH_FLOOR =
|
|
81
|
+
export const PUBLISH_MARKETPLACE_AUTH_FLOOR = "0.124.64";
|
|
83
82
|
|
|
84
83
|
/** The first chant that reads a marketplace target's `onRefusal` (#4698). */
|
|
85
|
-
export const PUBLISH_MARKETPLACE_ON_REFUSAL_FLOOR =
|
|
84
|
+
export const PUBLISH_MARKETPLACE_ON_REFUSAL_FLOOR = "0.124.64";
|
|
86
85
|
|
|
87
86
|
export const OPEN_VSX_REGISTRY = "https://open-vsx.org";
|
|
88
87
|
export const VSCODE_GALLERY = "https://marketplace.visualstudio.com";
|
package/src/lifecycle/query.ts
CHANGED
|
@@ -90,8 +90,8 @@ export const QUERY_TABLES = {
|
|
|
90
90
|
* request a pending fact asks for, as JSON.
|
|
91
91
|
*/
|
|
92
92
|
gates: [["member", "TEXT"], ["op", "TEXT"], ["gate", "TEXT"], ["kind", "TEXT"], ["timestamp", "TEXT"], ["resolved_by", "TEXT"], ["relayed_by", "TEXT"], ["approver_kind", "TEXT"], ["plan_digest", "TEXT"], ["environment", "TEXT"], ["release_digest", "TEXT"], ["git_sha", "TEXT"], ["run_id", "TEXT"], ["url", "TEXT"], ["note", "TEXT"], ["expires_at", "TEXT"], ["origin", "TEXT"], ["empty", "INTEGER"], ["signed", "INTEGER"], ["change_set", "TEXT"], ["request", "TEXT"]],
|
|
93
|
-
/** One row per deploy record in `<env>/releases.jsonl`. `promoted_from`, `restores` and `
|
|
94
|
-
deploys: [["member", "TEXT"], ["env", "TEXT"], ["component", "TEXT"], ["digest", "TEXT"], ["git_sha", "TEXT"], ["run_id", "TEXT"], ["forge", "TEXT"], ["run_url", "TEXT"], ["timestamp", "TEXT"], ["actor", "TEXT"], ["approver", "TEXT"], ["release_digest", "TEXT"], ["digest_kind", "TEXT"], ["promoted_from", "TEXT"], ["restores", "TEXT"], ["redeploys", "TEXT"]],
|
|
93
|
+
/** One row per deploy record in `<env>/releases.jsonl`. `promoted_from`, `restores`, `redeploys` and `unchanged_since` (#4695) are JSON. */
|
|
94
|
+
deploys: [["member", "TEXT"], ["env", "TEXT"], ["component", "TEXT"], ["digest", "TEXT"], ["git_sha", "TEXT"], ["run_id", "TEXT"], ["forge", "TEXT"], ["run_url", "TEXT"], ["timestamp", "TEXT"], ["actor", "TEXT"], ["approver", "TEXT"], ["release_digest", "TEXT"], ["digest_kind", "TEXT"], ["promoted_from", "TEXT"], ["restores", "TEXT"], ["redeploys", "TEXT"], ["unchanged_since", "TEXT"]],
|
|
95
95
|
/** One row per release file whose content hashes to its digest. `envs` joins its targets' environments with commas; `artifacts` is JSON. */
|
|
96
96
|
releases: [["member", "TEXT"], ["release_digest", "TEXT"], ["release_member", "TEXT"], ["git_sha", "TEXT"], ["envs", "TEXT"], ["artifacts", "TEXT"]],
|
|
97
97
|
/** One row per line of `_releases/cuts.jsonl`. `signed` is 1 for a signed cut. */
|
|
@@ -336,7 +336,7 @@ export async function loadQueryData(ledgers: readonly QueryLedger[]): Promise<Qu
|
|
|
336
336
|
const { records, malformed: bad } = parseReleaseLedger(releaseLedgerLines(await port.read(env, file)));
|
|
337
337
|
malformed.deploys += bad;
|
|
338
338
|
for (const d of records) {
|
|
339
|
-
data.deploys.push({ member, env: d.env, component: d.component, digest: d.digest, git_sha: d.gitSha, run_id: d.runId, forge: str(d.runOrigin?.forge), run_url: str(d.runOrigin?.url), timestamp: d.timestamp, actor: d.actor, approver: str(d.approver), release_digest: str(d.releaseDigest), digest_kind: str(d.digestKind), promoted_from: json(d.promotedFrom), restores: json(d.restores), redeploys: json(d.redeploys) });
|
|
339
|
+
data.deploys.push({ member, env: d.env, component: d.component, digest: d.digest, git_sha: d.gitSha, run_id: d.runId, forge: str(d.runOrigin?.forge), run_url: str(d.runOrigin?.url), timestamp: d.timestamp, actor: d.actor, approver: str(d.approver), release_digest: str(d.releaseDigest), digest_kind: str(d.digestKind), promoted_from: json(d.promotedFrom), restores: json(d.restores), redeploys: json(d.redeploys), unchanged_since: json(d.unchangedSince) });
|
|
340
340
|
}
|
|
341
341
|
continue;
|
|
342
342
|
}
|
|
@@ -100,6 +100,24 @@ describe("a cut from a lane (#4692)", () => {
|
|
|
100
100
|
});
|
|
101
101
|
});
|
|
102
102
|
|
|
103
|
+
test("an image handed to a cut from a lane is recorded, and nothing is built (#4694)", async () => {
|
|
104
|
+
await withTestDir(async (dir) => {
|
|
105
|
+
const sha = workspace(dir);
|
|
106
|
+
git(dir, "tag", `ci/green-server/${sha}`, sha);
|
|
107
|
+
const images = { api: `registry.fly.io/api@sha256:${"c".repeat(64)}` };
|
|
108
|
+
const plan = await planRelease({ cwd: dir, compiler: compiler(), label: "v1.0.0", actor: "alice", env: {}, lane: "server", images });
|
|
109
|
+
expect(plan.build).toEqual([]);
|
|
110
|
+
expect(plan.handed.map((h) => h.ref)).toEqual([images.api]);
|
|
111
|
+
const result = await cutRelease({ cwd: dir, compiler: compiler(), label: "v1.0.0", actor: "alice", env: {}, now: NOW, lane: "server", images });
|
|
112
|
+
expect(result.cut?.lane).toBe("server");
|
|
113
|
+
expect(result.release.artifactDigests.map((a) => a.ref)).toEqual([images.api]);
|
|
114
|
+
expect(result.release.releaseDigest).toBe(plan.releaseDigest);
|
|
115
|
+
const doc = await releasesDocument({ cwd: dir });
|
|
116
|
+
if ("error" in doc) throw new Error(doc.error.message);
|
|
117
|
+
contract(releasesSchema).expectValid(doc);
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
|
|
103
121
|
test("a cut without a lane writes no lane, and a full green commit is cut as before", async () => {
|
|
104
122
|
await withTestDir(async (dir) => {
|
|
105
123
|
const sha = workspace(dir);
|
|
@@ -155,6 +155,18 @@ describe("a cut of a commit that is not green, under an override (#4693)", () =>
|
|
|
155
155
|
});
|
|
156
156
|
});
|
|
157
157
|
|
|
158
|
+
test("an image handed to the cut is recorded under an override, and nothing is built (#4694)", async () => {
|
|
159
|
+
await withTestDir(async (dir) => {
|
|
160
|
+
const sha = project(dir);
|
|
161
|
+
await refusal(cutRelease(request(dir, T0)));
|
|
162
|
+
await override(dir, sha, "github:alice");
|
|
163
|
+
const result = await cutRelease({ ...request(dir, T2), images: { api: `registry.fly.io/api@sha256:${"c".repeat(64)}` } });
|
|
164
|
+
expect(result.cut?.override?.by).toBe("github:alice");
|
|
165
|
+
expect(result.handed).toEqual([{ component: "api", ref: `registry.fly.io/api@sha256:${"c".repeat(64)}`, digest: `sha256:${"c".repeat(64)}` }]);
|
|
166
|
+
expect(result.release.artifactDigests).toEqual([{ component: "api", kind: "image", path: "", digest: `sha256:${"c".repeat(64)}`, ref: `registry.fly.io/api@sha256:${"c".repeat(64)}` }]);
|
|
167
|
+
});
|
|
168
|
+
});
|
|
169
|
+
|
|
158
170
|
test("an override counts only from a listed person, with a reason, and not from an agent", async () => {
|
|
159
171
|
await withTestDir(async (dir) => {
|
|
160
172
|
const sha = project(dir);
|
|
@@ -123,6 +123,14 @@ describe("the release digest", () => {
|
|
|
123
123
|
expect(computeReleaseDigest({ ...subject, targets: [{ ...t, templates: [{ ...t.templates[0], encoding: "base64" as const }] }] })).not.toBe(digest);
|
|
124
124
|
});
|
|
125
125
|
|
|
126
|
+
test("an artifact without a ref hashes as before #4694; a handed image's ref is in the digest", () => {
|
|
127
|
+
const digest = computeReleaseDigest(subject);
|
|
128
|
+
expect(computeReleaseDigest({ ...subject, artifactDigests: subject.artifactDigests.map((a) => ({ ...a, ref: undefined })) })).toBe(digest);
|
|
129
|
+
const handed = { ...subject, artifactDigests: [{ component: "api", kind: "image" as const, path: "", digest: "sha256:1", ref: "r.io/api@sha256:1" }] };
|
|
130
|
+
expect(computeReleaseDigest(handed)).not.toBe(computeReleaseDigest({ ...handed, artifactDigests: [{ ...handed.artifactDigests[0], ref: "r.io/other@sha256:1" }] }));
|
|
131
|
+
expect(makeRelease(handed).artifactDigests[0].ref).toBe("r.io/api@sha256:1");
|
|
132
|
+
});
|
|
133
|
+
|
|
126
134
|
test("verifyReleaseDigest catches a release whose content no longer matches its digest", () => {
|
|
127
135
|
const release = makeRelease(subject);
|
|
128
136
|
expect(verifyReleaseDigest(release)).toBe(true);
|
|
@@ -307,6 +315,43 @@ describe("cutRelease", () => {
|
|
|
307
315
|
});
|
|
308
316
|
});
|
|
309
317
|
|
|
318
|
+
test("an image handed to the cut is recorded by its reference, and the component is not built (#4694)", async () => {
|
|
319
|
+
await withTestDir(async (dir) => {
|
|
320
|
+
const sha = initRepo(dir);
|
|
321
|
+
green(dir, sha);
|
|
322
|
+
const ref = `registry.fly.io/api@sha256:${"b".repeat(64)}`;
|
|
323
|
+
const compiler = fixtureCompiler();
|
|
324
|
+
const plan = await planRelease({ cwd: dir, compiler: fixtureCompiler(), label: "v1", actor: "a", env: {}, images: { api: ref } });
|
|
325
|
+
expect(plan.build).toEqual([]);
|
|
326
|
+
expect(plan.handed).toEqual([{ component: "api", ref, digest: `sha256:${"b".repeat(64)}` }]);
|
|
327
|
+
|
|
328
|
+
const result = await cutRelease({ cwd: dir, compiler, label: "v1", actor: "a", env: {}, images: { api: ref } });
|
|
329
|
+
expect(compiler.built).toEqual([]);
|
|
330
|
+
expect(result.release.artifactDigests).toEqual([{ component: "api", kind: "image", path: "", digest: `sha256:${"b".repeat(64)}`, ref }]);
|
|
331
|
+
expect(plan.releaseDigest).toBe(result.release.releaseDigest);
|
|
332
|
+
expect(await readRelease(result.release.releaseDigest, { cwd: dir })).toEqual(result.release);
|
|
333
|
+
|
|
334
|
+
// The next cut hands another image; nothing is carried from the first.
|
|
335
|
+
const next = commitFile(dir, "flags.json", "{}\n");
|
|
336
|
+
green(dir, next);
|
|
337
|
+
const r2 = await cutRelease({ cwd: dir, compiler, label: "v2", actor: "a", env: {}, images: { api: `registry.fly.io/api@sha256:${"c".repeat(64)}` } });
|
|
338
|
+
expect(r2.reused).toEqual([]);
|
|
339
|
+
expect(r2.release.artifactDigests.map((a) => a.digest)).toEqual([`sha256:${"c".repeat(64)}`]);
|
|
340
|
+
});
|
|
341
|
+
});
|
|
342
|
+
|
|
343
|
+
test("refuses an image handed by tag, or for a component that isn't enabled (#4694)", async () => {
|
|
344
|
+
await withTestDir(async (dir) => {
|
|
345
|
+
const sha = initRepo(dir);
|
|
346
|
+
green(dir, sha);
|
|
347
|
+
const byTag = await planRelease({ cwd: dir, compiler: fixtureCompiler(), label: null, actor: "a", env: {}, images: { api: "registry.fly.io/api:latest" } }).catch((e: unknown) => e);
|
|
348
|
+
expect((byTag as ReleaseCutError).code).toBe("release-image-invalid");
|
|
349
|
+
const unknown = await planRelease({ cwd: dir, compiler: fixtureCompiler(), label: null, actor: "a", env: {}, images: { web: `r.io/web@sha256:${"b".repeat(64)}` } }).catch((e: unknown) => e);
|
|
350
|
+
expect((unknown as ReleaseCutError).code).toBe("release-image-unknown-component");
|
|
351
|
+
expect((unknown as ReleaseCutError).fix).toMatch(/api/);
|
|
352
|
+
});
|
|
353
|
+
});
|
|
354
|
+
|
|
310
355
|
test("refuses a member that declares no environments", async () => {
|
|
311
356
|
await withTestDir(async (dir) => {
|
|
312
357
|
const sha = initRepo(dir);
|
|
@@ -17,6 +17,14 @@
|
|
|
17
17
|
* component's own file, the member's `chant.config.ts` and the paths its
|
|
18
18
|
* build steps read.
|
|
19
19
|
*
|
|
20
|
+
* An image built elsewhere, as by a CI job that builds what the cut's machine
|
|
21
|
+
* can't, is handed to the cut by digest (#4694, `--image
|
|
22
|
+
* <component>=<repository>@sha256:<hex>`). The release records it with its
|
|
23
|
+
* reference in `ref`, and the cut builds nothing for that component: its
|
|
24
|
+
* archive steps, if it has any, don't run, and no earlier release's entry is
|
|
25
|
+
* carried. A deploy under the release runs that image
|
|
26
|
+
* (../components/release-run.ts).
|
|
27
|
+
*
|
|
20
28
|
* A project with no components (#4046) needs no special case here: its
|
|
21
29
|
* targets hold the files `chant build --env <env>` writes, each with
|
|
22
30
|
* `component: null`, and `artifactDigests` is empty.
|
|
@@ -74,12 +82,11 @@ import {
|
|
|
74
82
|
type TemplateContent,
|
|
75
83
|
} from "./release-store";
|
|
76
84
|
import type { CompiledTarget, TargetCompiler } from "../components/release-compile";
|
|
77
|
-
import { NEXT_RELEASE } from "../release-floors";
|
|
78
85
|
|
|
79
86
|
/** The first chant that cuts from a lane's green tag and writes `lane` on the cut line (#4692). */
|
|
80
|
-
export const RELEASE_CUT_LANE_FLOOR =
|
|
87
|
+
export const RELEASE_CUT_LANE_FLOOR = "0.124.64";
|
|
81
88
|
/** The first chant that cuts a commit that is not green under an override and writes `override` on the cut line (#4693). */
|
|
82
|
-
export const RELEASE_CUT_OVERRIDE_FLOOR =
|
|
89
|
+
export const RELEASE_CUT_OVERRIDE_FLOOR = "0.124.64";
|
|
83
90
|
|
|
84
91
|
/** The override gate's subject for a cut of `commit` (#4693): `release-<sha12>`. */
|
|
85
92
|
export function greenOverrideSubject(commit: string): string {
|
|
@@ -103,6 +110,8 @@ export type ReleaseCutCode =
|
|
|
103
110
|
| "release-no-environments"
|
|
104
111
|
| "release-no-components"
|
|
105
112
|
| "release-build-inputs-differ"
|
|
113
|
+
| "release-image-invalid"
|
|
114
|
+
| "release-image-unknown-component"
|
|
106
115
|
| "release-unsigned"
|
|
107
116
|
| "release-signer-refused"
|
|
108
117
|
| "declaration-invalid";
|
|
@@ -156,6 +165,12 @@ export interface CutRequest {
|
|
|
156
165
|
* refused, and a cut that is not a dry run records the request for one.
|
|
157
166
|
*/
|
|
158
167
|
overrideGreen?: boolean;
|
|
168
|
+
/**
|
|
169
|
+
* Images built elsewhere and handed to the cut (#4694), by component: each
|
|
170
|
+
* `<repository>@sha256:<hex>`. The release records each as the component's
|
|
171
|
+
* image, and the cut builds nothing for it.
|
|
172
|
+
*/
|
|
173
|
+
images?: Readonly<Record<string, string>>;
|
|
159
174
|
}
|
|
160
175
|
|
|
161
176
|
export interface CutResult {
|
|
@@ -168,6 +183,26 @@ export interface CutResult {
|
|
|
168
183
|
stored: boolean;
|
|
169
184
|
/** The components whose artifacts were taken from an earlier release, and that release's digest. */
|
|
170
185
|
reused: Array<{ component: string; from: string }>;
|
|
186
|
+
/** The images handed to the cut (#4694), by component, as recorded. */
|
|
187
|
+
handed: Array<{ component: string; ref: string; digest: string }>;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/** An image reference by digest: `<repository>@sha256:<64 hex>`, the repository without a tag. */
|
|
191
|
+
const IMAGE_BY_DIGEST = /^([a-z0-9]+(?:[._-][a-z0-9]+)*(?::[0-9]+)?(?:\/[a-z0-9]+(?:[._-]+[a-z0-9]+)*)*)@(sha256:[0-9a-f]{64})$/;
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* The release artifact for an image handed to the cut (#4694), or why the
|
|
195
|
+
* reference can't be one: it must name its repository and its digest, and no
|
|
196
|
+
* tag, since a tag can move after the cut.
|
|
197
|
+
*/
|
|
198
|
+
export function handedImage(component: string, ref: string): ReleaseArtifact | { error: string } {
|
|
199
|
+
const m = IMAGE_BY_DIGEST.exec(ref);
|
|
200
|
+
if (!m) {
|
|
201
|
+
return {
|
|
202
|
+
error: `--image ${component}=${ref}: an image is handed to the cut by digest, as <repository>@sha256:<64 hex digits> with no tag, such as registry.fly.io/app@sha256:${"0".repeat(64)}`,
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
return { component, kind: "image", path: "", digest: m[2]!, ref };
|
|
171
206
|
}
|
|
172
207
|
|
|
173
208
|
function git(top: string, args: string[]): string {
|
|
@@ -249,9 +284,10 @@ interface Prepared {
|
|
|
249
284
|
releaseRule: ReturnType<typeof import("../workspace/identity").releaseRuleFrom>;
|
|
250
285
|
/** The components to build, by the environment they are built in. */
|
|
251
286
|
toBuild: Map<string, string[]>;
|
|
252
|
-
/** The artifacts carried from an earlier release. */
|
|
287
|
+
/** The artifacts carried from an earlier release, and the images handed to the cut. */
|
|
253
288
|
carried: ReleaseArtifact[];
|
|
254
289
|
reused: CutResult["reused"];
|
|
290
|
+
handed: CutResult["handed"];
|
|
255
291
|
member: string | null;
|
|
256
292
|
/** The lane the commit was checked in, or null for the full green tag. */
|
|
257
293
|
lane: string | null;
|
|
@@ -447,15 +483,34 @@ async function prepare(req: CutRequest, record = false): Promise<Prepared> {
|
|
|
447
483
|
);
|
|
448
484
|
}
|
|
449
485
|
|
|
486
|
+
// #4694: an image handed to the cut is the component's, in place of a build.
|
|
487
|
+
const enabled = new Set(compiled.flatMap((t) => t.components));
|
|
488
|
+
const handedArtifacts: ReleaseArtifact[] = [];
|
|
489
|
+
for (const [component, ref] of Object.entries(req.images ?? {})) {
|
|
490
|
+
if (!enabled.has(component)) {
|
|
491
|
+
throw new ReleaseCutError(
|
|
492
|
+
"release-image-unknown-component",
|
|
493
|
+
`--image names "${component}", which is not a component enabled in any environment of this member`,
|
|
494
|
+
enabled.size > 0 ? `The components are: ${[...enabled].sort().join(", ")}` : undefined,
|
|
495
|
+
);
|
|
496
|
+
}
|
|
497
|
+
const artifact = handedImage(component, ref);
|
|
498
|
+
if ("error" in artifact) throw new ReleaseCutError("release-image-invalid", artifact.error);
|
|
499
|
+
handedArtifacts.push(artifact);
|
|
500
|
+
}
|
|
501
|
+
const handedTo = new Set(handedArtifacts.map((a) => a.component));
|
|
502
|
+
|
|
450
503
|
// Which environment each component's artifacts are built in: the first one it is enabled in.
|
|
451
504
|
const firstEnv = new Map<string, CompiledTarget>();
|
|
452
|
-
for (const t of compiled)
|
|
505
|
+
for (const t of compiled) {
|
|
506
|
+
for (const c of t.components) if (!firstEnv.has(c) && !handedTo.has(c) && (t.buildSteps[c]?.length ?? 0) > 0) firstEnv.set(c, t);
|
|
507
|
+
}
|
|
453
508
|
|
|
454
509
|
// git names paths from its top with symlinks resolved (/private/var on macOS).
|
|
455
510
|
const realCwd = realpathSync(cwd);
|
|
456
511
|
const previous = firstEnv.size > 0 ? await previousRelease(top, commit, cwd) : undefined;
|
|
457
512
|
const reused: CutResult["reused"] = [];
|
|
458
|
-
const artifacts: ReleaseArtifact[] = [];
|
|
513
|
+
const artifacts: ReleaseArtifact[] = [...handedArtifacts];
|
|
459
514
|
const toBuild = new Map<string, string[]>();
|
|
460
515
|
for (const [component, target] of firstEnv) {
|
|
461
516
|
const prior = previous?.artifactDigests.filter((a) => a.component === component) ?? [];
|
|
@@ -484,6 +539,7 @@ async function prepare(req: CutRequest, record = false): Promise<Prepared> {
|
|
|
484
539
|
toBuild,
|
|
485
540
|
carried: artifacts,
|
|
486
541
|
reused,
|
|
542
|
+
handed: handedArtifacts.map((a) => ({ component: a.component, ref: a.ref!, digest: a.digest })),
|
|
487
543
|
member: ledger.members.length > 0 ? ledger.members.join("/") : null,
|
|
488
544
|
lane,
|
|
489
545
|
override,
|
|
@@ -531,6 +587,8 @@ export interface CutPlan {
|
|
|
531
587
|
build: Array<{ component: string; env: string }>;
|
|
532
588
|
/** The components whose artifacts would be carried from an earlier release. */
|
|
533
589
|
reused: CutResult["reused"];
|
|
590
|
+
/** The images handed to the cut (#4694), by component. */
|
|
591
|
+
handed: CutResult["handed"];
|
|
534
592
|
/** Each component's publish steps, with the environments whose deploy runs them. */
|
|
535
593
|
publishSteps: Array<{ component: string; kind: string; to: string | null; envs: string[] }>;
|
|
536
594
|
/** Whether the release gate in identity.gates requires a signed cut. */
|
|
@@ -605,6 +663,7 @@ export async function planRelease(req: CutRequest): Promise<CutPlan> {
|
|
|
605
663
|
targets: targets.map((t) => ({ env: t.env, params: t.params, templates: t.templates.map(({ component, path }) => ({ component, path })), ...(t.trees ? { trees: t.trees } : {}) })),
|
|
606
664
|
build,
|
|
607
665
|
reused: p.reused,
|
|
666
|
+
handed: p.handed,
|
|
608
667
|
publishSteps: [...steps.values()],
|
|
609
668
|
signatureRequired: p.releaseRule.requirement !== null,
|
|
610
669
|
lane: p.lane,
|
|
@@ -628,7 +687,7 @@ export async function planRelease(req: CutRequest): Promise<CutPlan> {
|
|
|
628
687
|
*/
|
|
629
688
|
export async function cutRelease(req: CutRequest): Promise<CutResult> {
|
|
630
689
|
const p = await prepare(req, true);
|
|
631
|
-
const { cwd, commit, compiled, releaseRule, reused } = p;
|
|
690
|
+
const { cwd, commit, compiled, releaseRule, reused, handed } = p;
|
|
632
691
|
const artifacts = [...p.carried];
|
|
633
692
|
for (const env of p.envs) {
|
|
634
693
|
const names = p.toBuild.get(env);
|
|
@@ -697,5 +756,6 @@ export async function cutRelease(req: CutRequest): Promise<CutResult> {
|
|
|
697
756
|
label: outcome.appended ? outcome.cut.label : outcome.label,
|
|
698
757
|
stored: stored.written,
|
|
699
758
|
reused,
|
|
759
|
+
handed,
|
|
700
760
|
};
|
|
701
761
|
}
|
|
@@ -242,6 +242,17 @@ export interface ReleaseRecord {
|
|
|
242
242
|
* partway. Absent on every other record.
|
|
243
243
|
*/
|
|
244
244
|
redeploys?: ReleaseRef;
|
|
245
|
+
/**
|
|
246
|
+
* Optional: set when a release skipped this component (#4695) because the
|
|
247
|
+
* inputs it declares were the same as in the release the environment ran
|
|
248
|
+
* it from. Names that environment's record, whose `digest`, `gitSha`,
|
|
249
|
+
* `manifestDigest`, `digestKind` and `inputDigest` this record repeats:
|
|
250
|
+
* nothing was deployed, and the environment still runs that deploy, now
|
|
251
|
+
* under this record's `releaseDigest`. Written from chant
|
|
252
|
+
* `UNCHANGED_INPUTS_FLOOR` (../components/unchanged-inputs.ts); absent on
|
|
253
|
+
* every deploy.
|
|
254
|
+
*/
|
|
255
|
+
unchangedSince?: ReleaseRef;
|
|
245
256
|
/**
|
|
246
257
|
* Optional: the release this deploy came from (#4026, ws-104), the
|
|
247
258
|
* `releaseDigest` of `_releases/<releaseDigest>.json`. Written by
|