@intentius/chant 0.124.87 → 0.124.88
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/action-pins.d.ts +1 -0
- package/dist/action-pins.d.ts.map +1 -1
- package/dist/action-pins.js +2 -0
- package/dist/actor.d.ts +12 -0
- package/dist/actor.d.ts.map +1 -0
- package/dist/actor.js +18 -0
- package/dist/bundle-check.d.ts +20 -5
- package/dist/bundle-check.d.ts.map +1 -1
- package/dist/bundle-check.js +20 -5
- package/dist/chant-install.d.ts +98 -0
- package/dist/chant-install.d.ts.map +1 -1
- package/dist/chant-install.js +204 -2
- package/dist/ci-commit.d.ts +1 -1
- package/dist/ci-commit.d.ts.map +1 -1
- package/dist/ci-commit.js +1 -2
- package/dist/ci-control.d.ts +1 -1
- package/dist/ci-control.d.ts.map +1 -1
- package/dist/ci-control.js +1 -1
- package/dist/ci-evidence-claims.d.ts +59 -0
- package/dist/ci-evidence-claims.d.ts.map +1 -0
- package/dist/ci-evidence-claims.js +87 -0
- package/dist/ci-evidence-from-job.d.ts +103 -0
- package/dist/ci-evidence-from-job.d.ts.map +1 -0
- package/dist/ci-evidence-from-job.js +162 -0
- package/dist/ci-evidence-jobs.d.ts +39 -4
- package/dist/ci-evidence-jobs.d.ts.map +1 -1
- package/dist/ci-evidence-jobs.js +38 -4
- package/dist/ci-handover.d.ts +12 -0
- package/dist/ci-handover.d.ts.map +1 -1
- package/dist/ci-handover.js +15 -3
- package/dist/ci-identity.d.ts +32 -6
- package/dist/ci-identity.d.ts.map +1 -1
- package/dist/ci-identity.js +40 -8
- package/dist/ci-image.d.ts +47 -9
- package/dist/ci-image.d.ts.map +1 -1
- package/dist/ci-image.js +45 -18
- package/dist/ci-jobs.d.ts +1 -1
- package/dist/ci-jobs.d.ts.map +1 -1
- package/dist/ci-jobs.js +7 -2
- package/dist/ci-login.d.ts +75 -13
- package/dist/ci-login.d.ts.map +1 -1
- package/dist/ci-login.js +89 -37
- package/dist/ci-product-words.d.ts +20 -1
- package/dist/ci-product-words.d.ts.map +1 -1
- package/dist/ci-product-words.js +27 -1
- package/dist/ci-product.d.ts +21 -2
- package/dist/ci-product.d.ts.map +1 -1
- package/dist/ci-product.js +21 -2
- package/dist/cli/handlers/approve-confirm.d.ts +14 -0
- package/dist/cli/handlers/approve-confirm.d.ts.map +1 -1
- package/dist/cli/handlers/approve-confirm.js +46 -0
- package/dist/cli/handlers/build.d.ts +1 -1
- package/dist/cli/handlers/build.d.ts.map +1 -1
- package/dist/cli/handlers/build.js +22 -1
- package/dist/cli/handlers/ci-check.d.ts.map +1 -1
- package/dist/cli/handlers/ci-check.js +21 -1
- package/dist/cli/handlers/ci-evidence.d.ts.map +1 -1
- package/dist/cli/handlers/ci-evidence.js +227 -18
- package/dist/cli/handlers/ci-forge-check.d.ts.map +1 -1
- package/dist/cli/handlers/ci-forge-check.js +34 -17
- package/dist/cli/handlers/generated-check.d.ts +3 -0
- package/dist/cli/handlers/generated-check.d.ts.map +1 -0
- package/dist/cli/handlers/generated-check.js +41 -0
- package/dist/cli/handlers/lifecycle.d.ts.map +1 -1
- package/dist/cli/handlers/lifecycle.js +3 -0
- package/dist/cli/handlers/local-chant.d.ts +13 -0
- package/dist/cli/handlers/local-chant.d.ts.map +1 -1
- package/dist/cli/handlers/local-chant.js +42 -1
- package/dist/cli/handlers/pr.d.ts.map +1 -1
- package/dist/cli/handlers/pr.js +42 -5
- package/dist/cli/handlers/run-wave.js +8 -0
- package/dist/cli/main.d.ts.map +1 -1
- package/dist/cli/main.js +38 -4
- package/dist/cli/parse-args.d.ts.map +1 -1
- package/dist/cli/parse-args.js +66 -0
- package/dist/cli/registry.d.ts +24 -0
- package/dist/cli/registry.d.ts.map +1 -1
- package/dist/components/check-hooks.d.ts +10 -0
- package/dist/components/check-hooks.d.ts.map +1 -1
- package/dist/components/check-hooks.js +18 -0
- package/dist/components/pr-checks.d.ts +105 -0
- package/dist/components/pr-checks.d.ts.map +1 -0
- package/dist/components/pr-checks.js +119 -0
- package/dist/components/pr-pipeline.d.ts +34 -0
- package/dist/components/pr-pipeline.d.ts.map +1 -1
- package/dist/components/pr-pipeline.js +14 -1
- package/dist/components/product-pipeline.d.ts +16 -1
- package/dist/components/product-pipeline.d.ts.map +1 -1
- package/dist/components/product-pipeline.js +17 -2
- package/dist/components/product-plan.d.ts +257 -4
- package/dist/components/product-plan.d.ts.map +1 -1
- package/dist/components/product-plan.js +241 -11
- package/dist/config.d.ts +10 -6
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +11 -6
- package/dist/control/consumers.d.ts +6 -0
- package/dist/control/consumers.d.ts.map +1 -1
- package/dist/control/consumers.js +6 -0
- package/dist/dead-guards.d.ts.map +1 -1
- package/dist/dead-guards.js +9 -6
- package/dist/discovery/files.d.ts +1 -1
- package/dist/discovery/files.js +1 -1
- package/dist/drift-issue.d.ts +20 -3
- package/dist/drift-issue.d.ts.map +1 -1
- package/dist/drift-issue.js +16 -0
- package/dist/drift-record.d.ts +45 -5
- package/dist/drift-record.d.ts.map +1 -1
- package/dist/drift-record.js +27 -6
- package/dist/floor-table.d.ts +6 -6
- package/dist/floor-table.d.ts.map +1 -1
- package/dist/floor-table.data.d.ts.map +1 -1
- package/dist/floor-table.data.js +58 -21
- package/dist/floor-table.js +10 -7
- package/dist/forge-check/contract.d.ts +8 -0
- package/dist/forge-check/contract.d.ts.map +1 -1
- package/dist/forge-check/contract.js +4 -1
- package/dist/forge-check/index.d.ts +2 -0
- package/dist/forge-check/index.d.ts.map +1 -1
- package/dist/forge-check/index.js +2 -0
- package/dist/forge-flags.d.ts +10 -0
- package/dist/forge-flags.d.ts.map +1 -1
- package/dist/forge-flags.js +31 -0
- package/dist/forge-remote.d.ts +47 -0
- package/dist/forge-remote.d.ts.map +1 -0
- package/dist/forge-remote.js +69 -0
- package/dist/generated-check.d.ts +74 -0
- package/dist/generated-check.d.ts.map +1 -0
- package/dist/generated-check.js +216 -0
- package/dist/lexicon.d.ts +16 -0
- package/dist/lexicon.d.ts.map +1 -1
- 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 +49 -3
- package/dist/lifecycle/release-images.d.ts +22 -1
- package/dist/lifecycle/release-images.d.ts.map +1 -1
- package/dist/lifecycle/release-images.js +27 -3
- package/dist/lifecycle/release-ledger.d.ts +4 -3
- package/dist/lifecycle/release-ledger.d.ts.map +1 -1
- package/dist/lifecycle/release-ledger.js +3 -2
- package/dist/local-chant.d.ts +57 -3
- package/dist/local-chant.d.ts.map +1 -1
- package/dist/local-chant.js +122 -13
- package/dist/op/op-waves-evidence-jobs.d.ts +92 -0
- package/dist/op/op-waves-evidence-jobs.d.ts.map +1 -0
- package/dist/op/op-waves-evidence-jobs.js +112 -0
- package/dist/op/op-waves-evidence.d.ts +12 -1
- package/dist/op/op-waves-evidence.d.ts.map +1 -1
- package/dist/op/op-waves-evidence.js +23 -2
- package/dist/op/op-waves-run.d.ts +12 -1
- package/dist/op/op-waves-run.d.ts.map +1 -1
- package/dist/op/op-waves-run.js +54 -3
- package/dist/op/op-waves.d.ts +8 -0
- package/dist/op/op-waves.d.ts.map +1 -1
- package/dist/op/op-waves.js +10 -0
- package/dist/op/schedule-overdue.d.ts +39 -2
- package/dist/op/schedule-overdue.d.ts.map +1 -1
- package/dist/op/schedule-overdue.js +89 -7
- package/dist/pr-forge-reads.d.ts +21 -1
- package/dist/pr-forge-reads.d.ts.map +1 -1
- package/dist/pr-forge-reads.js +19 -1
- package/dist/pr-forge.d.ts +7 -1
- package/dist/pr-forge.d.ts.map +1 -1
- package/dist/pr-forge.js +7 -2
- package/dist/pr-plan-note.d.ts +24 -0
- package/dist/pr-plan-note.d.ts.map +1 -1
- package/dist/pr-plan-note.js +11 -1
- package/dist/pr-plan-record.d.ts +47 -0
- package/dist/pr-plan-record.d.ts.map +1 -0
- package/dist/pr-plan-record.js +89 -0
- package/dist/pr-post.d.ts +40 -0
- package/dist/pr-post.d.ts.map +1 -1
- package/dist/pr-post.js +79 -6
- package/dist/pr-requires.d.ts +8 -0
- package/dist/pr-requires.d.ts.map +1 -1
- package/dist/pr-requires.js +3 -1
- package/dist/ref-gate-init.d.ts +76 -0
- package/dist/ref-gate-init.d.ts.map +1 -0
- package/dist/ref-gate-init.js +144 -0
- package/dist/ref-gate-rules.d.ts +19 -0
- package/dist/ref-gate-rules.d.ts.map +1 -0
- package/dist/ref-gate-rules.js +17 -0
- package/dist/release-floors.d.ts +64 -16
- package/dist/release-floors.d.ts.map +1 -1
- package/dist/release-floors.js +65 -17
- package/dist/state-migration.d.ts +24 -1
- package/dist/state-migration.d.ts.map +1 -1
- package/dist/state-migration.js +39 -3
- package/dist/state-unlock.d.ts +32 -1
- package/dist/state-unlock.d.ts.map +1 -1
- package/dist/state-unlock.js +31 -0
- package/dist/wave-runtime.mjs +292 -285
- package/dist/workspace/ci-green-cli.d.ts.map +1 -1
- package/dist/workspace/ci-green-cli.js +13 -7
- package/dist/workspace/drift-cli.d.ts +1 -1
- package/dist/workspace/drift-cli.d.ts.map +1 -1
- package/dist/workspace/drift-cli.js +5 -12
- package/dist/workspace/forge-work.d.ts +3 -2
- package/dist/workspace/forge-work.d.ts.map +1 -1
- package/dist/workspace/forge-work.js +7 -17
- package/dist/workspace/lexicon-outputs.js +2 -2
- package/dist/workspace/release-workflow.d.ts +26 -3
- package/dist/workspace/release-workflow.d.ts.map +1 -1
- package/dist/workspace/release-workflow.js +48 -6
- package/dist/workspace/trust/check-evidence-report.d.ts +18 -0
- package/dist/workspace/trust/check-evidence-report.d.ts.map +1 -1
- package/dist/workspace/trust/check-evidence-report.js +13 -0
- package/dist/workspace/trust/check-evidence.d.ts +13 -1
- package/dist/workspace/trust/check-evidence.d.ts.map +1 -1
- package/dist/workspace/trust/check-evidence.js +8 -3
- package/dist/workspace/trust/evidence.d.ts +5 -0
- package/dist/workspace/trust/evidence.d.ts.map +1 -1
- package/dist/workspace/trust/evidence.js +5 -0
- package/dist/workspace/trust/open-evidence.d.ts +67 -0
- package/dist/workspace/trust/open-evidence.d.ts.map +1 -0
- package/dist/workspace/trust/open-evidence.js +92 -0
- package/dist/workspace/trust/ref-gate-cli.d.ts.map +1 -1
- package/dist/workspace/trust/ref-gate-cli.js +65 -3
- package/dist/workspace/trust/ref-gate.d.ts +61 -2
- package/dist/workspace/trust/ref-gate.d.ts.map +1 -1
- package/dist/workspace/trust/ref-gate.js +72 -7
- package/package.json +1 -1
- package/src/action-pins.ts +2 -0
- package/src/actor.test.ts +12 -0
- package/src/actor.ts +19 -0
- package/src/bundle-check.test.ts +22 -0
- package/src/bundle-check.ts +33 -5
- package/src/chant-install.test.ts +109 -1
- package/src/chant-install.ts +243 -2
- package/src/ci-commit.test.ts +51 -5
- package/src/ci-commit.ts +1 -2
- package/src/ci-control.ts +1 -0
- package/src/ci-evidence-claims.ts +102 -0
- package/src/ci-evidence-from-job.test.ts +147 -0
- package/src/ci-evidence-from-job.ts +195 -0
- package/src/ci-evidence-jobs.ts +41 -4
- package/src/ci-handover.ts +16 -3
- package/src/ci-identity.test.ts +3 -3
- package/src/ci-identity.ts +51 -11
- package/src/ci-image.test.ts +60 -10
- package/src/ci-image.ts +78 -19
- package/src/ci-jobs.ts +7 -2
- package/src/ci-login.test.ts +131 -3
- package/src/ci-login.token-drop.test.ts +204 -0
- package/src/ci-login.ts +137 -39
- package/src/ci-product-words.ts +30 -0
- package/src/ci-product.ts +26 -1
- package/src/cli/commands/__fixtures__/source-dir-root/migrations/0001-init/backfill.ts +3 -0
- package/src/cli/handlers/approve-confirm.test.ts +35 -0
- package/src/cli/handlers/approve-confirm.ts +44 -0
- package/src/cli/handlers/build-source-dir.test.ts +4 -0
- package/src/cli/handlers/build.ts +20 -2
- package/src/cli/handlers/ci-check.ts +19 -1
- package/src/cli/handlers/ci-evidence-open.test.ts +164 -0
- package/src/cli/handlers/ci-evidence.ts +210 -16
- package/src/cli/handlers/ci-forge-check.ts +22 -9
- package/src/cli/handlers/generated-check.ts +39 -0
- package/src/cli/handlers/lifecycle.test.ts +20 -0
- package/src/cli/handlers/lifecycle.ts +4 -0
- package/src/cli/handlers/local-chant.ts +39 -1
- package/src/cli/handlers/pr.ts +43 -5
- package/src/cli/handlers/run-wave.ts +7 -0
- package/src/cli/main.ts +38 -4
- package/src/cli/parse-args.ts +46 -0
- package/src/cli/registry.ts +24 -0
- package/src/components/check-hooks.ts +22 -0
- package/src/components/check-report-summary.test.ts +78 -0
- package/src/components/pr-checks.ts +159 -0
- package/src/components/pr-pipeline.ts +41 -1
- package/src/components/product-pipeline.ts +25 -3
- package/src/components/product-plan.test.ts +102 -1
- package/src/components/product-plan.ts +416 -15
- package/src/config.ts +13 -8
- package/src/control/consumers.ts +7 -0
- package/src/dead-guards.test.ts +27 -5
- package/src/dead-guards.ts +9 -6
- package/src/discovery/files.ts +1 -1
- package/src/drift-issue.test.ts +29 -1
- package/src/drift-issue.ts +28 -3
- package/src/drift-record.test.ts +25 -0
- package/src/drift-record.ts +55 -6
- package/src/floor-table.data.ts +58 -21
- package/src/floor-table.ts +12 -9
- package/src/forge-check/contract.ts +11 -1
- package/src/forge-check/forge-check.test.ts +8 -0
- package/src/forge-check/index.ts +2 -0
- package/src/forge-flags.test.ts +25 -1
- package/src/forge-flags.ts +34 -0
- package/src/forge-remote.test.ts +37 -0
- package/src/forge-remote.ts +79 -0
- package/src/generated-check.e2e.test.ts +98 -0
- package/src/generated-check.test.ts +104 -0
- package/src/generated-check.ts +269 -0
- package/src/lexicon.ts +17 -0
- package/src/lifecycle/publish-npm.ts +56 -3
- package/src/lifecycle/release-catalog.test.ts +2 -2
- package/src/lifecycle/release-images-dockerfile.test.ts +20 -0
- package/src/lifecycle/release-images.test.ts +44 -0
- package/src/lifecycle/release-images.ts +39 -3
- package/src/lifecycle/release-ledger.ts +4 -3
- package/src/local-chant.e2e.test.ts +81 -6
- package/src/local-chant.test.ts +22 -3
- package/src/local-chant.ts +130 -13
- package/src/op/op-waves-evidence-jobs.ts +134 -0
- package/src/op/op-waves-evidence.test.ts +36 -3
- package/src/op/op-waves-evidence.ts +23 -3
- package/src/op/op-waves-run.ts +57 -2
- package/src/op/op-waves.ts +11 -0
- package/src/op/schedule-overdue.test.ts +83 -1
- package/src/op/schedule-overdue.ts +107 -9
- package/src/pr-forge-reads-compare.test.ts +2 -1
- package/src/pr-forge-reads.ts +37 -1
- package/src/pr-forge.ts +14 -3
- package/src/pr-plan-note.ts +32 -3
- package/src/pr-plan-record.test.ts +75 -0
- package/src/pr-plan-record.ts +101 -0
- package/src/pr-post-plan-note.test.ts +60 -0
- package/src/pr-post.test.ts +30 -0
- package/src/pr-post.ts +110 -6
- package/src/pr-requires.test.ts +20 -0
- package/src/pr-requires.ts +10 -1
- package/src/ref-gate-init.ts +189 -0
- package/src/ref-gate-rules.ts +26 -0
- package/src/release-floors.ts +86 -17
- package/src/state-migration-record.test.ts +90 -0
- package/src/state-migration.test.ts +1 -1
- package/src/state-migration.ts +52 -3
- package/src/state-unlock.test.ts +33 -1
- package/src/state-unlock.ts +49 -1
- package/src/workspace/ci-green-cli.ts +12 -6
- package/src/workspace/drift-cli.ts +6 -18
- package/src/workspace/forge-work.ts +7 -14
- package/src/workspace/lexicon-outputs.ts +2 -2
- package/src/workspace/release-workflow.test.ts +70 -0
- package/src/workspace/release-workflow.ts +56 -8
- package/src/workspace/trust/check-evidence-report.ts +24 -0
- package/src/workspace/trust/check-evidence.ts +17 -5
- package/src/workspace/trust/evidence.ts +5 -0
- package/src/workspace/trust/open-evidence.ts +129 -0
- package/src/workspace/trust/ref-gate-cli.ts +59 -3
- package/src/workspace/trust/ref-gate-pieces.test.ts +175 -0
- package/src/workspace/trust/ref-gate.e2e.test.ts +17 -0
- package/src/workspace/trust/ref-gate.ts +87 -6
|
@@ -14,6 +14,8 @@ import { composeChangeSet, lifecyclePlanPart, type ChangeSetDocument } from "../
|
|
|
14
14
|
import type { ChangeSet as LifecycleChangeSet } from "../../lifecycle/change-set";
|
|
15
15
|
import { persistChangeSet } from "../../lifecycle/change-set-store";
|
|
16
16
|
import { appendPendingGate, readGateLedger } from "../../lifecycle/gate-ledger";
|
|
17
|
+
import { gatedRequestAttachmentPath } from "../../lifecycle/gated-request-digest";
|
|
18
|
+
import { writeBlobToPath } from "../../lifecycle/git";
|
|
17
19
|
import { resetGateOrigin } from "../../lifecycle/gate-origin";
|
|
18
20
|
import { CHANT_EXIT } from "../../exit-codes";
|
|
19
21
|
import type { ParsedArgs } from "../registry";
|
|
@@ -203,6 +205,39 @@ describe("confirmApproval (#4575)", () => {
|
|
|
203
205
|
});
|
|
204
206
|
});
|
|
205
207
|
|
|
208
|
+
describe("confirmApproval on a gated request's attachment (#4928)", () => {
|
|
209
|
+
const cwd = process.cwd();
|
|
210
|
+
afterEach(() => {
|
|
211
|
+
process.chdir(cwd);
|
|
212
|
+
resetGateOrigin();
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
test("a migration's request shows its roots and the product's record, which its digest binds", async () => {
|
|
216
|
+
await withTestDir(async (dir) => {
|
|
217
|
+
git(["init", "-q", "-b", "main"], dir);
|
|
218
|
+
git(["config", "user.email", "t@chant.dev"], dir);
|
|
219
|
+
git(["config", "user.name", "T"], dir);
|
|
220
|
+
writeFileSync(join(dir, "README.md"), "x\n");
|
|
221
|
+
git(["add", "."], dir);
|
|
222
|
+
git(["commit", "-q", "-m", "init"], dir);
|
|
223
|
+
const digest = `sha256:${"a".repeat(64)}`;
|
|
224
|
+
const attachment = `${JSON.stringify({ name: "move-queues", roots: [{ root: "queues", location: "s3://acme/queues.tfstate" }], record: { moves: [{ addresses: ["aws_sqs_queue.jobs"], from: "platform", to: "queues" }], stamps: [] } })}\n`;
|
|
225
|
+
const { dir: at, file } = gatedRequestAttachmentPath("tf-migrate", digest);
|
|
226
|
+
await writeBlobToPath(at, file, attachment, "Request migrate on move-queues", { cwd: dir });
|
|
227
|
+
await appendPendingGate({ op: "tf-migrate", gate: "move-queues", timestamp: "2026-11-09T00:00:00.000Z", expiresAt: "2999-01-01T00:00:00.000Z", planDigest: digest, description: "migration move-queues: queues" }, { cwd: dir });
|
|
228
|
+
process.chdir(dir);
|
|
229
|
+
let shown = "";
|
|
230
|
+
let said = "";
|
|
231
|
+
const c = await confirmApproval("tf-migrate", "move-queues", { cwd: dir, out: (t) => (shown += t), err: (t) => (said += t), ask: async () => "move-queues" });
|
|
232
|
+
expect(c).toEqual({ status: "confirmed", plan: digest, target: "move-queues" });
|
|
233
|
+
expect(shown).toContain(`The request binds _gates/tf-migrate/requests/sha256_${"a".repeat(64)}.json`);
|
|
234
|
+
expect(shown).toContain('"aws_sqs_queue.jobs"');
|
|
235
|
+
expect(shown).toContain('"record"');
|
|
236
|
+
expect(said).not.toContain("No plan is stored");
|
|
237
|
+
});
|
|
238
|
+
});
|
|
239
|
+
});
|
|
240
|
+
|
|
206
241
|
describe("chant approve with a faked terminal (#4575)", () => {
|
|
207
242
|
const cwd = process.cwd();
|
|
208
243
|
const stdinTTY = Object.getOwnPropertyDescriptor(process.stdin, "isTTY");
|
|
@@ -24,6 +24,14 @@ import type { ParsedArgs } from "../registry";
|
|
|
24
24
|
import type { PendingGateRecord } from "../../lifecycle/gate-ledger";
|
|
25
25
|
import { CHANT_EXIT } from "../../exit-codes";
|
|
26
26
|
|
|
27
|
+
/**
|
|
28
|
+
* The first chant with `confirmApproval` here, the type-the-name
|
|
29
|
+
* confirmation a product's approve word asks through (#4575). #4916
|
|
30
|
+
* declared it after the fact, so `chant dev dead-guards` sees a product's
|
|
31
|
+
* lazy load of this subpath.
|
|
32
|
+
*/
|
|
33
|
+
export const APPROVE_CONFIRM_FLOOR = "0.124.55";
|
|
34
|
+
|
|
27
35
|
/** The streams the terminal check reads. `process` in the CLI; tests pass their own. */
|
|
28
36
|
export interface ApprovalTerminal {
|
|
29
37
|
stdin: { isTTY?: boolean };
|
|
@@ -167,6 +175,8 @@ export async function confirmApproval(opName: string, gate: string, opts: Confir
|
|
|
167
175
|
err(`The stored plan can't be read: ${e instanceof Error ? e.message : String(e)}\n`);
|
|
168
176
|
}
|
|
169
177
|
}
|
|
178
|
+
// #4928: a gated request's attachment (a state migration's roots and the product's record) is what its digest binds; show it.
|
|
179
|
+
if (!shown) shown = await showAttachment(opName, digest, cwd, out, err);
|
|
170
180
|
if (!shown) {
|
|
171
181
|
err(
|
|
172
182
|
`No plan is stored on chant/lifecycle under ${changeSet}. The run that stopped at the gate printed it; ` +
|
|
@@ -198,3 +208,37 @@ export async function confirmApproval(opName: string, gate: string, opts: Confir
|
|
|
198
208
|
}
|
|
199
209
|
return { status: "confirmed", plan: digest, target };
|
|
200
210
|
}
|
|
211
|
+
|
|
212
|
+
/** The most of an attachment `chant approve` prints before it says where the rest is (#4928). */
|
|
213
|
+
const ATTACHMENT_SHOWN_BYTES = 64 * 1024;
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* Print the attachment a gated request stored under `digest` (#4928), such
|
|
217
|
+
* as a state migration's roots and the product's record. JSON is printed
|
|
218
|
+
* indented, anything else as stored, and either is cut at
|
|
219
|
+
* {@link ATTACHMENT_SHOWN_BYTES} with the path of the whole. False when none is stored.
|
|
220
|
+
*/
|
|
221
|
+
export async function showAttachment(op: string, digest: string, cwd: string, out: (text: string) => void, err: (text: string) => void): Promise<boolean> {
|
|
222
|
+
const { gatedRequestAttachmentPath } = await import("../../lifecycle/gated-request-digest");
|
|
223
|
+
const { readBlobFromPath } = await import("../../lifecycle/git");
|
|
224
|
+
const { dir, file } = gatedRequestAttachmentPath(op, digest);
|
|
225
|
+
let text: string | null;
|
|
226
|
+
try {
|
|
227
|
+
text = await readBlobFromPath(dir, file, { cwd });
|
|
228
|
+
} catch (e) {
|
|
229
|
+
err(`The request's attachment can't be read: ${e instanceof Error ? e.message : String(e)}\n`);
|
|
230
|
+
return false;
|
|
231
|
+
}
|
|
232
|
+
if (text === null) return false;
|
|
233
|
+
let shown = text;
|
|
234
|
+
try {
|
|
235
|
+
shown = `${JSON.stringify(JSON.parse(text), null, 2)}\n`;
|
|
236
|
+
} catch {
|
|
237
|
+
// Not JSON: shown as stored.
|
|
238
|
+
}
|
|
239
|
+
const cut = Buffer.byteLength(shown, "utf8") > ATTACHMENT_SHOWN_BYTES;
|
|
240
|
+
out(`The request binds ${dir}/${file}:\n`);
|
|
241
|
+
out(cut ? `${Buffer.from(shown, "utf8").subarray(0, ATTACHMENT_SHOWN_BYTES).toString("utf8")}\n...\n` : shown);
|
|
242
|
+
if (cut) err(`The attachment is longer than ${ATTACHMENT_SHOWN_BYTES} bytes; the whole is at ${dir}/${file} on chant/lifecycle.\n`);
|
|
243
|
+
return true;
|
|
244
|
+
}
|
|
@@ -38,6 +38,10 @@ describe("a root build (#4794)", () => {
|
|
|
38
38
|
expect(await loaded(root, root)).toEqual(["infra.ts"]);
|
|
39
39
|
});
|
|
40
40
|
|
|
41
|
+
test("nor its top-level migrations/, whose backfill scripts run on load (#4921)", async () => {
|
|
42
|
+
expect((await findInfraFiles(root)).map((f) => relative(root, f).split("\\").join("/"))).toEqual(["infra.ts"]);
|
|
43
|
+
});
|
|
44
|
+
|
|
41
45
|
test("include brings scripts/ back", async () => {
|
|
42
46
|
expect((await findInfraFiles(include)).map((f) => relative(include, f).split("\\").join("/")).sort()).toEqual(["infra.ts", "scripts/run-on-load.ts"]);
|
|
43
47
|
});
|
|
@@ -65,7 +65,11 @@ async function engineSetupFor(path: string): Promise<string[]> {
|
|
|
65
65
|
* `--merge auto --merge-token-env <VAR> [--merge-method <m>]` (#4636) merges
|
|
66
66
|
* the pull request after its update before merge. `--respond <list>`,
|
|
67
67
|
* `--decide-backend` and `--decide-model` (#4629) set the apply and note
|
|
68
|
-
* jobs' responses and the description check's service.
|
|
68
|
+
* jobs' responses and the description check's service.
|
|
69
|
+
* `--evidence-runner-key-secret <NAME>`, or `--evidence-identity oidc` with
|
|
70
|
+
* `--evidence-audience` (#4935), give the loop its runner identity: the note
|
|
71
|
+
* job signs `plan` and `policy`. `--check-job` and `--ref-gate-status`
|
|
72
|
+
* (#4935) write the check job and the ref gate's status job. {@link prLoopFlagsProblem}
|
|
69
73
|
* has checked all of them first.
|
|
70
74
|
*/
|
|
71
75
|
function prLoopOption(args: CommandContext["args"], reportUrl: string | undefined, requireReview = false, requireRunnerStart = false): PrLoopPipelineOptions {
|
|
@@ -105,6 +109,11 @@ function prLoopOption(args: CommandContext["args"], reportUrl: string | undefine
|
|
|
105
109
|
// #4629: the responses on the apply and note jobs, and the description check's service.
|
|
106
110
|
...(respond && Object.keys(respond).length > 0 ? { respond } : {}),
|
|
107
111
|
...(args.decideBackend && args.decideModel ? { decide: { backend: args.decideBackend, model: args.decideModel } } : {}),
|
|
112
|
+
// #4935: the runner identity the note job signs with, the check job and the ref gate's status job.
|
|
113
|
+
...(args.evidenceRunnerKeySecret ? { evidence: { runnerKeySecret: args.evidenceRunnerKeySecret } } : {}),
|
|
114
|
+
...(args.evidenceIdentity === "oidc" ? { evidence: { identity: "oidc" as const, ...(args.evidenceAudience ? { audience: args.evidenceAudience } : {}) } } : {}),
|
|
115
|
+
...(args.checkJob ? { checkJob: true } : {}),
|
|
116
|
+
...(args.refGateStatus ? { refGateStatus: true } : {}),
|
|
108
117
|
};
|
|
109
118
|
}
|
|
110
119
|
|
|
@@ -114,8 +123,13 @@ function prLoopOption(args: CommandContext["args"], reportUrl: string | undefine
|
|
|
114
123
|
* they do. Each value is refused by name, as `pr-apply` and `pr-post` refuse
|
|
115
124
|
* it, so a build never writes a job that fails on its own line.
|
|
116
125
|
*/
|
|
117
|
-
export function prLoopFlagsProblem(args: Pick<CommandContext["args"], "prLoop" | "applyBeforeMerge" | "merge" | "mergeTokenEnv" | "mergeMethod" | "respond" | "decideBackend" | "decideModel" | "targetDependents"> & Partial<Pick<CommandContext["args"], "controlRepo" | "controlSettings">>): string | undefined {
|
|
126
|
+
export function prLoopFlagsProblem(args: Pick<CommandContext["args"], "prLoop" | "applyBeforeMerge" | "merge" | "mergeTokenEnv" | "mergeMethod" | "respond" | "decideBackend" | "decideModel" | "targetDependents"> & Partial<Pick<CommandContext["args"], "controlRepo" | "controlSettings" | "evidenceRunnerKeySecret" | "evidenceIdentity" | "evidenceAudience" | "checkJob" | "refGateStatus">>): string | undefined {
|
|
118
127
|
const given = [
|
|
128
|
+
...(args.evidenceRunnerKeySecret !== undefined ? ["--evidence-runner-key-secret"] : []),
|
|
129
|
+
...(args.evidenceIdentity !== undefined ? ["--evidence-identity"] : []),
|
|
130
|
+
...(args.evidenceAudience !== undefined ? ["--evidence-audience"] : []),
|
|
131
|
+
...(args.checkJob ? ["--check-job"] : []),
|
|
132
|
+
...(args.refGateStatus ? ["--ref-gate-status"] : []),
|
|
119
133
|
...(args.controlRepo !== undefined ? ["--control"] : []),
|
|
120
134
|
...(args.controlSettings !== undefined ? ["--control-setting"] : []),
|
|
121
135
|
...(args.merge !== undefined ? ["--merge"] : []),
|
|
@@ -140,6 +154,10 @@ export function prLoopFlagsProblem(args: Pick<CommandContext["args"], "prLoop" |
|
|
|
140
154
|
if (args.mergeMethod !== undefined && !(PR_MERGE_METHODS as readonly string[]).includes(args.mergeMethod)) return `--merge-method takes ${PR_MERGE_METHODS.join(", ")}, not ${args.mergeMethod}`;
|
|
141
155
|
}
|
|
142
156
|
if (args.controlSettings !== undefined && args.controlRepo === undefined) return "--control-setting sets the control repo's settings, so it needs --control <repo>";
|
|
157
|
+
// #4935: one runner identity, as PipelineEvidence takes it.
|
|
158
|
+
if (args.evidenceRunnerKeySecret !== undefined && args.evidenceIdentity !== undefined) return "--evidence-runner-key-secret and --evidence-identity each name the runner identity the jobs sign with; give one of them";
|
|
159
|
+
if (args.evidenceAudience !== undefined && args.evidenceIdentity === undefined) return "--evidence-audience is the keyless signing token's audience, so it goes with --evidence-identity oidc";
|
|
160
|
+
if (args.evidenceRunnerKeySecret !== undefined && !/^[A-Za-z_][A-Za-z0-9_]*$/.test(args.evidenceRunnerKeySecret)) return `--evidence-runner-key-secret takes a secret name of letters, digits and _, not ${args.evidenceRunnerKeySecret}`;
|
|
143
161
|
const respond = args.respond ? parseRespondList(args.respond) : {};
|
|
144
162
|
if ("error" in respond) return respond.error;
|
|
145
163
|
const check = respond.description === "check";
|
|
@@ -20,6 +20,10 @@
|
|
|
20
20
|
* is signed as local evidence instead, under `refs/notes/chant/local-evidence`.
|
|
21
21
|
* Without one, a hook whose check `local.checks` at base names is skipped
|
|
22
22
|
* when current local evidence for the tree stands in for it; the rest run.
|
|
23
|
+
*
|
|
24
|
+
* #4914: `--summary <file>` appends the report's markdown section
|
|
25
|
+
* (`checkReportSummary`) to the file, as a product's check report keeps it,
|
|
26
|
+
* and a job with `GITHUB_STEP_SUMMARY` set gets it in its summary too.
|
|
23
27
|
*/
|
|
24
28
|
import { resolve } from "node:path";
|
|
25
29
|
import type { CheckStageEvidence, CheckStepsAdapter } from "../../components/check-steps";
|
|
@@ -45,7 +49,7 @@ async function lexiconCheckSteps(ctx: CommandContext, cwd: string): Promise<Chec
|
|
|
45
49
|
return plugins.map((p) => p.checkSteps?.()).filter((a): a is CheckStepsAdapter => a !== undefined);
|
|
46
50
|
}
|
|
47
51
|
|
|
48
|
-
const USAGE = "chant ci check --base <rev> [<target>...] [--output <dir>] [--no-push] [--json]";
|
|
52
|
+
const USAGE = "chant ci check --base <rev> [<target>...] [--output <dir>] [--summary <file>] [--no-push] [--json]";
|
|
49
53
|
|
|
50
54
|
/**
|
|
51
55
|
* The check stage's signer (#4870), when the job has a runner identity: a
|
|
@@ -106,6 +110,20 @@ export async function runCiCheck(ctx: CommandContext): Promise<number> {
|
|
|
106
110
|
console.error(formatError({ message: err instanceof Error ? err.message : String(err), hint: USAGE }));
|
|
107
111
|
return CHANT_EXIT.failed;
|
|
108
112
|
}
|
|
113
|
+
// #4914: the report's markdown section, in the product's own report and the job summary of a forge that keeps one.
|
|
114
|
+
for (const file of [...new Set([args.checkSummary, process.env.GITHUB_STEP_SUMMARY].filter((f): f is string => Boolean(f)))]) {
|
|
115
|
+
const { checkReportSummary } = await import("../../components/check-hooks");
|
|
116
|
+
const lines = checkReportSummary(report);
|
|
117
|
+
if (lines.length === 0) continue;
|
|
118
|
+
try {
|
|
119
|
+
const { appendFileSync, mkdirSync } = await import("node:fs");
|
|
120
|
+
const { dirname } = await import("node:path");
|
|
121
|
+
mkdirSync(dirname(resolve(file)), { recursive: true });
|
|
122
|
+
appendFileSync(file, `${lines.join("\n")}\n`);
|
|
123
|
+
} catch (err) {
|
|
124
|
+
console.error(`ci check: could not write the summary to ${file}: ${err instanceof Error ? err.message : String(err)}`);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
109
127
|
if (args.json) console.log(JSON.stringify(report, null, 2));
|
|
110
128
|
else if (report.status === "none") console.error("ci check: no ci.hooks.check at base and no lexicon check step, so nothing ran");
|
|
111
129
|
else {
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* #4914: `chant ci evidence sign --open`, the GitLab signing job of the
|
|
3
|
+
* target branch's plan notes pipeline. For each open merge request it reads
|
|
4
|
+
* the newest plan or check job's report from its artifact, signs it for the
|
|
5
|
+
* head, keeps `<out>/<iid>/evidence.json` naming the head, and does not
|
|
6
|
+
* sign a head again once its evidence is current. The forge is a fake; the
|
|
7
|
+
* repository, the runner key and the notes are real.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { execFileSync } from "node:child_process";
|
|
11
|
+
import { generateKeyPairSync } from "node:crypto";
|
|
12
|
+
import { existsSync, mkdirSync, mkdtempSync, readFileSync, writeFileSync } from "node:fs";
|
|
13
|
+
import { tmpdir } from "node:os";
|
|
14
|
+
import { join } from "node:path";
|
|
15
|
+
import { afterEach, describe, expect, test, vi } from "vitest";
|
|
16
|
+
import { loadRunnerKey } from "../../workspace/trust/dsse";
|
|
17
|
+
import { readCheckEvidence } from "../../workspace/trust/check-evidence";
|
|
18
|
+
import { signOpenReports } from "../../workspace/trust/open-evidence";
|
|
19
|
+
import { parseArgs } from "../parse-args";
|
|
20
|
+
import type { CommandContext } from "../registry";
|
|
21
|
+
import type { MergeRequestJob, PrForge } from "../../pr-forge";
|
|
22
|
+
|
|
23
|
+
const forge = vi.hoisted(() => ({ current: undefined as unknown }));
|
|
24
|
+
vi.mock("../../pr-forge", async (actual) => ({ ...(await actual<typeof import("../../pr-forge")>()), forgeFromEnv: () => forge.current }));
|
|
25
|
+
|
|
26
|
+
const { runCiEvidence } = await import("./ci-evidence");
|
|
27
|
+
|
|
28
|
+
function git(cwd: string, ...args: string[]): string {
|
|
29
|
+
return execFileSync("git", ["-c", "user.name=t", "-c", "user.email=t@example.invalid", "-c", "init.defaultBranch=main", ...args], { cwd, encoding: "utf-8", stdio: ["ignore", "pipe", "pipe"] }).trim();
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** A repository whose base lists `ci`'s key as a runner, and a merge request's head on a branch beside it. */
|
|
33
|
+
function repo(): { dir: string; base: string; head: string; pem: string } {
|
|
34
|
+
const dir = mkdtempSync(join(tmpdir(), "chant-4914-"));
|
|
35
|
+
const { privateKey } = generateKeyPairSync("ed25519");
|
|
36
|
+
const pem = privateKey.export({ format: "pem", type: "pkcs8" }).toString();
|
|
37
|
+
git(dir, "init", "--quiet");
|
|
38
|
+
mkdirSync(join(dir, ".chant"));
|
|
39
|
+
writeFileSync(join(dir, ".chant/trust.json"), JSON.stringify({ schema: 1, runners: [{ principal: "ci", class: "runner", key: loadRunnerKey(pem).publicKey }] }));
|
|
40
|
+
writeFileSync(join(dir, "main.tf"), "# base\n");
|
|
41
|
+
git(dir, "add", ".");
|
|
42
|
+
git(dir, "commit", "--quiet", "-m", "base");
|
|
43
|
+
const base = git(dir, "rev-parse", "HEAD");
|
|
44
|
+
git(dir, "checkout", "--quiet", "-b", "change");
|
|
45
|
+
writeFileSync(join(dir, "main.tf"), "# change\n");
|
|
46
|
+
git(dir, "commit", "--quiet", "-am", "change");
|
|
47
|
+
const head = git(dir, "rev-parse", "HEAD");
|
|
48
|
+
git(dir, "checkout", "--quiet", "main");
|
|
49
|
+
return { dir, base, head, pem };
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** A GitLab client with the merge requests' jobs, each job's artifact files, and the merge requests from a fork. */
|
|
53
|
+
function gitlab(jobs: MergeRequestJob[], artifacts: Record<number, Record<string, string>>, forks: number[] = []) {
|
|
54
|
+
const asked: string[] = [];
|
|
55
|
+
const client = {
|
|
56
|
+
kind: "gitlab",
|
|
57
|
+
async mergeRequestJobs(_branch: string, job: string) {
|
|
58
|
+
asked.push(job);
|
|
59
|
+
return jobs;
|
|
60
|
+
},
|
|
61
|
+
async openPullRequests(base: string) {
|
|
62
|
+
return jobs.map((j) => ({ number: j.pr, head: `mr-${j.pr}`, headSha: j.head, base, fork: forks.includes(j.pr) }));
|
|
63
|
+
},
|
|
64
|
+
async jobArtifact(id: number, path: string) {
|
|
65
|
+
return artifacts[id]?.[path];
|
|
66
|
+
},
|
|
67
|
+
} as unknown as PrForge;
|
|
68
|
+
return { client, asked };
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const PLAN = JSON.stringify({ version: 1, policy: { result: "passed" } });
|
|
72
|
+
const CHECK = JSON.stringify({ version: 1, hooks: [{ name: "lint", exit: 0, outcome: "passed" }, { name: "tests", exit: 1, outcome: "failed" }] });
|
|
73
|
+
|
|
74
|
+
afterEach(() => {
|
|
75
|
+
vi.restoreAllMocks();
|
|
76
|
+
delete process.env.CHANT_RUNNER_KEY;
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
async function run(dir: string, argv: string[]): Promise<number> {
|
|
80
|
+
vi.spyOn(process, "cwd").mockReturnValue(dir);
|
|
81
|
+
vi.spyOn(console, "error").mockImplementation(() => {});
|
|
82
|
+
return runCiEvidence({ args: parseArgs(["ci", "evidence", "sign", ...argv]) } as CommandContext);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
describe("ci evidence sign --open (#4914)", () => {
|
|
86
|
+
test("signs each open merge request's settled plan job for its head, keeps evidence.json naming it, and signs a head once", async () => {
|
|
87
|
+
const r = repo();
|
|
88
|
+
const g = gitlab(
|
|
89
|
+
[
|
|
90
|
+
{ pr: 7, head: r.head, id: 101, status: "success" },
|
|
91
|
+
{ pr: 8, head: r.head, id: 102, status: "running" },
|
|
92
|
+
],
|
|
93
|
+
{ 101: { ".chant/pr/pr-plan.json": PLAN } },
|
|
94
|
+
);
|
|
95
|
+
forge.current = g.client;
|
|
96
|
+
process.env.CHANT_RUNNER_KEY = r.pem;
|
|
97
|
+
const out = join(r.dir, ".chant/evidence/plan");
|
|
98
|
+
const argv = ["--open", "--job", "plan", "--from-report", ".chant/pr", "--base", r.base, "--branch", "main", "-o", out, "--no-push"];
|
|
99
|
+
expect(await run(r.dir, argv)).toBe(0);
|
|
100
|
+
expect(g.asked).toEqual(["plan"]);
|
|
101
|
+
const kept = JSON.parse(readFileSync(join(out, "7", "evidence.json"), "utf-8"));
|
|
102
|
+
expect(kept).toMatchObject({ pr: 7, head: r.head, skipped: [] });
|
|
103
|
+
expect(kept.signed.map((s: { check: string }) => s.check)).toEqual(["plan", "policy"]);
|
|
104
|
+
expect(existsSync(join(out, "8"))).toBe(false);
|
|
105
|
+
expect((await readCheckEvidence(r.dir, r.head, r.base, ["plan", "policy"])).map((v) => v.status)).toEqual(["current", "current"]);
|
|
106
|
+
// The next scheduled pipeline: the head's evidence is current, so nothing is signed again, and the file says it is signed.
|
|
107
|
+
const notes = git(r.dir, "notes", "--ref=refs/notes/chant/evidence", "list");
|
|
108
|
+
expect(await run(r.dir, argv)).toBe(0);
|
|
109
|
+
expect(git(r.dir, "notes", "--ref=refs/notes/chant/evidence", "list")).toBe(notes);
|
|
110
|
+
expect(JSON.parse(readFileSync(join(out, "7", "evidence.json"), "utf-8")).signed.map((s: { check: string; runner: string }) => `${s.check}:${s.runner}`)).toEqual(["plan:ci", "policy:ci"]);
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
test("signs each hook that passed from a check job's artifact, and none of a fork's with --no-forks", async () => {
|
|
114
|
+
const r = repo();
|
|
115
|
+
const g = gitlab(
|
|
116
|
+
[
|
|
117
|
+
{ pr: 7, head: r.head, id: 201, status: "failed" },
|
|
118
|
+
{ pr: 9, head: r.head, id: 202, status: "success" },
|
|
119
|
+
],
|
|
120
|
+
{ 201: { ".chant/check/check-hooks.json": CHECK }, 202: { ".chant/check/check-hooks.json": CHECK } },
|
|
121
|
+
[9],
|
|
122
|
+
);
|
|
123
|
+
forge.current = g.client;
|
|
124
|
+
process.env.CHANT_RUNNER_KEY = r.pem;
|
|
125
|
+
const out = join(r.dir, ".chant/evidence/check");
|
|
126
|
+
expect(await run(r.dir, ["--open", "--job", "check", "--from-report", ".chant/check", "--base", r.base, "--branch", "main", "-o", out, "--no-push", "--no-forks"])).toBe(0);
|
|
127
|
+
const kept = JSON.parse(readFileSync(join(out, "7", "evidence.json"), "utf-8"));
|
|
128
|
+
expect(kept.signed.map((s: { check: string }) => s.check)).toEqual(["lint"]);
|
|
129
|
+
expect(kept.skipped).toEqual([{ check: "tests", reason: "the hook did not pass in the check job" }]);
|
|
130
|
+
expect(existsSync(join(out, "9"))).toBe(false);
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
test("refuses what it cannot sign for: no job, no output, a fixed head", async () => {
|
|
134
|
+
const r = repo();
|
|
135
|
+
forge.current = gitlab([], {}).client;
|
|
136
|
+
expect(await run(r.dir, ["--open", "--from-report", ".chant/pr", "-o", "x", "--branch", "main"])).toBe(1);
|
|
137
|
+
expect(await run(r.dir, ["--open", "--job", "plan", "--from-report", ".chant/pr", "--branch", "main"])).toBe(1);
|
|
138
|
+
expect(await run(r.dir, ["--open", "--job", "plan", "--from-report", ".chant/pr", "-o", "x", "--branch", "main", "--at", "HEAD"])).toBe(1);
|
|
139
|
+
});
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
describe("signOpenReports (#4914)", () => {
|
|
143
|
+
test("a job that left no report, or whose head does not fetch, is said and signs nothing", async () => {
|
|
144
|
+
const out = mkdtempSync(join(tmpdir(), "chant-4914-open-"));
|
|
145
|
+
const g = gitlab(
|
|
146
|
+
[
|
|
147
|
+
{ pr: 1, head: "a".repeat(40), id: 1, status: "success" },
|
|
148
|
+
{ pr: 2, head: "b".repeat(40), id: 2, status: "success" },
|
|
149
|
+
],
|
|
150
|
+
{ 2: { ".chant/pr/pr-plan.json": PLAN } },
|
|
151
|
+
);
|
|
152
|
+
const sign = vi.fn();
|
|
153
|
+
const { done } = await signOpenReports({ forge: g.client, branch: "main", job: "plan", artifactDir: ".chant/pr/", out, fetchHead: () => false, sign });
|
|
154
|
+
expect(done.map((d) => [d.pr, d.skipped])).toEqual([
|
|
155
|
+
[1, "the plan job left no report under .chant/pr"],
|
|
156
|
+
[2, `the head ${"b".repeat(12)} did not fetch`],
|
|
157
|
+
]);
|
|
158
|
+
expect(sign).not.toHaveBeenCalled();
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
test("a forge that cannot list merge request jobs is refused", async () => {
|
|
162
|
+
await expect(signOpenReports({ forge: { kind: "github" } as PrForge, branch: "main", job: "plan", artifactDir: ".chant/pr", out: "x", fetchHead: () => true, sign: vi.fn() })).rejects.toThrow(/it is for GitLab/);
|
|
163
|
+
});
|
|
164
|
+
});
|