@intentius/chant 0.124.64 → 0.124.65

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (105) hide show
  1. package/dist/cli/handlers/release.d.ts.map +1 -1
  2. package/dist/cli/handlers/release.js +20 -2
  3. package/dist/cli/handlers/run.d.ts +30 -1
  4. package/dist/cli/handlers/run.d.ts.map +1 -1
  5. package/dist/cli/handlers/run.js +108 -7
  6. package/dist/cli/main.d.ts.map +1 -1
  7. package/dist/cli/main.js +17 -2
  8. package/dist/cli/parse-args.d.ts.map +1 -1
  9. package/dist/cli/parse-args.js +7 -0
  10. package/dist/cli/registry.d.ts +5 -1
  11. package/dist/cli/registry.d.ts.map +1 -1
  12. package/dist/components/cli-support.d.ts +19 -1
  13. package/dist/components/cli-support.d.ts.map +1 -1
  14. package/dist/components/cli-support.js +11 -3
  15. package/dist/components/component.d.ts +19 -0
  16. package/dist/components/component.d.ts.map +1 -1
  17. package/dist/components/component.schema.json +17 -0
  18. package/dist/components/index.d.ts +1 -1
  19. package/dist/components/index.d.ts.map +1 -1
  20. package/dist/components/release-run.d.ts +48 -0
  21. package/dist/components/release-run.d.ts.map +1 -0
  22. package/dist/components/release-run.js +166 -0
  23. package/dist/components/starter-plugin.d.ts +1 -0
  24. package/dist/components/starter-plugin.d.ts.map +1 -1
  25. package/dist/components/starter-plugin.js +5 -1
  26. package/dist/components/unchanged-inputs.d.ts +81 -0
  27. package/dist/components/unchanged-inputs.d.ts.map +1 -0
  28. package/dist/components/unchanged-inputs.js +122 -0
  29. package/dist/components/verbs/index.d.ts +1 -0
  30. package/dist/components/verbs/index.d.ts.map +1 -1
  31. package/dist/components/verbs/index.js +1 -0
  32. package/dist/components/verbs/release-image.d.ts +36 -0
  33. package/dist/components/verbs/release-image.d.ts.map +1 -0
  34. package/dist/components/verbs/release-image.js +33 -0
  35. package/dist/lifecycle/delivery-metrics.d.ts.map +1 -1
  36. package/dist/lifecycle/delivery-metrics.js +4 -2
  37. package/dist/lifecycle/gate-statement.d.ts.map +1 -1
  38. package/dist/lifecycle/gate-statement.js +1 -2
  39. package/dist/lifecycle/git.d.ts.map +1 -1
  40. package/dist/lifecycle/git.js +6 -1
  41. package/dist/lifecycle/ledger-read.js +1 -1
  42. package/dist/lifecycle/publish-homebrew.d.ts.map +1 -1
  43. package/dist/lifecycle/publish-homebrew.js +1 -2
  44. package/dist/lifecycle/publish-marketplace.d.ts.map +1 -1
  45. package/dist/lifecycle/publish-marketplace.js +2 -3
  46. package/dist/lifecycle/query.d.ts +2 -2
  47. package/dist/lifecycle/query.d.ts.map +1 -1
  48. package/dist/lifecycle/query.js +3 -3
  49. package/dist/lifecycle/release-cut.d.ts +32 -2
  50. package/dist/lifecycle/release-cut.d.ts.map +1 -1
  51. package/dist/lifecycle/release-cut.js +47 -7
  52. package/dist/lifecycle/release-ledger.d.ts +11 -0
  53. package/dist/lifecycle/release-ledger.d.ts.map +1 -1
  54. package/dist/lifecycle/release-store.d.ts +17 -3
  55. package/dist/lifecycle/release-store.d.ts.map +1 -1
  56. package/dist/lifecycle/release-store.js +11 -3
  57. package/dist/op/activities/activity-contracts.d.ts +4 -4
  58. package/dist/op/op-waves-run.js +5 -3
  59. package/dist/release-floors.d.ts +1 -1
  60. package/dist/release-floors.js +1 -1
  61. package/dist/wave-runtime.mjs +237 -237
  62. package/dist/workspace/delivery-metrics.schema.json +1 -1
  63. package/dist/workspace/release-candidates.d.ts.map +1 -1
  64. package/dist/workspace/release-candidates.js +1 -2
  65. package/dist/workspace/releases.schema.json +7 -2
  66. package/package.json +1 -1
  67. package/src/cli/handlers/release.ts +18 -2
  68. package/src/cli/handlers/run-unchanged.e2e.test.ts +112 -0
  69. package/src/cli/handlers/run.ts +117 -7
  70. package/src/cli/main.ts +17 -2
  71. package/src/cli/parse-args.ts +6 -0
  72. package/src/cli/registry.ts +5 -1
  73. package/src/components/cli-support.test.ts +53 -0
  74. package/src/components/cli-support.ts +26 -4
  75. package/src/components/component.schema.json +17 -0
  76. package/src/components/component.ts +20 -0
  77. package/src/components/index.ts +1 -0
  78. package/src/components/registry.test.ts +1 -1
  79. package/src/components/release-run.test.ts +127 -0
  80. package/src/components/release-run.ts +188 -0
  81. package/src/components/starter-plugin.ts +5 -0
  82. package/src/components/unchanged-inputs.test.ts +98 -0
  83. package/src/components/unchanged-inputs.ts +151 -0
  84. package/src/components/verbs/index.ts +1 -0
  85. package/src/components/verbs/release-image.ts +52 -0
  86. package/src/lifecycle/delivery-metrics.ts +4 -2
  87. package/src/lifecycle/gate-statement.ts +1 -2
  88. package/src/lifecycle/git.test.ts +15 -0
  89. package/src/lifecycle/git.ts +5 -1
  90. package/src/lifecycle/ledger-read.ts +1 -1
  91. package/src/lifecycle/publish-homebrew.ts +1 -2
  92. package/src/lifecycle/publish-marketplace.ts +2 -3
  93. package/src/lifecycle/query.ts +3 -3
  94. package/src/lifecycle/release-cut-lane.test.ts +18 -0
  95. package/src/lifecycle/release-cut-override.test.ts +12 -0
  96. package/src/lifecycle/release-cut.test.ts +45 -0
  97. package/src/lifecycle/release-cut.ts +67 -7
  98. package/src/lifecycle/release-ledger.ts +11 -0
  99. package/src/lifecycle/release-store.ts +29 -5
  100. package/src/op/op-waves-run.ts +4 -2
  101. package/src/release-floors.ts +1 -1
  102. package/src/workspace/delivery-metrics.schema.json +1 -1
  103. package/src/workspace/delivery-metrics.test.ts +8 -0
  104. package/src/workspace/release-candidates.ts +1 -2
  105. package/src/workspace/releases.schema.json +7 -2
