@intentius/chant 0.124.63 → 0.124.65

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (185) hide show
  1. package/dist/cli/handlers/approve.d.ts +8 -0
  2. package/dist/cli/handlers/approve.d.ts.map +1 -1
  3. package/dist/cli/handlers/approve.js +27 -4
  4. package/dist/cli/handlers/pr.d.ts.map +1 -1
  5. package/dist/cli/handlers/pr.js +2 -1
  6. package/dist/cli/handlers/release.d.ts +6 -4
  7. package/dist/cli/handlers/release.d.ts.map +1 -1
  8. package/dist/cli/handlers/release.js +101 -16
  9. package/dist/cli/handlers/run.d.ts +30 -1
  10. package/dist/cli/handlers/run.d.ts.map +1 -1
  11. package/dist/cli/handlers/run.js +108 -7
  12. package/dist/cli/main.d.ts.map +1 -1
  13. package/dist/cli/main.js +34 -7
  14. package/dist/cli/parse-args.d.ts.map +1 -1
  15. package/dist/cli/parse-args.js +19 -0
  16. package/dist/cli/registry.d.ts +10 -2
  17. package/dist/cli/registry.d.ts.map +1 -1
  18. package/dist/components/cli-support.d.ts +19 -1
  19. package/dist/components/cli-support.d.ts.map +1 -1
  20. package/dist/components/cli-support.js +11 -3
  21. package/dist/components/component.d.ts +19 -0
  22. package/dist/components/component.d.ts.map +1 -1
  23. package/dist/components/component.schema.json +17 -0
  24. package/dist/components/index.d.ts +1 -1
  25. package/dist/components/index.d.ts.map +1 -1
  26. package/dist/components/release-run.d.ts +48 -0
  27. package/dist/components/release-run.d.ts.map +1 -0
  28. package/dist/components/release-run.js +166 -0
  29. package/dist/components/starter-plugin.d.ts +1 -0
  30. package/dist/components/starter-plugin.d.ts.map +1 -1
  31. package/dist/components/starter-plugin.js +5 -1
  32. package/dist/components/unchanged-inputs.d.ts +81 -0
  33. package/dist/components/unchanged-inputs.d.ts.map +1 -0
  34. package/dist/components/unchanged-inputs.js +122 -0
  35. package/dist/components/verbs/index.d.ts +1 -0
  36. package/dist/components/verbs/index.d.ts.map +1 -1
  37. package/dist/components/verbs/index.js +1 -0
  38. package/dist/components/verbs/release-image.d.ts +36 -0
  39. package/dist/components/verbs/release-image.d.ts.map +1 -0
  40. package/dist/components/verbs/release-image.js +33 -0
  41. package/dist/config.d.ts +18 -0
  42. package/dist/config.d.ts.map +1 -1
  43. package/dist/config.js +1 -0
  44. package/dist/gate-statement.schema.json +4 -2
  45. package/dist/lifecycle/delivery-metrics.d.ts.map +1 -1
  46. package/dist/lifecycle/delivery-metrics.js +4 -2
  47. package/dist/lifecycle/gate-ledger.d.ts +11 -2
  48. package/dist/lifecycle/gate-ledger.d.ts.map +1 -1
  49. package/dist/lifecycle/gate-ledger.js +6 -0
  50. package/dist/lifecycle/gate-seal.d.ts +20 -4
  51. package/dist/lifecycle/gate-seal.d.ts.map +1 -1
  52. package/dist/lifecycle/gate-seal.js +18 -5
  53. package/dist/lifecycle/gate-statement.d.ts +27 -2
  54. package/dist/lifecycle/gate-statement.d.ts.map +1 -1
  55. package/dist/lifecycle/gate-statement.js +37 -2
  56. package/dist/lifecycle/git.d.ts.map +1 -1
  57. package/dist/lifecycle/git.js +6 -1
  58. package/dist/lifecycle/ledger-read.js +1 -1
  59. package/dist/lifecycle/plan-stale.d.ts.map +1 -1
  60. package/dist/lifecycle/plan-stale.js +1 -2
  61. package/dist/lifecycle/publish-declaration.d.ts +20 -0
  62. package/dist/lifecycle/publish-declaration.d.ts.map +1 -1
  63. package/dist/lifecycle/publish-declaration.js +24 -1
  64. package/dist/lifecycle/publish-forge.d.ts.map +1 -1
  65. package/dist/lifecycle/publish-forge.js +1 -2
  66. package/dist/lifecycle/publish-git-ssh.d.ts +82 -0
  67. package/dist/lifecycle/publish-git-ssh.d.ts.map +1 -0
  68. package/dist/lifecycle/publish-git-ssh.js +180 -0
  69. package/dist/lifecycle/publish-homebrew.d.ts +11 -0
  70. package/dist/lifecycle/publish-homebrew.d.ts.map +1 -1
  71. package/dist/lifecycle/publish-homebrew.js +96 -5
  72. package/dist/lifecycle/publish-marketplace.d.ts +36 -2
  73. package/dist/lifecycle/publish-marketplace.d.ts.map +1 -1
  74. package/dist/lifecycle/publish-marketplace.js +173 -30
  75. package/dist/lifecycle/publish-tauri.d.ts.map +1 -1
  76. package/dist/lifecycle/publish-tauri.js +1 -2
  77. package/dist/lifecycle/query.d.ts +2 -2
  78. package/dist/lifecycle/query.d.ts.map +1 -1
  79. package/dist/lifecycle/query.js +3 -3
  80. package/dist/lifecycle/release-cut.d.ts +82 -6
  81. package/dist/lifecycle/release-cut.d.ts.map +1 -1
  82. package/dist/lifecycle/release-cut.js +209 -20
  83. package/dist/lifecycle/release-ledger.d.ts +11 -0
  84. package/dist/lifecycle/release-ledger.d.ts.map +1 -1
  85. package/dist/lifecycle/release-publish.d.ts +13 -0
  86. package/dist/lifecycle/release-publish.d.ts.map +1 -1
  87. package/dist/lifecycle/release-publish.js +5 -0
  88. package/dist/lifecycle/release-revocation.d.ts +4 -3
  89. package/dist/lifecycle/release-revocation.d.ts.map +1 -1
  90. package/dist/lifecycle/release-revocation.js +5 -4
  91. package/dist/lifecycle/release-store.d.ts +49 -3
  92. package/dist/lifecycle/release-store.d.ts.map +1 -1
  93. package/dist/lifecycle/release-store.js +22 -3
  94. package/dist/op/gate.d.ts +1 -1
  95. package/dist/op/gate.d.ts.map +1 -1
  96. package/dist/op/gate.js +2 -1
  97. package/dist/op/op-waves-run.js +5 -3
  98. package/dist/pr-forge.d.ts.map +1 -1
  99. package/dist/pr-forge.js +26 -6
  100. package/dist/release-floors.d.ts +1 -1
  101. package/dist/release-floors.js +1 -1
  102. package/dist/wave-runtime.mjs +284 -283
  103. package/dist/workspace/ci-green.d.ts.map +1 -1
  104. package/dist/workspace/ci-green.js +1 -2
  105. package/dist/workspace/ci-quarantine-report.d.ts.map +1 -1
  106. package/dist/workspace/ci-quarantine-report.js +1 -2
  107. package/dist/workspace/ci-quarantine.d.ts.map +1 -1
  108. package/dist/workspace/ci-quarantine.js +1 -2
  109. package/dist/workspace/delivery-metrics.schema.json +1 -1
  110. package/dist/workspace/intent.d.ts.map +1 -1
  111. package/dist/workspace/intent.js +1 -2
  112. package/dist/workspace/release-candidates.d.ts +9 -1
  113. package/dist/workspace/release-candidates.d.ts.map +1 -1
  114. package/dist/workspace/release-candidates.js +16 -5
  115. package/dist/workspace/release-candidates.schema.json +7 -0
  116. package/dist/workspace/releases.schema.json +54 -2
  117. package/package.json +1 -1
  118. package/src/cli/handlers/approve-external-signature.test.ts +105 -3
  119. package/src/cli/handlers/approve.ts +34 -4
  120. package/src/cli/handlers/pr.ts +2 -1
  121. package/src/cli/handlers/release.ts +91 -16
  122. package/src/cli/handlers/run-unchanged.e2e.test.ts +112 -0
  123. package/src/cli/handlers/run.ts +117 -7
  124. package/src/cli/main.ts +34 -7
  125. package/src/cli/parse-args.ts +15 -0
  126. package/src/cli/registry.ts +10 -2
  127. package/src/components/cli-support.test.ts +53 -0
  128. package/src/components/cli-support.ts +26 -4
  129. package/src/components/component.schema.json +17 -0
  130. package/src/components/component.ts +20 -0
  131. package/src/components/index.ts +1 -0
  132. package/src/components/registry.test.ts +1 -1
  133. package/src/components/release-run.test.ts +127 -0
  134. package/src/components/release-run.ts +188 -0
  135. package/src/components/starter-plugin.ts +5 -0
  136. package/src/components/unchanged-inputs.test.ts +98 -0
  137. package/src/components/unchanged-inputs.ts +151 -0
  138. package/src/components/verbs/index.ts +1 -0
  139. package/src/components/verbs/release-image.ts +52 -0
  140. package/src/config.ts +8 -0
  141. package/src/gate-statement.schema.json +4 -2
  142. package/src/lifecycle/delivery-metrics.ts +4 -2
  143. package/src/lifecycle/gate-ledger.ts +17 -2
  144. package/src/lifecycle/gate-seal.ts +24 -6
  145. package/src/lifecycle/gate-statement.ts +40 -4
  146. package/src/lifecycle/git.test.ts +15 -0
  147. package/src/lifecycle/git.ts +5 -1
  148. package/src/lifecycle/ledger-read.ts +1 -1
  149. package/src/lifecycle/plan-stale.test.ts +3 -4
  150. package/src/lifecycle/plan-stale.ts +1 -2
  151. package/src/lifecycle/publish-declaration.ts +24 -1
  152. package/src/lifecycle/publish-forge.ts +1 -2
  153. package/src/lifecycle/publish-git-ssh.ts +202 -0
  154. package/src/lifecycle/publish-homebrew.test.ts +181 -2
  155. package/src/lifecycle/publish-homebrew.ts +101 -6
  156. package/src/lifecycle/publish-marketplace.test.ts +158 -6
  157. package/src/lifecycle/publish-marketplace.ts +192 -31
  158. package/src/lifecycle/publish-resume.test.ts +40 -0
  159. package/src/lifecycle/publish-tauri.ts +1 -2
  160. package/src/lifecycle/query.ts +3 -3
  161. package/src/lifecycle/release-cut-lane.test.ts +195 -0
  162. package/src/lifecycle/release-cut-override.test.ts +225 -0
  163. package/src/lifecycle/release-cut.test.ts +45 -0
  164. package/src/lifecycle/release-cut.ts +262 -21
  165. package/src/lifecycle/release-ledger.ts +11 -0
  166. package/src/lifecycle/release-publish.ts +18 -0
  167. package/src/lifecycle/release-revocation.ts +5 -4
  168. package/src/lifecycle/release-store.ts +73 -5
  169. package/src/op/gate.ts +2 -1
  170. package/src/op/op-waves-run.ts +4 -2
  171. package/src/pr-forge.ts +25 -6
  172. package/src/pr-requires.test.ts +9 -0
  173. package/src/release-floors.ts +1 -1
  174. package/src/workspace/ci-green.ts +1 -2
  175. package/src/workspace/ci-quarantine-report.test.ts +2 -3
  176. package/src/workspace/ci-quarantine-report.ts +1 -2
  177. package/src/workspace/ci-quarantine.test.ts +2 -3
  178. package/src/workspace/ci-quarantine.ts +1 -2
  179. package/src/workspace/delivery-metrics.schema.json +1 -1
  180. package/src/workspace/delivery-metrics.test.ts +8 -0
  181. package/src/workspace/intent.ts +1 -2
  182. package/src/workspace/release-candidates.schema.json +7 -0
  183. package/src/workspace/release-candidates.ts +19 -5
  184. package/src/workspace/releases.schema.json +54 -2
  185. package/src/workspace/trust/gate-seal.test.ts +44 -0
