@intentius/chant 0.124.70 → 0.124.72
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/ci-agent.d.ts +12 -1
- package/dist/ci-agent.d.ts.map +1 -1
- package/dist/ci-agent.js +13 -8
- package/dist/ci-commit.d.ts +326 -0
- package/dist/ci-commit.d.ts.map +1 -0
- package/dist/ci-commit.js +725 -0
- package/dist/ci-estate/delivery.d.ts +75 -2
- package/dist/ci-estate/delivery.d.ts.map +1 -1
- package/dist/ci-estate/delivery.js +129 -0
- package/dist/ci-estate.d.ts +3 -1
- package/dist/ci-estate.d.ts.map +1 -1
- package/dist/ci-estate.js +4 -1
- package/dist/ci-product-words.d.ts +6 -1
- package/dist/ci-product-words.d.ts.map +1 -1
- package/dist/ci-product-words.js +3 -1
- package/dist/ci-product.d.ts +1 -1
- package/dist/ci-product.d.ts.map +1 -1
- package/dist/ci-product.js +1 -1
- package/dist/cli/handlers/approve.d.ts.map +1 -1
- package/dist/cli/handlers/approve.js +7 -2
- package/dist/cli/handlers/commit.d.ts +26 -0
- package/dist/cli/handlers/commit.d.ts.map +1 -0
- package/dist/cli/handlers/commit.js +145 -0
- package/dist/cli/handlers/notify-relay.d.ts.map +1 -1
- package/dist/cli/handlers/notify-relay.js +22 -2
- package/dist/cli/handlers/pr.d.ts +6 -0
- package/dist/cli/handlers/pr.d.ts.map +1 -1
- package/dist/cli/handlers/pr.js +16 -7
- package/dist/cli/handlers/release.d.ts +9 -0
- package/dist/cli/handlers/release.d.ts.map +1 -1
- package/dist/cli/handlers/release.js +114 -5
- package/dist/cli/main.d.ts.map +1 -1
- package/dist/cli/main.js +17 -0
- package/dist/components/product-pipeline.d.ts +33 -0
- package/dist/components/product-pipeline.d.ts.map +1 -1
- package/dist/components/product-pipeline.js +34 -1
- package/dist/components/release-compile.d.ts +2 -0
- package/dist/components/release-compile.d.ts.map +1 -1
- package/dist/components/release-compile.js +8 -4
- package/dist/config.d.ts +60 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +16 -0
- package/dist/lexicon.d.ts +54 -0
- package/dist/lexicon.d.ts.map +1 -1
- package/dist/lexicon.js +28 -0
- package/dist/lifecycle/__fixtures__/publish-fakes.d.ts +4 -0
- package/dist/lifecycle/__fixtures__/publish-fakes.d.ts.map +1 -1
- package/dist/lifecycle/__fixtures__/publish-fakes.js +6 -2
- package/dist/lifecycle/gated-request.d.ts +3 -1
- package/dist/lifecycle/gated-request.d.ts.map +1 -1
- package/dist/lifecycle/gated-request.js +5 -2
- package/dist/lifecycle/git.d.ts.map +1 -1
- package/dist/lifecycle/git.js +57 -0
- package/dist/lifecycle/publish-declaration.d.ts +16 -0
- package/dist/lifecycle/publish-declaration.d.ts.map +1 -1
- package/dist/lifecycle/publish-declaration.js +35 -3
- package/dist/lifecycle/publish-forge.d.ts +12 -0
- package/dist/lifecycle/publish-forge.d.ts.map +1 -1
- package/dist/lifecycle/publish-forge.js +102 -19
- package/dist/lifecycle/publish-npm.d.ts +15 -0
- package/dist/lifecycle/publish-npm.d.ts.map +1 -1
- package/dist/lifecycle/publish-npm.js +28 -1
- package/dist/lifecycle/publish-oci.d.ts +2 -0
- package/dist/lifecycle/publish-oci.d.ts.map +1 -1
- package/dist/lifecycle/publish-oci.js +10 -0
- package/dist/lifecycle/release-cut.d.ts +7 -1
- package/dist/lifecycle/release-cut.d.ts.map +1 -1
- package/dist/lifecycle/release-cut.js +8 -1
- package/dist/lifecycle/release-images.d.ts +87 -0
- package/dist/lifecycle/release-images.d.ts.map +1 -0
- package/dist/lifecycle/release-images.js +138 -0
- package/dist/lifecycle/release-publish.d.ts +2 -0
- package/dist/lifecycle/release-publish.d.ts.map +1 -1
- package/dist/notify-relay.d.ts +41 -1
- package/dist/notify-relay.d.ts.map +1 -1
- package/dist/notify-relay.js +40 -0
- package/dist/notify.d.ts +16 -3
- package/dist/notify.d.ts.map +1 -1
- package/dist/notify.js +16 -10
- package/dist/op/activities/review-agent.d.ts.map +1 -1
- package/dist/op/activities/review-agent.js +4 -2
- package/dist/op/gate.d.ts +5 -1
- package/dist/op/gate.d.ts.map +1 -1
- package/dist/op/gate.js +7 -2
- package/dist/op/op-waves-notify.d.ts +1 -1
- package/dist/op/op-waves-notify.d.ts.map +1 -1
- package/dist/op/op-waves-notify.js +2 -1
- package/dist/op/op-waves-run.d.ts.map +1 -1
- package/dist/op/op-waves-run.js +12 -8
- package/dist/op/op-waves.d.ts +9 -0
- package/dist/op/op-waves.d.ts.map +1 -1
- package/dist/op/op-waves.js +11 -0
- package/dist/pr-forge-base.d.ts +18 -0
- package/dist/pr-forge-base.d.ts.map +1 -0
- package/dist/pr-forge-base.js +29 -0
- package/dist/release-floors.d.ts +1 -1
- package/dist/release-floors.js +1 -1
- package/dist/wave-runtime.mjs +315 -315
- package/dist/workspace/ci-green.d.ts.map +1 -1
- package/dist/workspace/ci-green.js +1 -2
- package/dist/workspace/release-workflow.d.ts +47 -0
- package/dist/workspace/release-workflow.d.ts.map +1 -1
- package/dist/workspace/release-workflow.js +258 -14
- package/package.json +1 -1
- package/src/ci-agent.ts +13 -8
- package/src/ci-commit.test.ts +415 -0
- package/src/ci-commit.ts +901 -0
- package/src/ci-estate/__fixtures__/terragucci-dora.json +1305 -0
- package/src/ci-estate/delivery.ts +186 -2
- package/src/ci-estate/records-delivery.test.ts +55 -0
- package/src/ci-estate.ts +10 -0
- package/src/ci-product-words.ts +6 -2
- package/src/ci-product.ts +1 -0
- package/src/cli/handlers/approve.ts +6 -2
- package/src/cli/handlers/commit.ts +155 -0
- package/src/cli/handlers/notify-relay.ts +21 -2
- package/src/cli/handlers/operator.test.ts +2 -0
- package/src/cli/handlers/pr-wave-approve-lines.test.ts +32 -0
- package/src/cli/handlers/pr.ts +17 -7
- package/src/cli/handlers/release.ts +110 -5
- package/src/cli/main.ts +17 -0
- package/src/components/product-pipeline.test.ts +28 -1
- package/src/components/product-pipeline.ts +54 -1
- package/src/components/release-compile.ts +9 -3
- package/src/config.ts +31 -0
- package/src/lexicon.ts +72 -0
- package/src/lifecycle/__fixtures__/publish-fakes.ts +11 -5
- package/src/lifecycle/gated-request-spend.test.ts +115 -0
- package/src/lifecycle/gated-request.ts +5 -2
- package/src/lifecycle/git.ts +53 -0
- package/src/lifecycle/ledger-two-clones.test.ts +132 -0
- package/src/lifecycle/publish-declaration.ts +35 -3
- package/src/lifecycle/publish-forge-notes.test.ts +193 -0
- package/src/lifecycle/publish-forge.ts +100 -22
- package/src/lifecycle/publish-npm.ts +31 -2
- package/src/lifecycle/publish-oci.ts +10 -0
- package/src/lifecycle/publish-targets.test.ts +2 -1
- package/src/lifecycle/release-cut.ts +17 -1
- package/src/lifecycle/release-images.test.ts +242 -0
- package/src/lifecycle/release-images.ts +174 -0
- package/src/lifecycle/release-publish.ts +2 -0
- package/src/notify-relay.test.ts +55 -1
- package/src/notify-relay.ts +49 -1
- package/src/notify.ts +25 -12
- package/src/op/activities/review-agent.test.ts +20 -1
- package/src/op/activities/review-agent.ts +5 -2
- package/src/op/gate.ts +7 -2
- package/src/op/op-waves-approve-target.test.ts +108 -0
- package/src/op/op-waves-notify.ts +2 -2
- package/src/op/op-waves-run.ts +12 -7
- package/src/op/op-waves.ts +12 -0
- package/src/pr-forge-base.test.ts +37 -0
- package/src/pr-forge-base.ts +36 -0
- package/src/release-floors.ts +1 -1
- package/src/workspace/__fixtures__/release-workflow/forgejo-plain-member.yml +26 -0
- package/src/workspace/__fixtures__/release-workflow/forgejo-plain.yml +23 -0
- package/src/workspace/__fixtures__/release-workflow/forgejo-secure-member.yml +27 -0
- package/src/workspace/__fixtures__/release-workflow/forgejo-secure.yml +24 -0
- package/src/workspace/__fixtures__/release-workflow/github-plain-member.yml +26 -0
- package/src/workspace/__fixtures__/release-workflow/github-plain.yml +23 -0
- package/src/workspace/__fixtures__/release-workflow/github-secure-member.yml +27 -0
- package/src/workspace/__fixtures__/release-workflow/github-secure.yml +24 -0
- package/src/workspace/__fixtures__/release-workflow/gitlab-plain-member.yml +13 -0
- package/src/workspace/__fixtures__/release-workflow/gitlab-plain.yml +12 -0
- package/src/workspace/__fixtures__/release-workflow/gitlab-secure-member.yml +14 -0
- package/src/workspace/__fixtures__/release-workflow/gitlab-secure.yml +13 -0
- package/src/workspace/ci-green.ts +1 -2
- package/src/workspace/release-workflow.test.ts +199 -0
- package/src/workspace/release-workflow.ts +356 -14
package/src/lexicon.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { InstanceObservation } from "./instance-nodes";
|
|
2
2
|
import type { CiRunner } from "./ci-jobs";
|
|
3
3
|
import type { OpAgentSpec } from "./ci-agent";
|
|
4
|
+
import type { OpCommitSpec } from "./ci-commit";
|
|
4
5
|
import type { CloudTradeSpec } from "./ci-identity";
|
|
5
6
|
import type { EngineFacts } from "./engine-facts";
|
|
6
7
|
import type { CapabilityPack } from "./capabilities/view";
|
|
@@ -78,6 +79,7 @@ export type { ReferenceCatalog, IdentityRule, RefRule } from "./graph-refs";
|
|
|
78
79
|
// edge type from the same entry it imports the plugin contract from.
|
|
79
80
|
export type { IREdge } from "./graph-ir";
|
|
80
81
|
export type { OpAgentSpec } from "./ci-agent";
|
|
82
|
+
export type { OpCommitSpec } from "./ci-commit";
|
|
81
83
|
|
|
82
84
|
// The observation contract (#1089), re-exported from the same entry so a
|
|
83
85
|
// lexicon's `describeResources` can report NOT-OBSERVED without a second
|
|
@@ -935,6 +937,16 @@ export interface ScheduledOpSpec {
|
|
|
935
937
|
* branch. The model's job holds no write token; the push job does.
|
|
936
938
|
*/
|
|
937
939
|
agent?: OpAgentSpec;
|
|
940
|
+
/**
|
|
941
|
+
* The commit jobs (#4722, ../ci-commit.ts): the product's fixed command run
|
|
942
|
+
* on a pull request's head, its change pushed to the pull request's branch.
|
|
943
|
+
* `on: "comment"`: this spec is the commit job's own workflow, answering
|
|
944
|
+
* `/<product> <word>`, and `trigger` is not read. `on: "check"`: the jobs
|
|
945
|
+
* follow this Op's job on a pull request and run when its run exits with
|
|
946
|
+
* one of `findings`. The command's job holds no forge token; the push job
|
|
947
|
+
* holds `tokenEnv`.
|
|
948
|
+
*/
|
|
949
|
+
commit?: OpCommitSpec;
|
|
938
950
|
/**
|
|
939
951
|
* The job's cloud identities (#4631), as an op wave's `cloud` (#4332,
|
|
940
952
|
* #4549): the three generators trade the job's OIDC token for them in a
|
|
@@ -952,6 +964,66 @@ export interface ScheduledOpSpec {
|
|
|
952
964
|
* check. A cron or pull_request trigger only.
|
|
953
965
|
*/
|
|
954
966
|
update?: ScheduledOpUpdate;
|
|
967
|
+
/**
|
|
968
|
+
* Files the Op's job keeps after its run (#4622), such as a drift report
|
|
969
|
+
* for a repository with no bucket to put it in. Kept whether the run
|
|
970
|
+
* passed, failed or found drift. GitHub and Forgejo upload each entry as
|
|
971
|
+
* its own artifact; GitLab keeps one archive per job, so the entries' paths
|
|
972
|
+
* join the job's `artifacts:` under the entry's name when there is one.
|
|
973
|
+
* Not on a `reviewAgent` split or a comment agent's workflow.
|
|
974
|
+
*/
|
|
975
|
+
artifacts?: ScheduledOpArtifact[];
|
|
976
|
+
/** GitLab only (#4753): what a GitLab Op job declares beyond chant's own. Ignored by the other generators. */
|
|
977
|
+
gitlab?: ScheduledOpGitlab;
|
|
978
|
+
}
|
|
979
|
+
|
|
980
|
+
/** A scheduled Op job's GitLab-only settings (#4753). */
|
|
981
|
+
export interface ScheduledOpGitlab {
|
|
982
|
+
/** Named `id_tokens:` with their audiences, beside chant's own (`CHANT_ID_TOKEN`, a cloud trade's); a name chant uses is refused. */
|
|
983
|
+
idTokens?: Record<string, { aud: string | string[] }>;
|
|
984
|
+
/** The job's `cache:` entry, or entries, as GitLab takes them. */
|
|
985
|
+
cache?: Record<string, unknown> | Array<Record<string, unknown>>;
|
|
986
|
+
/**
|
|
987
|
+
* For a cron trigger: the `rules: if:` that picks the pipeline schedule,
|
|
988
|
+
* in place of `$CI_PIPELINE_SOURCE == "schedule" && $CHANT_SCHEDULED_OP == "<name>"`,
|
|
989
|
+
* such as a product's rule that runs on every schedule but its own named ones.
|
|
990
|
+
*/
|
|
991
|
+
scheduleRule?: string;
|
|
992
|
+
}
|
|
993
|
+
|
|
994
|
+
/** A named set of files a scheduled Op's job keeps after its run (#4622). */
|
|
995
|
+
export interface ScheduledOpArtifact {
|
|
996
|
+
/** The artifact's name, unique among the Op's artifacts. */
|
|
997
|
+
name: string;
|
|
998
|
+
/** Files or directories, relative to the job's directory (the member's, in a workspace). */
|
|
999
|
+
paths: string[];
|
|
1000
|
+
/** How many days the forge keeps it. Default: the forge's own. */
|
|
1001
|
+
retentionDays?: number;
|
|
1002
|
+
}
|
|
1003
|
+
|
|
1004
|
+
/**
|
|
1005
|
+
* Check a scheduled Op's `artifacts` (#4622) and return them, or `[]` when it
|
|
1006
|
+
* has none. Throws naming the Op on an empty or repeated name, an empty
|
|
1007
|
+
* `paths`, an absolute path or one that leaves the job's directory, or a
|
|
1008
|
+
* retention that is not a positive whole number of days.
|
|
1009
|
+
*/
|
|
1010
|
+
export function scheduledOpArtifacts(spec: Pick<ScheduledOpSpec, "name" | "artifacts">): ScheduledOpArtifact[] {
|
|
1011
|
+
const list = spec.artifacts ?? [];
|
|
1012
|
+
const seen = new Set<string>();
|
|
1013
|
+
for (const a of list) {
|
|
1014
|
+
const where = `Scheduled Op "${spec.name}" artifact "${a.name}"`;
|
|
1015
|
+
if (!a.name || !/^[A-Za-z0-9._-]+$/.test(a.name)) throw new Error(`Scheduled Op "${spec.name}": an artifact's name is letters, digits, ".", "_" and "-", and "${a.name}" is not.`);
|
|
1016
|
+
if (seen.has(a.name)) throw new Error(`Scheduled Op "${spec.name}" names the artifact "${a.name}" twice.`);
|
|
1017
|
+
seen.add(a.name);
|
|
1018
|
+
if (a.paths.length === 0) throw new Error(`${where} lists no paths.`);
|
|
1019
|
+
for (const p of a.paths) {
|
|
1020
|
+
if (p === "" || p.startsWith("/") || p.split("/").includes("..")) throw new Error(`${where}: "${p}" is not a path inside the job's directory.`);
|
|
1021
|
+
}
|
|
1022
|
+
if (a.retentionDays !== undefined && (!Number.isInteger(a.retentionDays) || a.retentionDays < 1)) {
|
|
1023
|
+
throw new Error(`${where}: retentionDays is a whole number of days, 1 or more.`);
|
|
1024
|
+
}
|
|
1025
|
+
}
|
|
1026
|
+
return list;
|
|
955
1027
|
}
|
|
956
1028
|
|
|
957
1029
|
/** A scheduled Op's update on drift (#4631). */
|
|
@@ -254,6 +254,10 @@ export interface FakeForgeRelease {
|
|
|
254
254
|
name?: string;
|
|
255
255
|
/** GitHub: the `make_latest` the release was published with. */
|
|
256
256
|
make_latest?: string;
|
|
257
|
+
/** The release's notes: GitHub's and Forgejo's `body`, GitLab's `description` (#4658). */
|
|
258
|
+
body?: string;
|
|
259
|
+
/** Forgejo: published as a prerelease. */
|
|
260
|
+
prerelease?: boolean;
|
|
257
261
|
}
|
|
258
262
|
|
|
259
263
|
/** A forge fake answering through `fetch`: GitHub or Forgejo with draft releases, or GitLab with releases, links and a generic package registry. */
|
|
@@ -307,9 +311,9 @@ export function startFakeForge(forge: "github" | "forgejo" | "gitlab", api: stri
|
|
|
307
311
|
return r ? json(200, view(r)) : json(404, { message: "404 Not Found" });
|
|
308
312
|
}
|
|
309
313
|
if (init.method === "POST" && path === `${root}/releases`) {
|
|
310
|
-
const b = JSON.parse(text(init.body)) as { tag_name: string; ref: string; assets?: { links?: Array<{ name: string; url: string }> } };
|
|
314
|
+
const b = JSON.parse(text(init.body)) as { tag_name: string; ref: string; description?: string; assets?: { links?: Array<{ name: string; url: string }> } };
|
|
311
315
|
if (releases.some((x) => x.tag_name === b.tag_name)) return json(409, { message: "Release already exists" });
|
|
312
|
-
const r: FakeForgeRelease = { id: nextId++, tag_name: b.tag_name, draft: false, target: b.ref, assets: (b.assets?.links ?? []).map((l) => ({ name: l.name, digest: null, bytes: packages.get(l.url) ?? "" })) };
|
|
316
|
+
const r: FakeForgeRelease = { id: nextId++, tag_name: b.tag_name, draft: false, target: b.ref, assets: (b.assets?.links ?? []).map((l) => ({ name: l.name, digest: null, bytes: packages.get(l.url) ?? "" })), ...(b.description !== undefined ? { body: b.description } : {}) };
|
|
313
317
|
releases.push(r);
|
|
314
318
|
return json(201, view(r));
|
|
315
319
|
}
|
|
@@ -322,8 +326,8 @@ export function startFakeForge(forge: "github" | "forgejo" | "gitlab", api: stri
|
|
|
322
326
|
}
|
|
323
327
|
if (init.method === "GET" && path === `${root}/releases`) return json(200, releases.map(view));
|
|
324
328
|
if (init.method === "POST" && path === `${root}/releases`) {
|
|
325
|
-
const b = JSON.parse(text(init.body)) as { tag_name: string; target_commitish: string; draft?: boolean; name?: string };
|
|
326
|
-
const r: FakeForgeRelease = { id: nextId++, tag_name: b.tag_name, draft: b.draft === true, target: b.target_commitish, assets: [], ...(b.name ? { name: b.name } : {}) };
|
|
329
|
+
const b = JSON.parse(text(init.body)) as { tag_name: string; target_commitish: string; draft?: boolean; name?: string; body?: string };
|
|
330
|
+
const r: FakeForgeRelease = { id: nextId++, tag_name: b.tag_name, draft: b.draft === true, target: b.target_commitish, assets: [], ...(b.name ? { name: b.name } : {}), ...(b.body !== undefined ? { body: b.body } : {}) };
|
|
327
331
|
releases.push(r);
|
|
328
332
|
return json(201, view(r));
|
|
329
333
|
}
|
|
@@ -342,7 +346,9 @@ export function startFakeForge(forge: "github" | "forgejo" | "gitlab", api: stri
|
|
|
342
346
|
if (init.method === "PATCH" && edit) {
|
|
343
347
|
const r = releases.find((x) => x.id === Number(edit[1]));
|
|
344
348
|
if (!r) return json(404, { message: "Not Found" });
|
|
345
|
-
const b = JSON.parse(text(init.body)) as { draft?: boolean; make_latest?: string };
|
|
349
|
+
const b = JSON.parse(text(init.body)) as { draft?: boolean; make_latest?: string; body?: string; prerelease?: boolean };
|
|
350
|
+
if (b.body !== undefined) r.body = b.body;
|
|
351
|
+
if (b.prerelease !== undefined) r.prerelease = b.prerelease;
|
|
346
352
|
if (b.draft === false && r.draft) {
|
|
347
353
|
if (releases.some((x) => x !== r && !x.draft && x.tag_name === r.tag_name)) return json(422, { message: "Validation Failed", errors: [{ code: "already_exists", field: "tag_name" }] });
|
|
348
354
|
r.draft = false;
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* #4720: spending a gated request's approval in a checkout with no remote for
|
|
3
|
+
* `chant/lifecycle`. The local branch is the whole ledger there, so the
|
|
4
|
+
* applied line written to it spends the approval. A push that fails still
|
|
5
|
+
* refuses, as before.
|
|
6
|
+
*/
|
|
7
|
+
import { afterEach, describe, expect, test } from "vitest";
|
|
8
|
+
import { execFileSync } from "node:child_process";
|
|
9
|
+
import { mkdtempSync, realpathSync, rmSync, writeFileSync } from "node:fs";
|
|
10
|
+
import { tmpdir } from "node:os";
|
|
11
|
+
import { join } from "node:path";
|
|
12
|
+
import { pushLifecycleStatus, readBlobFromPath, writeBlobToPath } from "./git";
|
|
13
|
+
import { spendGatedRequest } from "./gated-request";
|
|
14
|
+
import { appliedGatePath, parseAppliedGateFile } from "./gate-applied";
|
|
15
|
+
|
|
16
|
+
const dirs: string[] = [];
|
|
17
|
+
|
|
18
|
+
afterEach(() => {
|
|
19
|
+
for (const d of dirs.splice(0)) rmSync(d, { recursive: true, force: true });
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
function git(args: string[], cwd: string): string {
|
|
23
|
+
return execFileSync("git", args, { cwd, encoding: "utf8" }).trim();
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function tmp(name: string): string {
|
|
27
|
+
const dir = realpathSync(mkdtempSync(join(tmpdir(), `gated-spend-${name}-`)));
|
|
28
|
+
dirs.push(dir);
|
|
29
|
+
return dir;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function identity(dir: string): void {
|
|
33
|
+
git(["config", "user.email", "test@chant.dev"], dir);
|
|
34
|
+
git(["config", "user.name", "Test"], dir);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function repo(dir: string): void {
|
|
38
|
+
git(["init", "-q", "-b", "main"], dir);
|
|
39
|
+
identity(dir);
|
|
40
|
+
writeFileSync(join(dir, "README.md"), "fixture\n");
|
|
41
|
+
git(["add", "README.md"], dir);
|
|
42
|
+
git(["commit", "-q", "-m", "init"], dir);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const spend = (cwd: string) => ({
|
|
46
|
+
op: "tf-export",
|
|
47
|
+
gate: "network",
|
|
48
|
+
digest: "sha256:" + "a".repeat(64),
|
|
49
|
+
approval: { resolvedBy: "github:bob", timestamp: "2026-11-02T10:00:00Z" },
|
|
50
|
+
now: "2026-11-02T10:05:00Z",
|
|
51
|
+
cwd,
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
async function appliedLines(cwd: string) {
|
|
55
|
+
const { dir, file } = appliedGatePath("tf-export");
|
|
56
|
+
const text = await readBlobFromPath(dir, file, { cwd });
|
|
57
|
+
return text ? parseAppliedGateFile(text).applied : [];
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
describe("spendGatedRequest (#4720)", () => {
|
|
61
|
+
test("with no remote, the applied line on the local branch spends the approval", async () => {
|
|
62
|
+
const dir = tmp("local");
|
|
63
|
+
repo(dir);
|
|
64
|
+
expect(git(["remote"], dir)).toBe("");
|
|
65
|
+
|
|
66
|
+
const record = await spendGatedRequest(spend(dir));
|
|
67
|
+
expect(record).toMatchObject({ kind: "applied", gate: "network", approvedBy: "github:bob" });
|
|
68
|
+
expect(await appliedLines(dir)).toEqual([expect.objectContaining({ gate: "network", planDigest: spend(dir).digest })]);
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
test("with a remote the push cannot reach, the spend still throws and nothing may apply", async () => {
|
|
72
|
+
const remote = tmp("remote");
|
|
73
|
+
git(["init", "-q", "--bare", "-b", "main"], remote);
|
|
74
|
+
const dir = tmp("checkout");
|
|
75
|
+
git(["clone", "-q", remote, dir], tmpdir());
|
|
76
|
+
identity(dir);
|
|
77
|
+
writeFileSync(join(dir, "README.md"), "fixture\n");
|
|
78
|
+
git(["add", "README.md"], dir);
|
|
79
|
+
git(["commit", "-q", "-m", "init"], dir);
|
|
80
|
+
git(["push", "-q", "origin", "main"], dir);
|
|
81
|
+
await writeBlobToPath("prod", "releases.jsonl", '{"seed":true}\n', "seed", { cwd: dir });
|
|
82
|
+
expect((await pushLifecycleStatus({ cwd: dir })).status).toBe("pushed");
|
|
83
|
+
|
|
84
|
+
git(["remote", "set-url", "origin", join(remote, "gone")], dir);
|
|
85
|
+
await expect(spendGatedRequest(spend(dir))).rejects.toThrow(/recorded as spent and not pushed .*failed.*so nothing may apply under it/);
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
test("with a remote another writer pushed to first, the spend still throws", async () => {
|
|
89
|
+
const remote = tmp("remote");
|
|
90
|
+
git(["init", "-q", "--bare", "-b", "main"], remote);
|
|
91
|
+
const dir = tmp("checkout");
|
|
92
|
+
git(["clone", "-q", remote, dir], tmpdir());
|
|
93
|
+
identity(dir);
|
|
94
|
+
writeFileSync(join(dir, "README.md"), "fixture\n");
|
|
95
|
+
git(["add", "README.md"], dir);
|
|
96
|
+
git(["commit", "-q", "-m", "init"], dir);
|
|
97
|
+
git(["push", "-q", "origin", "main"], dir);
|
|
98
|
+
await writeBlobToPath("prod", "releases.jsonl", '{"seed":true}\n', "seed", { cwd: dir });
|
|
99
|
+
expect((await pushLifecycleStatus({ cwd: dir })).status).toBe("pushed");
|
|
100
|
+
|
|
101
|
+
// A second checkout records and pushes, and the first never fetches it:
|
|
102
|
+
// the fetch before the spend is pointed somewhere unreadable, the push
|
|
103
|
+
// back at the real remote.
|
|
104
|
+
const other = tmp("other");
|
|
105
|
+
git(["clone", "-q", remote, other], tmpdir());
|
|
106
|
+
identity(other);
|
|
107
|
+
git(["fetch", "-q", "origin", "chant/lifecycle:chant/lifecycle"], other);
|
|
108
|
+
await writeBlobToPath("prod", "releases.jsonl", '{"seed":true}\n{"other":true}\n', "other", { cwd: other });
|
|
109
|
+
expect((await pushLifecycleStatus({ cwd: other })).status).toBe("pushed");
|
|
110
|
+
|
|
111
|
+
git(["remote", "set-url", "origin", join(remote, "gone")], dir);
|
|
112
|
+
git(["remote", "set-url", "--push", "origin", remote], dir);
|
|
113
|
+
await expect(spendGatedRequest(spend(dir))).rejects.toThrow(/recorded as spent and not pushed .*stale info.*so nothing may apply under it/s);
|
|
114
|
+
});
|
|
115
|
+
});
|
|
@@ -32,6 +32,7 @@ import { readGateLedger, type GateResolutionRecord, type PendingGateRecord } fro
|
|
|
32
32
|
import { pushLifecycleReport, readBlobBySha, readBlobFromPath, readPathSha, RefCASConflictError, requireLifecycleLedger, writeBlobToPath, type LedgerLocation } from "./git";
|
|
33
33
|
import { samePlanDigest } from "./plan-digest";
|
|
34
34
|
import { gatedRequestAttachmentPath, gatedRequestDigest, type GatedRequest } from "./gated-request-digest";
|
|
35
|
+
import { isLifecycleLocalNote } from "./local-note";
|
|
35
36
|
|
|
36
37
|
export { gatedRequestAttachmentPath, gatedRequestDigest, gatedRequestOf, type GatedRequest } from "./gated-request-digest";
|
|
37
38
|
|
|
@@ -183,7 +184,9 @@ export async function requestGate(input: RequestGateInput): Promise<RequestGateR
|
|
|
183
184
|
/**
|
|
184
185
|
* Record that the request applies under `approval`, which spends it. Throws
|
|
185
186
|
* unless the line was pushed, so two jobs never act on one approval; the
|
|
186
|
-
* caller acts only after this returns.
|
|
187
|
+
* caller acts only after this returns. With no remote for `chant/lifecycle`
|
|
188
|
+
* the local branch is the whole ledger, so the line written to it spends the
|
|
189
|
+
* approval (#4720); a push that failed or that another writer beat still throws.
|
|
187
190
|
*/
|
|
188
191
|
export async function spendGatedRequest(input: {
|
|
189
192
|
op: string;
|
|
@@ -208,7 +211,7 @@ export async function spendGatedRequest(input: {
|
|
|
208
211
|
...(input.commit ? { commit: input.commit } : {}),
|
|
209
212
|
};
|
|
210
213
|
const pushed = await appendAppliedLine(input.op, record as unknown as Record<string, unknown>, `Applied under ${input.gate}`, input.cwd ? { cwd: input.cwd } : undefined);
|
|
211
|
-
if (!pushed.pushed) throw new Error(`the approval of ${input.gate} was recorded as spent and not pushed (${pushed.pushWarning ?? "no remote"}), so nothing may apply under it`);
|
|
214
|
+
if (!pushed.pushed && !isLifecycleLocalNote(pushed.pushWarning)) throw new Error(`the approval of ${input.gate} was recorded as spent and not pushed (${pushed.pushWarning ?? "no remote"}), so nothing may apply under it`);
|
|
212
215
|
return record;
|
|
213
216
|
}
|
|
214
217
|
|
package/src/lifecycle/git.ts
CHANGED
|
@@ -276,6 +276,11 @@ export async function writeLedgerFiles(
|
|
|
276
276
|
await requireLifecycleLedger({ ...(cwd ? { cwd } : {}) });
|
|
277
277
|
}
|
|
278
278
|
|
|
279
|
+
// #4637: start from the remote's records this checkout already fetched. A
|
|
280
|
+
// caller that read a tip (`expectTip`) keeps it, and a run that records
|
|
281
|
+
// nothing leaves the branch alone.
|
|
282
|
+
if (opts?.expectTip === undefined && !ledgerRecordingOff()) await catchUpLifecycle(cwd);
|
|
283
|
+
|
|
279
284
|
// 2-5. Read the trees, build the commit, and CAS-update the branch ref —
|
|
280
285
|
// retried on a conflict (#1959 finding 1). Before that retry existed a
|
|
281
286
|
// conflict from step 5's `updateRefCAS` simply threw, breaking every caller
|
|
@@ -787,6 +792,40 @@ export type LifecyclePushStatus =
|
|
|
787
792
|
| { status: "stale"; remote: string; expected: string | null; stderr: string }
|
|
788
793
|
| { status: "failed"; remote: string; stderr: string };
|
|
789
794
|
|
|
795
|
+
/** Whether `ancestor` is in `descendant`'s history. */
|
|
796
|
+
async function isAncestor(ancestor: string, descendant: string, cwd?: string): Promise<boolean> {
|
|
797
|
+
const rt = getRuntime();
|
|
798
|
+
return (await rt.spawn(["git", "merge-base", "--is-ancestor", ancestor, descendant], { cwd, env: C_LOCALE_ENV })).exitCode === 0;
|
|
799
|
+
}
|
|
800
|
+
|
|
801
|
+
/**
|
|
802
|
+
* Fast-forward the local `chant/lifecycle` to the ledger remote's tip this
|
|
803
|
+
* checkout has already fetched, when it is behind it (#4637). A plain
|
|
804
|
+
* `git fetch` in a full clone moves `refs/remotes/<remote>/chant/lifecycle`
|
|
805
|
+
* and leaves the branch, so a write built on the branch would sit beside the
|
|
806
|
+
* records made elsewhere instead of after them. Nothing is fetched here, and a
|
|
807
|
+
* branch with commits the remote lacks is left for the push to replay. The
|
|
808
|
+
* move is a compare-and-swap, so a writer that moved the branch meanwhile is
|
|
809
|
+
* never undone, and a checked-out `chant/lifecycle` is left alone.
|
|
810
|
+
*/
|
|
811
|
+
async function catchUpLifecycle(cwd?: string): Promise<void> {
|
|
812
|
+
const rt = getRuntime();
|
|
813
|
+
const found = await ledgerRemote(cwd);
|
|
814
|
+
if (found === null || "failed" in found) return;
|
|
815
|
+
const fetched = await getRemoteLifecycleBranchSha(found.remote, { cwd });
|
|
816
|
+
if (!fetched) return;
|
|
817
|
+
const local = await getStateBranchTip(cwd);
|
|
818
|
+
if (!local || local === fetched) return;
|
|
819
|
+
if (!(await isAncestor(local, fetched, cwd))) return;
|
|
820
|
+
const head = await rt.spawn(["git", "symbolic-ref", "-q", "HEAD"], { cwd, env: C_LOCALE_ENV });
|
|
821
|
+
if (head.exitCode === 0 && head.stdout.trim() === `refs/heads/${STATE_BRANCH}`) return;
|
|
822
|
+
try {
|
|
823
|
+
await updateRefCAS(`refs/heads/${STATE_BRANCH}`, fetched, local, { cwd });
|
|
824
|
+
} catch (err) {
|
|
825
|
+
if (!(err instanceof RefCASConflictError)) throw err;
|
|
826
|
+
}
|
|
827
|
+
}
|
|
828
|
+
|
|
790
829
|
/**
|
|
791
830
|
* Point `refs/remotes/<remote>/chant/lifecycle` at `sha`, the remote tip this
|
|
792
831
|
* checkout has just seen (#3391).
|
|
@@ -830,6 +869,20 @@ export async function pushLifecycleStatus(opts?: { cwd?: string }): Promise<Life
|
|
|
830
869
|
const lease = `refs/heads/${STATE_BRANCH}:${expected ?? ""}`;
|
|
831
870
|
const tip = await getStateBranchTip(cwd);
|
|
832
871
|
|
|
872
|
+
// #4637: the lease only says the remote still holds `expected`. A plain
|
|
873
|
+
// `git fetch` moves that ref without moving the local branch, so a branch
|
|
874
|
+
// that does not contain it would pass the lease and push over every record
|
|
875
|
+
// made since (an approval from another clone). Refused as stale, so a
|
|
876
|
+
// rebasing caller replays its commits onto the remote's tip.
|
|
877
|
+
if (expected && tip && expected !== tip && !(await isAncestor(expected, tip, cwd))) {
|
|
878
|
+
return {
|
|
879
|
+
status: "stale",
|
|
880
|
+
remote,
|
|
881
|
+
expected,
|
|
882
|
+
stderr: `this checkout's ${STATE_BRANCH} does not contain ${expected.slice(0, 12)}, the tip it last fetched from "${remote}"; pushing it would drop the records made since`,
|
|
883
|
+
};
|
|
884
|
+
}
|
|
885
|
+
|
|
833
886
|
const pushResult = await rt.spawn(
|
|
834
887
|
["git", "push", `--force-with-lease=${lease}`, remote, `${STATE_BRANCH}:${STATE_BRANCH}`],
|
|
835
888
|
{ cwd, env: C_LOCALE_ENV },
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* #4637: two clones of one bare origin write to `chant/lifecycle`. An approval
|
|
3
|
+
* pushed from one clone survives every write the other makes afterwards.
|
|
4
|
+
*
|
|
5
|
+
* A plain `git fetch` in a full clone moves `refs/remotes/origin/chant/lifecycle`
|
|
6
|
+
* and leaves the local branch where it was. A write then built on the local
|
|
7
|
+
* branch, pushed with a lease on that ref, used to pass the lease and replace
|
|
8
|
+
* the remote's history with a branch missing the approval.
|
|
9
|
+
*/
|
|
10
|
+
import { afterEach, describe, expect, test } from "vitest";
|
|
11
|
+
import { execFileSync } from "node:child_process";
|
|
12
|
+
import { mkdtempSync, realpathSync, rmSync, writeFileSync } from "node:fs";
|
|
13
|
+
import { tmpdir } from "node:os";
|
|
14
|
+
import { join } from "node:path";
|
|
15
|
+
import { pushLifecycleRebasing, pushLifecycleStatus, writeBlobToPath } from "./git";
|
|
16
|
+
import { appendGateResolution } from "./gate-ledger";
|
|
17
|
+
import { appendRunRecord } from "./run-ledger";
|
|
18
|
+
import type { OpRunRecordInput } from "../op/runtime";
|
|
19
|
+
|
|
20
|
+
const dirs: string[] = [];
|
|
21
|
+
|
|
22
|
+
afterEach(() => {
|
|
23
|
+
for (const d of dirs.splice(0)) rmSync(d, { recursive: true, force: true });
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
function git(args: string[], cwd: string): string {
|
|
27
|
+
return execFileSync("git", args, { cwd, encoding: "utf8", env: { ...process.env, LC_ALL: "C" } }).trim();
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function tmp(name: string): string {
|
|
31
|
+
const dir = realpathSync(mkdtempSync(join(tmpdir(), `ledger-two-${name}-`)));
|
|
32
|
+
dirs.push(dir);
|
|
33
|
+
return dir;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function clone(origin: string, name: string): string {
|
|
37
|
+
const dir = tmp(name);
|
|
38
|
+
git(["clone", "-q", origin, dir], tmpdir());
|
|
39
|
+
git(["config", "user.email", `${name}@chant.dev`], dir);
|
|
40
|
+
git(["config", "user.name", name], dir);
|
|
41
|
+
return dir;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** A bare origin with `main` and a seeded `chant/lifecycle`, and two clones that both hold the seed locally. */
|
|
45
|
+
async function setup(): Promise<{ origin: string; a: string; b: string }> {
|
|
46
|
+
const origin = tmp("origin");
|
|
47
|
+
git(["init", "-q", "--bare", "-b", "main"], origin);
|
|
48
|
+
const a = clone(origin, "a");
|
|
49
|
+
writeFileSync(join(a, "README.md"), "fixture\n");
|
|
50
|
+
git(["add", "README.md"], a);
|
|
51
|
+
git(["commit", "-q", "-m", "init"], a);
|
|
52
|
+
git(["push", "-q", "origin", "main"], a);
|
|
53
|
+
await writeBlobToPath("prod", "seed.jsonl", '{"seed":true}\n', "seed", { cwd: a });
|
|
54
|
+
expect((await pushLifecycleStatus({ cwd: a })).status).toBe("pushed");
|
|
55
|
+
const b = clone(origin, "b");
|
|
56
|
+
git(["fetch", "-q", "origin", "chant/lifecycle:chant/lifecycle"], b);
|
|
57
|
+
return { origin, a, b };
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const approval = { op: "deploy", gate: "prod", resolvedBy: "github:alice", timestamp: "2026-11-07T10:00:00Z" };
|
|
61
|
+
|
|
62
|
+
function run(overrides: Partial<OpRunRecordInput> = {}): OpRunRecordInput {
|
|
63
|
+
return {
|
|
64
|
+
op: "deploy",
|
|
65
|
+
env: "prod",
|
|
66
|
+
started: "2026-11-07T10:01:00.000Z",
|
|
67
|
+
ended: "2026-11-07T10:02:00.000Z",
|
|
68
|
+
status: "ok",
|
|
69
|
+
labels: {},
|
|
70
|
+
outcomes: {},
|
|
71
|
+
phases: [],
|
|
72
|
+
...overrides,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/** A file on origin's `chant/lifecycle`, or "" when it has none. */
|
|
77
|
+
function onOrigin(origin: string, path: string): string {
|
|
78
|
+
try {
|
|
79
|
+
return execFileSync("git", ["--git-dir", origin, "show", `chant/lifecycle:${path}`], { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] });
|
|
80
|
+
} catch {
|
|
81
|
+
return "";
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
async function approveInA(a: string): Promise<void> {
|
|
86
|
+
await appendGateResolution(approval, { cwd: a });
|
|
87
|
+
expect((await pushLifecycleStatus({ cwd: a })).status).toBe("pushed");
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
describe("ledger writers in two clones of one origin (#4637)", () => {
|
|
91
|
+
test("a write after a plain fetch keeps the approval the other clone pushed", async () => {
|
|
92
|
+
const { origin, a, b } = await setup();
|
|
93
|
+
await approveInA(a);
|
|
94
|
+
|
|
95
|
+
// An ordinary fetch: the tracking ref moves, the local branch does not.
|
|
96
|
+
git(["fetch", "-q", "origin"], b);
|
|
97
|
+
await appendRunRecord(run(), { cwd: b });
|
|
98
|
+
await pushLifecycleRebasing({ cwd: b });
|
|
99
|
+
|
|
100
|
+
expect(onOrigin(origin, "_gates/deploy.jsonl")).toContain("github:alice");
|
|
101
|
+
expect(onOrigin(origin, "prod/runs__deploy.jsonl")).toContain('"status":"ok"');
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
test("a write committed before the fetch is replayed onto the approval, never pushed over it", async () => {
|
|
105
|
+
const { origin, a, b } = await setup();
|
|
106
|
+
await approveInA(a);
|
|
107
|
+
|
|
108
|
+
await appendRunRecord(run(), { cwd: b });
|
|
109
|
+
// The fetch lands after the commit, so the local branch no longer contains the lease.
|
|
110
|
+
git(["fetch", "-q", "origin"], b);
|
|
111
|
+
const status = await pushLifecycleStatus({ cwd: b });
|
|
112
|
+
expect(status.status).toBe("stale");
|
|
113
|
+
expect(onOrigin(origin, "_gates/deploy.jsonl")).toContain("github:alice");
|
|
114
|
+
|
|
115
|
+
expect(await pushLifecycleRebasing({ cwd: b })).toEqual({ pushed: true });
|
|
116
|
+
expect(onOrigin(origin, "_gates/deploy.jsonl")).toContain("github:alice");
|
|
117
|
+
expect(git(["--git-dir", origin, "log", "--format=%s", "chant/lifecycle"], b).split("\n")).toEqual(
|
|
118
|
+
expect.arrayContaining(["Gate resolution record", "Op run record: deploy"]),
|
|
119
|
+
);
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
test("a write with no fetch at all is refused as stale, then replayed onto the approval", async () => {
|
|
123
|
+
const { origin, a, b } = await setup();
|
|
124
|
+
await approveInA(a);
|
|
125
|
+
|
|
126
|
+
await appendRunRecord(run(), { cwd: b });
|
|
127
|
+
expect((await pushLifecycleStatus({ cwd: b })).status).toBe("stale");
|
|
128
|
+
expect(await pushLifecycleRebasing({ cwd: b })).toEqual({ pushed: true });
|
|
129
|
+
expect(onOrigin(origin, "_gates/deploy.jsonl")).toContain("github:alice");
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
|
|
@@ -69,6 +69,14 @@ export const NpmPublishSchema = z
|
|
|
69
69
|
* registry accepts a publish before it serves it. Unset, the wait ends
|
|
70
70
|
* only when every version is served or the registry fails (#4271).
|
|
71
71
|
*/
|
|
72
|
+
/**
|
|
73
|
+
* A file in the package, from its root, holding the image digests it pins
|
|
74
|
+
* (#4657), such as `dist/image-digests.json`. Every `sha256:` digest in it
|
|
75
|
+
* must be an image the release records, or the plan and `chant release
|
|
76
|
+
* verify` refuse the package. A package without the file is not checked,
|
|
77
|
+
* and a target none of whose packages has it is refused.
|
|
78
|
+
*/
|
|
79
|
+
pins: z.string().min(1).optional(),
|
|
72
80
|
registryWait: z.number().int().min(0).optional(),
|
|
73
81
|
})
|
|
74
82
|
.strict();
|
|
@@ -101,8 +109,31 @@ export const ForgePublishSchema = z
|
|
|
101
109
|
repo: z.string().min(1),
|
|
102
110
|
/** The API root: default `$GITHUB_API_URL` or `https://api.github.com` on GitHub, `$CI_API_V4_URL` or `https://gitlab.com/api/v4` on GitLab, `$GITHUB_API_URL` on Forgejo, which has no default. */
|
|
103
111
|
api: z.string().url().optional(),
|
|
104
|
-
/** Files to attach, relative to the member. */
|
|
105
|
-
assets: z.array(z.string().min(1))
|
|
112
|
+
/** Files to attach, relative to the member. May be empty when `notes` gives the release its body. */
|
|
113
|
+
assets: z.array(z.string().min(1)),
|
|
114
|
+
/**
|
|
115
|
+
* The release's notes (#4658): a section of a file in the member, sent as
|
|
116
|
+
* the release's body on GitHub and Forgejo and its description on GitLab.
|
|
117
|
+
*/
|
|
118
|
+
notes: z
|
|
119
|
+
.object({
|
|
120
|
+
/** The file, relative to the member, such as `CHANGELOG.md` or a docs site's changes page. */
|
|
121
|
+
file: z.string().min(1),
|
|
122
|
+
/**
|
|
123
|
+
* The heading that starts the section, such as `## In {version}` or `## [{version}]`. `{label}`, `{version}`
|
|
124
|
+
* (the label from its first digit) and `{tag}` are filled in. The section runs to the next heading of the same
|
|
125
|
+
* level or higher.
|
|
126
|
+
*/
|
|
127
|
+
heading: z.string().regex(/^#{1,6} \S/, "a markdown heading, such as ## {version}"),
|
|
128
|
+
/** Links that start with `/` are made absolute against this, such as `https://docs.example.com`. */
|
|
129
|
+
linkBase: z.string().url().optional(),
|
|
130
|
+
/** A paragraph before the section, with the same placeholders. */
|
|
131
|
+
before: z.string().min(1).optional(),
|
|
132
|
+
/** A paragraph after the section, with the same placeholders. */
|
|
133
|
+
after: z.string().min(1).optional(),
|
|
134
|
+
})
|
|
135
|
+
.strict()
|
|
136
|
+
.optional(),
|
|
106
137
|
/** The forge release's tag. Default: the tag the cut made, `release/<label>` or `release/<member>/<label>`. */
|
|
107
138
|
tag: z.string().min(1).optional(),
|
|
108
139
|
/** The variable holding the token. Default `GITHUB_TOKEN`, `GITLAB_TOKEN` (then `CI_JOB_TOKEN`), or `FORGEJO_TOKEN`. */
|
|
@@ -117,7 +148,8 @@ export const ForgePublishSchema = z
|
|
|
117
148
|
*/
|
|
118
149
|
latest: z.union([z.boolean(), z.literal("legacy")]).optional(),
|
|
119
150
|
})
|
|
120
|
-
.strict()
|
|
151
|
+
.strict()
|
|
152
|
+
.refine((d) => d.assets.length > 0 || d.notes !== undefined, { message: "a forge release needs assets, notes or both", path: ["assets"] });
|
|
121
153
|
|
|
122
154
|
/**
|
|
123
155
|
* A Homebrew formula in a tap repository on GitHub (#4676), rendered from a
|