@@ -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
@@ -55,6 +55,7 @@ import {
55
55
  type LedgerLocation,
56
56
  } from "./git";
57
57
  import type { RunOrigin } from "./release-ledger";
58
+ import { NEXT_RELEASE } from "../release-floors";
58
59
 
59
60
  /** The directory on `chant/lifecycle` that holds releases, cuts and template bytes. */
60
61
  export const RELEASES_DIR = "_releases";
@@ -66,15 +67,30 @@ export const TEMPLATES_SUBDIR = "templates";
66
67
  /** The `kind` a release digest is computed under, so it can never equal a plan digest of another kind. */
67
68
  export const RELEASE_DIGEST_KIND = "release";
68
69
 
69
- /** An artifact built once from the release's commit: an `image` or `asset` archive entry. */
70
+ /**
71
+ * An artifact built once from the release's commit: an `image` or `asset`
72
+ * archive entry the cut built, or an image built elsewhere and handed to the
73
+ * cut by digest (#4694, `chant release cut --image`).
74
+ */
70
75
  export interface ReleaseArtifact {
71
76
  component: string;
72
77
  kind: "image" | "asset";
73
- /** The archive path the build step wrote. */
78
+ /** The archive path the build step wrote. Empty for an image handed to the cut, which no build step wrote. */
74
79
  path: string;
75
80
  digest: string;
81
+ /**
82
+ * For an image handed to the cut (#4694): where it is, as
83
+ * `<repository>@<digest>`, the reference a deploy under the release runs.
84
+ * Absent on an artifact the cut built. In the release digest when present,
85
+ * so a release that records one is read by chant {@link RELEASE_IMAGE_REF_FLOOR}
86
+ * and newer.
87
+ */
88
+ ref?: string;
76
89
  }