@@ -30,6 +30,31 @@
30
30
  *
31
31
  * The token is read from `tokenEnv`, else `VSCE_PAT` or `OVSX_PAT`, the
32
32
  * variables `vsce` and `ovsx` read, and is masked in all output.
33
+ *
34
+ * Or the target authenticates with the run's identity, with no stored
35
+ * token (#4698):
36
+ *
37
+ * - `auth: "azure-credential"` (VS Code Marketplace): `vsce` runs with
38
+ * `--azure-credential`, which gets a Microsoft Entra token from the job's
39
+ * Azure sign-in, such as the one `azure/login` makes from the run's OIDC
40
+ * token. `VSCE_PAT` is taken out of vsce's environment, since vsce prefers
41
+ * a PAT it finds there. The stage runs
42
+ * `vsce verify-pat --azure-credential <publisher>`, which signs in and asks
43
+ * the marketplace for the identity's role on the publisher, and changes
44
+ * nothing.
45
+ * - `auth: "trusted-publishing"` (Open VSX): the run's OIDC ID token, from
46
+ * GitHub Actions (a job with `id-token: write`) or from `OVSX_ID_TOKEN`, is
47
+ * exchanged at `POST {registry}/api/-/trusted-publishing/token` for a
48
+ * publishing token that lasts minutes, as `ovsx publish --trusted-publishing`
49
+ * does. The stage makes the exchange to check that Open VSX takes this
50
+ * workflow as a trusted publisher of the extension, and drops the token;
51
+ * the reveal exchanges again for the upload.
52
+ *
53
+ * With `onRefusal: "warn"`, a marketplace that refuses the reveal's upload,
54
+ * or a request around it, is a warning: the reveal returns the target with
55
+ * its items `refused` and a `warning`, and the publish goes on. Every check
56
+ * the stage makes still refuses, and so does a digest that differs after an
57
+ * upload.
33
58
  */
34
59
 
35
60
  import { spawn } from "node:child_process";
@@ -38,20 +63,61 @@ import { inflateRawSync } from "node:zlib";
38
63
  import { readCredential, type Credential } from "./publish-credentials";
39
64
  import type { MarketplacePublishDeclaration } from "./publish-declaration";
40
65
  import { bytesDigest, checkReleaseDigest, memberFile, publishTargetKey } from "./publish-targets";
41
- import { PublishTargetError, type PublishContext, type PublishDeps, type PublishFetch, type PublishItem, type PublishTarget, type StagedTarget } from "./release-publish";
42
- import { NEXT_RELEASE } from "../release-floors";
66
+ import {
67
+ PublishTargetError,
68
+ type PublishContext,
69
+ type PublishDeps,
70
+ type PublishedTarget,
71
+ type PublishFetch,
72
+ type PublishItem,
73
+ type PublishTarget,
74
+ type StagedTarget,
75
+ } from "./release-publish";
43
76
 
44
77
  /** The first chant that publishes a `marketplace` target (#4676). */
45
- export const PUBLISH_MARKETPLACE_FLOOR = NEXT_RELEASE;
78
+ export const PUBLISH_MARKETPLACE_FLOOR = "0.124.63";
79
+
80
+ /** The first chant that reads a marketplace target's `auth` (#4698). */
81
+ export const PUBLISH_MARKETPLACE_AUTH_FLOOR = "0.124.64";
82
+
83
+ /** The first chant that reads a marketplace target's `onRefusal` (#4698). */
84
+ export const PUBLISH_MARKETPLACE_ON_REFUSAL_FLOOR = "0.124.64";
46
85
 
47
86
  export const OPEN_VSX_REGISTRY = "https://open-vsx.org";
48
87
  export const VSCODE_GALLERY = "https://marketplace.visualstudio.com";
49
88
 
50
- /** The variables a marketplace's token is read from. */
51
- export function marketplaceTokenEnv(decl: Pick<MarketplacePublishDeclaration, "marketplace" | "tokenEnv">): string[] {
89
+ /** The variable an OIDC ID token for Open VSX is read from outside GitHub Actions, as `ovsx` reads it. */
90
+ export const OVSX_ID_TOKEN_ENV = "OVSX_ID_TOKEN";
91
+
92
+ export type MarketplaceAuth = NonNullable<MarketplacePublishDeclaration["auth"]>;
93
+
94
+ /** The declaration's `auth`, refused when the marketplace does not take it or when `tokenEnv` is set with another. */
95
+ export function marketplaceAuth(decl: Pick<MarketplacePublishDeclaration, "marketplace" | "auth" | "tokenEnv">): MarketplaceAuth {
96
+ const auth = decl.auth ?? "token";
97
+ const wrong =
98
+ auth === "azure-credential" && decl.marketplace !== "vscode"
99
+ ? "auth: azure-credential is the VS Code Marketplace's; Open VSX takes token or trusted-publishing"
100
+ : auth === "trusted-publishing" && decl.marketplace !== "openvsx"
101
+ ? "auth: trusted-publishing is Open VSX's; the VS Code Marketplace takes token or azure-credential"
102
+ : auth !== "token" && decl.tokenEnv !== undefined
103
+ ? `tokenEnv names a token, and auth: ${auth} reads none`
104
+ : null;
105
+ if (wrong) throw new PublishTargetError("publish-marketplace-auth-invalid", `a marketplace target for ${decl.marketplace}: ${wrong}`, "Fix the target in release.publish in chant.config.ts.");
106
+ return auth;
107
+ }
108
+
109
+ /** The variables a marketplace's credential is read from, whose values are masked. */
110
+ export function marketplaceTokenEnv(decl: Pick<MarketplacePublishDeclaration, "marketplace" | "tokenEnv" | "auth">): string[] {
111
+ const auth = decl.auth ?? "token";
112
+ // vsce's Entra sign-in reads a client secret from AZURE_CLIENT_SECRET when one is set; chant reads none.
113
+ if (auth === "azure-credential") return ["AZURE_CLIENT_SECRET"];
114
+ if (auth === "trusted-publishing") return [OVSX_ID_TOKEN_ENV];
52
115
  return [decl.tokenEnv ?? (decl.marketplace === "vscode" ? "VSCE_PAT" : "OVSX_PAT")];
53
116
  }
54
117
 
118
+ /** The codes a reveal turns into a warning under `onRefusal: "warn"`: the marketplace refused or failed a request. */
119
+ const REFUSALS = new Set(["publish-marketplace-failed", "publish-marketplace-trusted-publishing"]);
120
+
55
121
  /** One file of a zip archive, or null when it holds none by that name. Reads stored and deflated entries; refuses a zip64 archive. */
56
122
  export function readZipEntry(zip: Buffer, name: string): Buffer | null {
57
123
  let end = -1;
@@ -119,6 +185,7 @@ function run(bin: string, args: string[], ctx: PublishContext, env: NodeJS.Proce
119
185
 
120
186
  export function marketplaceTarget(decl: MarketplacePublishDeclaration, deps: PublishDeps): PublishTarget {
121
187
  const fetchImpl: PublishFetch = deps.fetch ?? ((url, init) => fetch(url, init as RequestInit));
188
+ const auth = marketplaceAuth(decl);
122
189
  const tokenNames = marketplaceTokenEnv(decl);
123
190
  const label = decl.marketplace === "vscode" ? "VS Code Marketplace" : "Open VSX";
124
191
  const registry = (decl.registry ?? (decl.marketplace === "vscode" ? VSCODE_GALLERY : OPEN_VSX_REGISTRY)).replace(/\/+$/, "");
@@ -129,9 +196,19 @@ export function marketplaceTarget(decl: MarketplacePublishDeclaration, deps: Pub
129
196
  const digest = bytesDigest(new Uint8Array(bytes));
130
197
  checkReleaseDigest(ctx.release, "asset", ctx.cwd, decl.vsix, [digest]);
131
198
  const id = vsixIdentity(bytes, decl.vsix);
132
- const token = readCredential(ctx.env, tokenNames, ctx.redactor);
133
- if (!token) {
134
- throw new PublishTargetError("publish-credentials-missing", `the ${label} target reads its token from ${tokenNames[0]}, and it is not set`, `Set ${tokenNames[0]} in the job's or the shell's environment.`);
199
+ let token: Credential | null = null;
200
+ if (auth === "token") {
201
+ token = readCredential(ctx.env, tokenNames, ctx.redactor);
202
+ if (!token) {
203
+ throw new PublishTargetError("publish-credentials-missing", `the ${label} target reads its token from ${tokenNames[0]}, and it is not set`, `Set ${tokenNames[0]} in the job's or the shell's environment.`);
204
+ }
205
+ }
206
+ if (auth === "trusted-publishing" && !ctx.env[OVSX_ID_TOKEN_ENV] && !(ctx.env.ACTIONS_ID_TOKEN_REQUEST_URL && ctx.env.ACTIONS_ID_TOKEN_REQUEST_TOKEN)) {
207
+ throw new PublishTargetError(
208
+ "publish-credentials-missing",
209
+ `the Open VSX target publishes with trusted publishing, and this run has no OIDC ID token: not a GitHub Actions job with id-token: write, and ${OVSX_ID_TOKEN_ENV} is not set`,
210
+ `In GitHub Actions, give the job permissions: id-token: write. Elsewhere, put an ID token whose audience is ${registry} in ${OVSX_ID_TOKEN_ENV}.`,
211
+ );
135
212
  }
136
213
  const destination =
137
214
  decl.marketplace === "vscode" ? `${registry}/items?itemName=${id.publisher}.${id.name}` : `${registry}/extension/${id.publisher}/${id.name}/${id.version}`;
@@ -160,6 +237,64 @@ export function marketplaceTarget(decl: MarketplacePublishDeclaration, deps: Pub
160
237
  return bytesDigest(new Uint8Array(await res.arrayBuffer()));
161
238
  };
162
239
 
240
+ /** The run's OIDC ID token for Open VSX: `OVSX_ID_TOKEN`, else one GitHub Actions issues with the registry as its audience. */
241
+ const idToken = async (ctx: PublishContext): Promise<string> => {
242
+ const direct = readCredential(ctx.env, [OVSX_ID_TOKEN_ENV], ctx.redactor);
243
+ if (direct) return direct.value;
244
+ const url = new URL(ctx.env.ACTIONS_ID_TOKEN_REQUEST_URL ?? "");
245
+ url.searchParams.set("audience", registry);
246
+ const res = await fetchImpl(url.toString(), { method: "GET", headers: { authorization: `Bearer ${ctx.env.ACTIONS_ID_TOKEN_REQUEST_TOKEN ?? ""}`, accept: "application/json" } });
247
+ const text = await res.text().catch(() => "");
248
+ const value = res.status === 200 ? (JSON.parse(text) as { value?: unknown }).value : undefined;
249
+ if (typeof value !== "string" || !value) {
250
+ throw new PublishTargetError("publish-marketplace-trusted-publishing", ctx.redactor.redact(`GitHub Actions gave no OIDC ID token for ${registry}: it answered ${res.status}`), "Give the job permissions: id-token: write.");
251
+ }
252
+ ctx.redactor.add(value);
253
+ return value;
254
+ };
255
+
256
+ /** Open VSX trusted publishing: a publishing token for the extension, exchanged for the run's ID token. It lasts minutes. */
257
+ const trustedToken = async (ctx: PublishContext, id: { publisher: string; name: string }): Promise<string> => {
258
+ const token = await idToken(ctx);
259
+ const res = await get(`${registry}/api/-/trusted-publishing/token`, {
260
+ method: "POST",
261
+ headers: { "content-type": "application/json" },
262
+ body: JSON.stringify({ namespace: id.publisher, extension: id.name, token }),
263
+ });
264
+ let body: { value?: unknown; error?: unknown } = {};
265
+ try {
266
+ body = JSON.parse(res.text) as typeof body;
267
+ } catch {
268
+ // An answer that is not JSON is reported by its status.
269
+ }
270
+ if (res.status < 200 || res.status > 299 || typeof body.value !== "string" || !body.value) {
271
+ const why = typeof body.error === "string" ? body.error : `it answered ${res.status}${res.text ? `: ${res.text.slice(0, 300)}` : ""}`;
272
+ throw new PublishTargetError(
273
+ "publish-marketplace-trusted-publishing",
274
+ ctx.redactor.redact(`Open VSX at ${registry} gave no trusted-publishing token for ${id.publisher}.${id.name}: ${why}`),
275
+ `Register this workflow as a trusted publisher of ${id.publisher}.${id.name} at ${registry}/user-settings/trusted-publishers.`,
276
+ );
277
+ }
278
+ ctx.redactor.add(body.value);
279
+ return body.value;
280
+ };
281
+
282
+ /** Runs vsce with the target's credential: `VSCE_PAT` for a token, `--azure-credential` and no `VSCE_PAT` for an Entra identity. */
283
+ const vsce = async (ctx: PublishContext, args: string[], token: Credential | null) => {
284
+ const env = { ...ctx.env };
285
+ if (token) env.VSCE_PAT = token.value;
286
+ else delete env.VSCE_PAT;
287
+ return run(deps.vsce ?? "vsce", token ? args : [...args, "--azure-credential"], ctx, env).catch((err: unknown) => {
288
+ throw new PublishTargetError("publish-marketplace-vsce-missing", `vsce could not be run: ${err instanceof Error ? err.message : String(err)}`, "Install it on the job's PATH: npm install -g @vscode/vsce");
289
+ });
290
+ };
291
+
292
+ /** The reveal of a target the marketplace refused, under `onRefusal: "warn"`. */
293
+ const refusedResult = (ctx: PublishContext, items: PublishItem[], err: PublishTargetError): PublishedTarget => {
294
+ const warning = ctx.redactor.redact(`${label} refused ${items[0]?.name ?? decl.vsix}: ${err.message}. onRefusal is warn, so the publish goes on without it, and the same publish run again tries it again`);
295
+ return { target: target.name, destination: target.destination, items: items.map((i) => ({ ...i, refused: true })), warning };
296
+ };
297
+
163
298
  /** VS Code Marketplace: whether the gallery lists the version. */
164
299
  const galleryHas = async (ctx: PublishContext, id: { publisher: string; name: string; version: string }): Promise<boolean> => {
165
300
  const res = await get(`${registry}/_apis/public/gallery/extensionquery`, {
@@ -183,9 +318,13 @@ export function marketplaceTarget(decl: MarketplacePublishDeclaration, deps: Pub
183
318
  },
184
319
  async stage(ctx) {
185
320
  const { id, digest, token, item } = setup(ctx);
186
- ctx.log(`using the token from ${token.from}`);
321
+ if (token) ctx.log(`using the token from ${token.from}`);
187
322
  const done = (present: boolean): StagedTarget => ({ target: target.name, destination: target.destination, items: [{ ...item, ...(present ? { present: true } : {}) }], state: present ? { present: "true" } : {} });
188
323
  if (decl.marketplace === "openvsx") {
324
+ if (auth === "trusted-publishing") {
325
+ await trustedToken(ctx, id);
326
+ ctx.log(`Open VSX takes this run as a trusted publisher of ${id.publisher}.${id.name}; the reveal asks for a new token, since one lasts minutes`);
327
+ }
189
328
  const ns = await get(`${registry}/api/${encodeURIComponent(id.publisher)}`);
190
329
  if (ns.status === 404) {
191
330
  throw new PublishTargetError("publish-marketplace-no-namespace", `Open VSX at ${registry} has no namespace ${id.publisher}`, `Create it once with: npx ovsx create-namespace ${id.publisher}`);
@@ -206,6 +345,18 @@ export function marketplaceTarget(decl: MarketplacePublishDeclaration, deps: Pub
206
345
  ctx.log(`${item.name} is already on Open VSX with the same bytes`);
207
346
  return done(true);
208
347
  }
348
+ if (auth === "azure-credential") {
349
+ ctx.log(`checking the job's Microsoft Entra identity may publish as ${id.publisher}: vsce verify-pat --azure-credential ${id.publisher}`);
350
+ const check = await vsce(ctx, ["verify-pat", id.publisher], null);
351
+ for (const l of check.output) ctx.log(`vsce: ${l}`);
352
+ if (check.code !== 0) {
353
+ throw new PublishTargetError(
354
+ "publish-marketplace-azure-credential",
355
+ `vsce could not sign in with a Microsoft Entra identity that has a role on publisher ${id.publisher}: vsce verify-pat exited ${check.code}${check.output.length ? `: ${check.output.slice(-3).join(" ")}` : ""}`,
356
+ `Sign in to Azure in the publish's job before it runs, such as with azure/login and the run's OIDC token, as an identity added to the publisher ${id.publisher}.`,
357
+ );
358
+ }
359
+ }
209
360
  if (await galleryHas(ctx, id)) {
210
361
  ctx.log(`${item.name} is already on the VS Code Marketplace; it reports no digest to compare`);
211
362
  return done(true);
@@ -217,43 +368,53 @@ export function marketplaceTarget(decl: MarketplacePublishDeclaration, deps: Pub
217
368
  const items = staged.items.map((i) => ({ name: i.name, destination: i.destination, ...(i.digest ? { digest: i.digest } : {}) }));
218
369
  if (staged.state.present === "true") return { target: target.name, destination: target.destination, items: items.map((i) => ({ ...i, present: true })) };
219
370
  const { abs, bytes, id, digest, token, item } = setup(ctx);
371
+ const refusable = async <T>(step: () => Promise<T>): Promise<T | PublishedTarget> => {
372
+ try {
373
+ return await step();
374
+ } catch (err) {
375
+ if (decl.onRefusal === "warn" && err instanceof PublishTargetError && REFUSALS.has(err.code)) return refusedResult(ctx, items, err);
376
+ throw err;
377
+ }
378
+ };
220
379
  if (decl.marketplace === "openvsx") {
221
380
  // Run again after an upload whose record was lost, the version is there: check it rather than send it twice.
222
- const before = await openVsxServed(ctx, id);
223
- if (before === null) {
224
- ctx.log(`uploading ${item.name} (${bytes.byteLength} bytes) to Open VSX`);
225
- const res = await fetchImpl(`${registry}/api/-/publish?token=${encodeURIComponent(token.value)}`, {
381
+ const uploaded = await refusable(async () => {
382
+ const before = await openVsxServed(ctx, id);
383
+ if (before !== null) return before;
384
+ const publishToken = token ? token.value : await trustedToken(ctx, id);
385
+ ctx.log(`uploading ${item.name} (${bytes.byteLength} bytes) to Open VSX${token ? "" : " with a trusted-publishing token"}`);
386
+ const res = await fetchImpl(`${registry}/api/-/publish?token=${encodeURIComponent(publishToken)}`, {
226
387
  method: "POST",
227
388
  headers: { "user-agent": "chant", "content-type": "application/octet-stream" },
228
389
  body: new Uint8Array(bytes),
229
390
  });
230
391
  if (res.status !== 201 && res.status !== 200) fail(ctx, `publishing ${item.name}`, res.status, await res.text().catch(() => ""));
231
- }
392
+ return null;
393
+ });
394
+ if (uploaded !== null && typeof uploaded === "object") return uploaded;
395
+ const before = uploaded;
232
396
  const served = before ?? (await openVsxServed(ctx, id));
233
397
  if (served !== digest) {
234
398
  throw new PublishTargetError("publish-marketplace-digest-mismatch", `Open VSX serves ${item.name} with digest ${served ?? "none"}, and the file published is ${digest}`);
235
399
  }
236
400
  return { target: target.name, destination: target.destination, items: before === null ? items : items.map((i) => ({ ...i, present: true })) };
237
401
  }
238
- if (await galleryHas(ctx, id)) {
239
- ctx.log(`${item.name} is already on the VS Code Marketplace`);
240
- return { target: target.name, destination: target.destination, items: items.map((i) => ({ ...i, present: true })) };
241
- }
242
- ctx.log(`running vsce publish --packagePath ${decl.vsix}`);
243
- const result = await run(deps.vsce ?? "vsce", ["publish", "--packagePath", abs], ctx, vsceEnv(ctx.env, token)).catch((err: unknown) => {
244
- throw new PublishTargetError("publish-marketplace-failed", `vsce could not be run: ${err instanceof Error ? err.message : String(err)}`, "Install it on the job's PATH: npm install -g @vscode/vsce");
402
+ const outcome = await refusable(async () => {
403
+ if (await galleryHas(ctx, id)) {
404
+ ctx.log(`${item.name} is already on the VS Code Marketplace`);
405
+ return true;
406
+ }
407
+ ctx.log(`running vsce publish --packagePath ${decl.vsix}${token ? "" : " --azure-credential"}`);
408
+ const result = await vsce(ctx, ["publish", "--packagePath", abs], token);
409
+ for (const l of result.output) ctx.log(`vsce: ${l}`);
410
+ if (result.code !== 0) {
411
+ throw new PublishTargetError("publish-marketplace-failed", `vsce publish of ${item.name} exited ${result.code}${result.output.length ? `: ${result.output.slice(-3).join(" ")}` : ""}`);
412
+ }
413
+ return false;
245
414
  });
246
- for (const l of result.output) ctx.log(`vsce: ${l}`);
247
- if (result.code !== 0) {
248
- throw new PublishTargetError("publish-marketplace-failed", `vsce publish of ${item.name} exited ${result.code}${result.output.length ? `: ${result.output.slice(-3).join(" ")}` : ""}`);
249
- }
250
- return { target: target.name, destination: target.destination, items };
415
+ if (typeof outcome === "object") return outcome;
416
+ return { target: target.name, destination: target.destination, items: outcome ? items.map((i) => ({ ...i, present: true })) : items };
251
417
  },
252
418
  };
253
419
  return target;
254
420
  }
255
-
256
- /** The environment vsce runs with: the run's, with the token in `VSCE_PAT`. */
257
- function vsceEnv(env: NodeJS.ProcessEnv, token: Credential): NodeJS.ProcessEnv {
258
- return { ...env, VSCE_PAT: token.value };
259
- }
@@ -152,6 +152,46 @@ describe("a publish that fails resumes", () => {
152
152
  }
153
153
  });
154
154
 
155
+ test("a target whose reveal comes back refused with a warning is not recorded as revealed, so the same publish tries it again (#4698)", async () => {
156
+ const r = new TestRepo("publish-refused");
157
+ repos.push(r);
158
+ const rel = await release(r);
159
+ const reveals: string[] = [];
160
+ let refuse = true;
161
+ const fake = (kind: "forge" | "marketplace", name: string): PublishTarget => ({
162
+ kind,
163
+ name,
164
+ destination: name,
165
+ credentialEnv: [],
166
+ key: `${kind}:${name}`,
167
+ plan: async () => [],
168
+ stage: async () => ({ target: name, destination: name, items: [{ name, destination: name }], state: {} }),
169
+ reveal: async () => {
170
+ reveals.push(name);
171
+ return kind === "marketplace" && refuse
172
+ ? { target: name, destination: name, items: [{ name, destination: name, refused: true }], warning: "Open VSX refused it: it answered 406" }
173
+ : { target: name, destination: name, items: [{ name, destination: name }] };
174
+ },
175
+ });
176
+ const targets = [fake("forge", "assets"), fake("marketplace", "openvsx")];
177
+ const lines: string[] = [];
178
+ const redactor = createRedactor({});
179
+ const ctx: PublishContext = { release: rel, label: "v2", releaseTag: "release/v2", provenance: NO_OIDC, cwd: r.dir, tag: null, env: {}, redactor, log: () => undefined };
180
+ const run = () => runPublish({ cwd: r.dir, release: rel, label: "v2", targets, ctx, say: (l) => lines.push(l) });
181
+ const records = () => parsePublishRecords(r.git(["show", `chant/lifecycle:_releases/${PUBLISHES_FILE}`])).records;
182
+
183
+ const first = await run();
184
+ expect(first.published.map((p) => p.warning ?? null)).toEqual([null, "Open VSX refused it: it answered 406"]);
185
+ expect(lines).toContain(" warning: openvsx: Open VSX refused it: it answered 406");
186
+ expect(records().filter((x) => x.step === "revealed").map((x) => x.target)).toEqual(["forge:assets"]);
187
+
188
+ refuse = false;
189
+ reveals.length = 0;
190
+ await run();
191
+ expect(reveals).toEqual(["openvsx"]);
192
+ expect(records().filter((x) => x.step === "revealed").map((x) => x.target)).toEqual(["forge:assets", "marketplace:openvsx"]);
193
+ });
194
+
155
195
  test("a target's key names its declaration, so a resume finds it, and holds no credential", async () => {
156
196
  const [a, b, c] = await createPublishTargets(
157
197
  [
@@ -52,10 +52,9 @@ import { GitHubRepo, githubApi, type GitHubRelease } from "./publish-github";
52
52
  import { fillUrl, releaseVersion } from "./publish-homebrew";
53
53
  import { bytesDigest, checkReleaseDigest, memberFile, publishTargetKey } from "./publish-targets";
54
54
  import { PublishTargetError, type PublishContext, type PublishDeps, type PublishFetch, type PublishItem, type PublishTarget, type StagedTarget } from "./release-publish";
55
- import { NEXT_RELEASE } from "../release-floors";
56
55
 
57
56
  /** The first chant that publishes a `tauri-updater` target (#4676). */
58
- export const PUBLISH_TAURI_UPDATER_FLOOR = NEXT_RELEASE;
57
+ export const PUBLISH_TAURI_UPDATER_FLOOR = "0.124.63";
59
58
 
60
59
  interface File {
61
60
  path: string;
@@ -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 `redeploys` 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"]],
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
  }
@@ -0,0 +1,195 @@
1
+ /**
2
+ * #4692: a release cut from a lane's green tag. A cut given a lane that
3
+ * `ci.green.lanes` declares checks `ci/green-<lane>/<sha>` and
4
+ * `ci/revoked-<lane>/<sha>` in place of the full green tags, and the cut
5
+ * line names the lane. `release candidates --lane` reads the same tags.
6
+ */
7
+
8
+ import { describe, test, expect } from "vitest";
9
+ import { withTestDir } from "@intentius/chant-test-utils";
10
+ import { spawnSync } from "node:child_process";
11
+ import { mkdirSync, writeFileSync } from "node:fs";
12
+ import { join } from "node:path";
13
+ import { cutRelease, planRelease, ReleaseCutError } from "./release-cut";
14
+ import { readCuts, type ReleaseArtifact } from "./release-store";
15
+ import type { CompiledTarget, TargetCompiler } from "../components/release-compile";
16
+ import { releasesDocument } from "../workspace/releases";
17
+ import { releaseCandidatesDocument } from "../workspace/release-candidates";
18
+ import { contract, declaration } from "../workspace/__fixtures__/contract-repo";
19
+ import releasesSchema from "../workspace/releases.schema.json";
20
+ import candidatesSchema from "../workspace/release-candidates.schema.json";
21
+
22
+ function git(dir: string, ...args: string[]): string {
23
+ const r = spawnSync("git", args, { cwd: dir, encoding: "utf-8" });
24
+ if (r.status !== 0) throw new Error(`git ${args.join(" ")}: ${r.stderr}`);
25
+ return r.stdout.trim();
26
+ }
27
+
28
+ const GREEN = {
29
+ branch: "main",
30
+ phases: { lint: ["lint"], test: ["test"], windows: ["windows"] },
31
+ require: ["lint", "test", "windows"],
32
+ lanes: { server: { require: ["lint", "test"] } },
33
+ };
34
+
35
+ /** A workspace whose root member is a chant project with two environments, on main, with `ci.green` as given. */
36
+ function workspace(dir: string, green: unknown = GREEN): string {
37
+ git(dir, "init", "-q", "-b", "main");
38
+ git(dir, "config", "user.email", "test@chant.dev");
39
+ git(dir, "config", "user.name", "Test");
40
+ writeFileSync(join(dir, "chant.workspace.json"), declaration([{ name: "root", dir: ".", kind: "other", because: "the release fixture" }], green ? { ci: { green } } : {}));
41
+ writeFileSync(join(dir, "chant.config.ts"), `export default { environments: ["dev", "prod"] };\n`);
42
+ mkdirSync(join(dir, "api"), { recursive: true });
43
+ writeFileSync(join(dir, "api", "Dockerfile"), "FROM scratch\n");
44
+ writeFileSync(join(dir, "api.component.ts"), "export const api = {};\n");
45
+ git(dir, "add", ".");
46
+ git(dir, "commit", "-q", "-m", "init");
47
+ return git(dir, "rev-parse", "HEAD");
48
+ }
49
+
50
+ function compiler(): TargetCompiler {
51
+ return {
52
+ async compile(env): Promise<CompiledTarget> {
53
+ return {
54
+ env,
55
+ params: [],
56
+ components: ["api"],
57
+ buildSteps: { api: [{ kind: "docker-build", context: "api", into: "api.tar" }] },
58
+ buildInputs: { api: ["api"] },
59
+ componentFiles: { api: "api.component.ts" },
60
+ templates: [{ component: "api", path: "dist/api.json", content: `{"env":"${env}"}\n` }],
61
+ };
62
+ },
63
+ async buildArtifacts(_env, components): Promise<ReleaseArtifact[]> {
64
+ return components.map((c) => ({ component: c, kind: "image" as const, path: `${c}.tar`, digest: `sha256:${"b".repeat(64)}` }));
65
+ },
66
+ };
67
+ }
68
+
69
+ const NOW = () => new Date("2026-11-01T10:00:00.000Z");
70
+ const cut = (dir: string, lane?: string, label: string | null = "v1.0.0") =>
71
+ cutRelease({ cwd: dir, compiler: compiler(), label, actor: "alice", env: {}, now: NOW, ...(lane !== undefined ? { lane } : {}) });
72
+ const refusal = async (p: Promise<unknown>): Promise<ReleaseCutError> => {
73
+ const err = await p.catch((e: unknown) => e);
74
+ expect(err).toBeInstanceOf(ReleaseCutError);
75
+ return err as ReleaseCutError;
76
+ };
77
+
78
+ describe("a cut from a lane (#4692)", () => {
79
+ test("a commit green only in its lane is cut with --lane, and the cut line and releases document name the lane", async () => {
80
+ await withTestDir(async (dir) => {
81
+ const sha = workspace(dir);
82
+ git(dir, "tag", `ci/green-server/${sha}`, sha);
83
+
84
+ const without = await refusal(cut(dir));
85
+ expect(without.code).toBe("release-commit-not-green");
86
+ expect(without.message).toContain("has no ci/green tag");
87
+
88
+ const plan = await planRelease({ cwd: dir, compiler: compiler(), label: "v1.0.0", actor: "alice", env: {}, lane: "server" });
89
+ expect(plan.lane).toBe("server");
90
+
91
+ const result = await cut(dir, "server");
92
+ expect(result.cut?.lane).toBe("server");
93
+ const { cuts } = await readCuts({ cwd: dir });
94
+ expect(cuts.map((c) => c.lane)).toEqual(["server"]);
95
+
96
+ const doc = await releasesDocument({ cwd: dir });
97
+ if ("error" in doc) throw new Error(doc.error.message);
98
+ expect(doc.releases[0].cuts[0].lane).toBe("server");
99
+ contract(releasesSchema).expectValid(doc);
100
+ });
101
+ });
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
+
121
+ test("a cut without a lane writes no lane, and a full green commit is cut as before", async () => {
122
+ await withTestDir(async (dir) => {
123
+ const sha = workspace(dir);
124
+ git(dir, "tag", `ci/green/${sha}`, sha);
125
+ const result = await cut(dir);
126
+ expect(result.cut).not.toBeNull();
127
+ expect(result.cut).not.toHaveProperty("lane");
128
+ // The full green tag does not stand in for the lane's.
129
+ const err = await refusal(cut(dir, "server", "v1.0.1"));
130
+ expect(err.code).toBe("release-commit-not-green");
131
+ expect(err.message).toContain("has no ci/green-server tag");
132
+ expect(err.fix).toContain("chant ci last-green --lane server");
133
+ });
134
+ });
135
+
136
+ test("a lane's revoked tag refuses the cut in that lane", async () => {
137
+ await withTestDir(async (dir) => {
138
+ const sha = workspace(dir);
139
+ git(dir, "tag", `ci/green-server/${sha}`, sha);
140
+ git(dir, "tag", `ci/revoked-server/${sha}`, sha);
141
+ const err = await refusal(cut(dir, "server"));
142
+ expect(err.code).toBe("release-commit-revoked");
143
+ expect(err.message).toContain("has a ci/revoked-server tag");
144
+ });
145
+ });
146
+
147
+ test("a lane the declaration does not declare, or no ci.green, is declaration-invalid and writes nothing", async () => {
148
+ await withTestDir(async (dir) => {
149
+ const sha = workspace(dir);
150
+ git(dir, "tag", `ci/green-app/${sha}`, sha);
151
+ const err = await refusal(cut(dir, "app"));
152
+ expect(err.code).toBe("declaration-invalid");
153
+ expect(err.message).toContain(`no lane "app"; it declares server`);
154
+ expect((await readCuts({ cwd: dir })).cuts).toEqual([]);
155
+ });
156
+ await withTestDir(async (dir) => {
157
+ const sha = workspace(dir, null);
158
+ git(dir, "tag", `ci/green-server/${sha}`, sha);
159
+ const err = await refusal(cut(dir, "server"));
160
+ expect(err.code).toBe("declaration-invalid");
161
+ expect(err.message).toContain("declares no ci.green");
162
+ });
163
+ });
164
+ });
165
+
166
+ describe("release candidates in a lane (#4692)", () => {
167
+ test("reads the lane's tags, names the lane, and skips a commit the lane revoked", async () => {
168
+ await withTestDir(async (dir) => {
169
+ const a = workspace(dir);
170
+ git(dir, "commit", "-q", "--allow-empty", "-m", "b");
171
+ const b = git(dir, "rev-parse", "HEAD");
172
+ git(dir, "commit", "-q", "--allow-empty", "-m", "c");
173
+ const c = git(dir, "rev-parse", "HEAD");
174
+ git(dir, "tag", `ci/green/${a}`, a);
175
+ git(dir, "tag", `ci/green-server/${b}`, b);
176
+ git(dir, "tag", `ci/green-server/${c}`, c);
177
+ git(dir, "tag", `ci/revoked-server/${c}`, c);
178
+
179
+ const full = await releaseCandidatesDocument({ cwd: dir });
180
+ if ("error" in full) throw new Error(full.error.message);
181
+ expect(full.lane).toBeNull();
182
+ expect(full.candidates.map((x) => x.commit)).toEqual([a]);
183
+
184
+ const lane = await releaseCandidatesDocument({ cwd: dir, lane: "server" });
185
+ if ("error" in lane) throw new Error(lane.error.message);
186
+ expect(lane.lane).toBe("server");
187
+ expect(lane.candidates.map((x) => x.commit)).toEqual([b]);
188
+ expect(lane.skipped.map((x) => x.commit)).toEqual([c]);
189
+ contract(candidatesSchema).expectValid(lane);
190
+
191
+ const unknown = await releaseCandidatesDocument({ cwd: dir, lane: "app" });
192
+ expect("error" in unknown && unknown.error.message).toContain(`no lane "app"`);
193
+ });
194
+ });
195
+ });