77
90
 
91
+ /** The first chant that writes and reads an artifact's `ref` (#4694). */
92
+ export const RELEASE_IMAGE_REF_FLOOR = NEXT_RELEASE;
93
+
78
94
  /** One template of a target: a file a component's deploy reads, compiled for the target's environment. */
79
95
  export interface ReleaseTemplate {
80
96
  /** The component whose deploy reads it, or null for a project with no components. */
@@ -207,12 +223,12 @@ export type ReleaseSubject = Pick<Release, "member" | "commit" | "artifactDigest
207
223
 
208
224
  const byString = (a: string, b: string): number => (a < b ? -1 : a > b ? 1 : 0);
209
225
 
210
- /** The same release with every list in the order ws-104 sets: artifacts by component then path, targets by env, templates by component then path, params by name. */
226
+ /** The same release with every list in the order ws-104 sets: artifacts by component then path (a handed image's `ref` kept), targets by env, templates by component then path, params by name. */
211
227
  export function normalizeRelease<T extends ReleaseSubject>(release: T): T {
212
228
  return {
213
229
  ...release,
214
230
  artifactDigests: [...release.artifactDigests]
215
- .map(({ component, kind, path, digest }) => ({ component, kind, path, digest }))
231
+ .map(({ component, kind, path, digest, ref }) => ({ component, kind, path, digest, ...(ref !== undefined ? { ref } : {}) }))
216
232
  .sort((a, b) => byString(a.component, b.component) || byString(a.path, b.path)),
217
233
  targets: [...release.targets]
218
234
  .map((t) => ({
@@ -354,7 +370,15 @@ export function parseRelease(text: string): Release | null {
354
370
  (r.member === null || typeof r.member === "string") &&
355
371
  typeof r.commit === "string" &&
356
372
  Array.isArray(r.artifactDigests) &&
357
- r.artifactDigests.every((a) => a && typeof a.component === "string" && (a.kind === "image" || a.kind === "asset") && typeof a.path === "string" && typeof a.digest === "string") &&
373
+ r.artifactDigests.every(
374
+ (a) =>
375
+ a &&
376
+ typeof a.component === "string" &&
377
+ (a.kind === "image" || a.kind === "asset") &&
378
+ typeof a.path === "string" &&
379
+ typeof a.digest === "string" &&
380
+ (a.ref === undefined || typeof a.ref === "string"),
381
+ ) &&
358
382
  Array.isArray(r.targets) &&
359
383
  r.targets.every(
360
384
  (t) =>
@@ -4014,10 +4014,12 @@ async function storeHeadChangeSet(doc: ChangeSetDocument, cwd: string): Promise<
4014
4014
  }
4015
4015
 
4016
4016
  async function writeHeadPlans(plans: HeadPlans, cwd: string): Promise<void> {
4017
- const { pushLifecycle, requireLifecycleLedger, writeBlobToPath } = await import("../lifecycle/git");
4017
+ const { pushLifecycleRebasing, requireLifecycleLedger, writeBlobToPath } = await import("../lifecycle/git");
4018
4018
  const { headPlansPath } = await import("./gate-review");
4019
4019
  await requireLifecycleLedger({ cwd });
4020
4020
  const { dir, file } = headPlansPath(plans.name, plans.head);
4021
4021
  await writeBlobToPath(dir, file, JSON.stringify(plans, null, 2) + "\n", `Op waves plans of ${plans.name} at ${plans.head.slice(0, 12)}`, { cwd });
4022
- if (!(await pushLifecycle({ cwd }))) throw new Error("the plans were recorded locally only: chant/lifecycle has no remote to push to");
4022
+ // The preview, its note and the approval status write the ledger at the same head, so a lost race replays rather than fails the job a pull request's checks wait on.
4023
+ const pushed = await pushLifecycleRebasing({ cwd });
4024
+ if (!pushed.pushed) throw new Error(`the plans were recorded locally only: ${pushed.pushWarning ?? "chant/lifecycle has no remote to push to"}`);
4023
4025
  }
@@ -19,4 +19,4 @@
19
19
  * this constant to the next patch (#4501). The check fails while a floor
20
20
  * still names this constant after its version shipped.
21
21
  */
22
- export const NEXT_RELEASE = "0.124.64";
22
+ export const NEXT_RELEASE = "0.124.65";
@@ -191,7 +191,7 @@
191
191
  "count": {
192
192
  "type": "integer",
193
193
  "minimum": 0,
194
- "description": "Deploy records whose timestamp is in the window, leaving out redeploys. Rollbacks count."
194
+ "description": "Deploy records whose timestamp is in the window, leaving out redeploys. Rollbacks count. A record with unchangedSince (#4695) deployed nothing and is in no metric."
195
195
  },
196
196
  "redeploys": {
197
197
  "type": "integer",
@@ -229,6 +229,14 @@ describe("environmentMetrics", () => {
229
229
  expect(m.leadTime.changes).toBe(0);
230
230
  });
231
231
 
232
+ test("a record of a skipped component deployed nothing and is in no metric (#4695)", () => {
233
+ const deploy = record("hub", "06");
234
+ const skip = record("hub", "08", { releaseDigest: "jcs1-sha256:r2", unchangedSince: { env: "prod", runId: deploy.runId, timestamp: deploy.timestamp } });
235
+ const m = environmentMetrics("prod", [deploy, skip], lookups, { since: t("05"), until: NOW });
236
+ expect(m.deployments.count).toBe(1);
237
+ expect(m.deployments.runs).toBe(1);
238
+ });
239
+
232
240
  test("a rollback is a record with restores; nothing else is", () => {
233
241
  expect(rollbackOf(record("api", "01"))).toBeNull();
234
242
  expect(rollbackOf(record("api", "02", { restores: { env: "prod", runId: "x", timestamp: t("01") } }))).toEqual({ env: "prod", runId: "x", timestamp: t("01") });
@@ -44,7 +44,6 @@
44
44
 
45
45
  import { execFileSync } from "node:child_process";
46
46
  import { relative, resolve, sep } from "node:path";
47
- import { NEXT_RELEASE } from "../release-floors";
48
47
  import { latestPerComponent, readReleaseLedger } from "../lifecycle/release-ledger";
49
48
  import { readAllReleases, readCuts } from "../lifecycle/release-store";
50
49
  import { resolveMemberLedger } from "../lifecycle/member-ledger";
@@ -56,7 +55,7 @@ export const RELEASE_CANDIDATES_CONTRACT_VERSION = 1;
56
55
  /** The first chant whose candidates carry `changes[].closes` and `groups[].issue` (#4649). */
57
56
  export const RELEASE_CANDIDATES_CLOSES_FLOOR = "0.124.63";
58
57
  /** The first chant whose candidates document carries `lane` and reads a lane's tags (#4692). */
59
- export const RELEASE_CANDIDATES_LANE_FLOOR = NEXT_RELEASE;
58
+ export const RELEASE_CANDIDATES_LANE_FLOOR = "0.124.64";
60
59
  export const RELEASE_CANDIDATES_SCHEMA_ID = "https://intentius.io/chant/schemas/workspace/release-candidates/v1/release-candidates.schema.json";
61
60
 
62
61
  /** Why the read stopped. Closed; each code is in `reason-codes.ts`. */
@@ -113,7 +113,7 @@
113
113
  },
114
114
  "artifactDigests": {
115
115
  "type": "array",
116
- "description": "Each image and asset built once from the commit, sorted by component, then path. A config-only release carries the previous release's entries.",
116
+ "description": "Each image and asset built once from the commit, or handed to the cut by digest, sorted by component, then path. A config-only release carries the previous release's entries.",
117
117
  "items": {
118
118
  "type": "object",
119
119
  "required": [
@@ -133,11 +133,16 @@
133
133
  ]
134
134
  },
135
135
  "path": {
136
- "type": "string"
136
+ "type": "string",
137
+ "description": "The archive path the build step wrote. Empty for an image handed to the cut."
137
138
  },
138
139
  "digest": {
139
140
  "type": "string",
140
141
  "minLength": 1
142
+ },
143
+ "ref": {
144
+ "type": "string",
145
+ "description": "An image handed to the cut by digest (chant release cut --image, #4694), as <repository>@<digest>: the image a deploy under the release runs. Absent on an artifact the cut built. Written by chant 0.124.65 and newer."
141
146
  }
142
147
  }
143
148
  }