@intentius/chant 0.124.86 → 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.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 +69 -10
- package/dist/ci-evidence-jobs.d.ts.map +1 -1
- package/dist/ci-evidence-jobs.js +72 -8
- 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 +20 -1
- 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 +38 -14
- package/dist/cli/handlers/ci-evidence.d.ts.map +1 -1
- package/dist/cli/handlers/ci-evidence.js +238 -26
- 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 +21 -3
- package/dist/components/check-steps.js +1 -1
- 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 +262 -3
- package/dist/components/product-plan.d.ts.map +1 -1
- package/dist/components/product-plan.js +243 -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 -20
- 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 +17 -4
- package/dist/op/op-waves-evidence.d.ts.map +1 -1
- package/dist/op/op-waves-evidence.js +32 -10
- 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 +51 -1
- package/dist/release-floors.d.ts.map +1 -1
- package/dist/release-floors.js +66 -16
- package/dist/state-migration.d.ts +23 -0
- 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 +310 -303
- package/dist/workspace/ci-green-cli.d.ts.map +1 -1
- package/dist/workspace/ci-green-cli.js +13 -7
- package/dist/workspace/ci-green.d.ts.map +1 -1
- package/dist/workspace/ci-green.js +4 -3
- 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 +25 -0
- package/dist/workspace/trust/check-evidence-report.d.ts.map +1 -1
- package/dist/workspace/trust/check-evidence-report.js +20 -0
- package/dist/workspace/trust/check-evidence.d.ts +59 -13
- package/dist/workspace/trust/check-evidence.d.ts.map +1 -1
- package/dist/workspace/trust/check-evidence.js +101 -24
- package/dist/workspace/trust/ci-tag-statement.d.ts +2 -2
- package/dist/workspace/trust/ci-tag-statement.d.ts.map +1 -1
- package/dist/workspace/trust/dsse.d.ts +40 -2
- package/dist/workspace/trust/dsse.d.ts.map +1 -1
- package/dist/workspace/trust/dsse.js +34 -2
- package/dist/workspace/trust/evidence.d.ts +7 -2
- package/dist/workspace/trust/evidence.d.ts.map +1 -1
- package/dist/workspace/trust/evidence.js +5 -0
- package/dist/workspace/trust/keyless-fixture.d.ts +41 -0
- package/dist/workspace/trust/keyless-fixture.d.ts.map +1 -0
- package/dist/workspace/trust/keyless-fixture.js +161 -0
- package/dist/workspace/trust/keyless.d.ts +202 -0
- package/dist/workspace/trust/keyless.d.ts.map +1 -0
- package/dist/workspace/trust/keyless.js +488 -0
- package/dist/workspace/trust/local-evidence.d.ts +3 -0
- package/dist/workspace/trust/local-evidence.d.ts.map +1 -1
- package/dist/workspace/trust/op-run-statement.d.ts +2 -2
- package/dist/workspace/trust/op-run-statement.d.ts.map +1 -1
- 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/policy.d.ts +56 -1
- package/dist/workspace/trust/policy.d.ts.map +1 -1
- package/dist/workspace/trust/policy.js +103 -2
- 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 +62 -3
- package/dist/workspace/trust/ref-gate.d.ts.map +1 -1
- package/dist/workspace/trust/ref-gate.js +75 -8
- package/dist/workspace/trust/run-statement.d.ts +3 -3
- package/dist/workspace/trust/run-statement.d.ts.map +1 -1
- package/dist/workspace/trust/runner-identity.d.ts +56 -0
- package/dist/workspace/trust/runner-identity.d.ts.map +1 -0
- package/dist/workspace/trust/runner-identity.js +65 -0
- package/dist/workspace/trust/trust-files.d.ts.map +1 -1
- package/dist/workspace/trust/trust-files.js +8 -1
- 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 +85 -10
- 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 +35 -13
- package/src/cli/handlers/ci-evidence-open.test.ts +164 -0
- package/src/cli/handlers/ci-evidence.ts +223 -24
- 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 +25 -3
- package/src/components/check-report-summary.test.ts +78 -0
- package/src/components/check-steps.ts +1 -1
- 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 +419 -14
- 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 -20
- 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 +37 -4
- package/src/op/op-waves-evidence.ts +32 -11
- 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 +88 -16
- 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/ci-green.ts +4 -3
- 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 +33 -0
- package/src/workspace/trust/check-evidence.test.ts +3 -3
- package/src/workspace/trust/check-evidence.ts +110 -28
- package/src/workspace/trust/ci-tag-statement.ts +2 -2
- package/src/workspace/trust/dsse.ts +48 -4
- package/src/workspace/trust/evidence.ts +7 -2
- package/src/workspace/trust/keyless-fixture.ts +214 -0
- package/src/workspace/trust/keyless.test.ts +220 -0
- package/src/workspace/trust/keyless.ts +557 -0
- package/src/workspace/trust/local-evidence.ts +3 -1
- package/src/workspace/trust/op-run-statement.ts +2 -2
- package/src/workspace/trust/open-evidence.ts +129 -0
- package/src/workspace/trust/policy.ts +129 -2
- 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 +90 -8
- package/src/workspace/trust/run-statement.ts +3 -3
- package/src/workspace/trust/runner-identity.ts +92 -0
- package/src/workspace/trust/trust-files.test.ts +6 -0
- package/src/workspace/trust/trust-files.ts +14 -1
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* #4914: the check report's markdown section, which `chant ci check
|
|
3
|
+
* --summary <file>` appends to a product's own report, so a product's check
|
|
4
|
+
* step runs chant's check stage (hooks, lexicon steps, signing) and renders
|
|
5
|
+
* nothing of its own.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { execFileSync } from "node:child_process";
|
|
9
|
+
import { mkdtempSync, readFileSync, writeFileSync } from "node:fs";
|
|
10
|
+
import { tmpdir } from "node:os";
|
|
11
|
+
import { join } from "node:path";
|
|
12
|
+
import { afterEach, describe, expect, test, vi } from "vitest";
|
|
13
|
+
import { checkReportSummary } from "./check-hooks";
|
|
14
|
+
import { parseArgs } from "../cli/parse-args";
|
|
15
|
+
import type { CommandContext } from "../cli/registry";
|
|
16
|
+
|
|
17
|
+
const BASE = "0123456789abcdef0123456789abcdef01234567";
|
|
18
|
+
|
|
19
|
+
describe("checkReportSummary (#4914)", () => {
|
|
20
|
+
test("names the base, each hook run and step, the failure and the evidence signed", () => {
|
|
21
|
+
const lines = checkReportSummary({
|
|
22
|
+
status: "failed",
|
|
23
|
+
base: BASE,
|
|
24
|
+
hooks: [
|
|
25
|
+
{ name: "fmt", exit: 0, outcome: "passed" },
|
|
26
|
+
{ name: "tflint", target: "roots/a", exit: 2, outcome: "failed" },
|
|
27
|
+
{ name: "checkov", exit: 0, outcome: "skipped", reason: "current local evidence from person alice" },
|
|
28
|
+
],
|
|
29
|
+
steps: [{ lexicon: "pulumi", step: "pulumi-about", member: "app", stack: "dev", exit: 0, outcome: "passed" }],
|
|
30
|
+
failed: "a check hook failed: tflint",
|
|
31
|
+
evidence: { signed: ["fmt"], runner: "ci", commit: BASE },
|
|
32
|
+
});
|
|
33
|
+
expect(lines).toEqual([
|
|
34
|
+
"### Check hooks (read at 0123456789ab)",
|
|
35
|
+
"",
|
|
36
|
+
"- passed: `fmt`",
|
|
37
|
+
"- failed: `tflint` for `roots/a`, exit 2",
|
|
38
|
+
"- skipped: `checkov` (current local evidence from person alice)",
|
|
39
|
+
"- passed: `pulumi pulumi-about` for `app` (stack `dev`)",
|
|
40
|
+
"- a check hook failed: tflint",
|
|
41
|
+
"- signed: `fmt` as ci",
|
|
42
|
+
"",
|
|
43
|
+
]);
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
test("nothing when no hook is declared and no step ran", () => {
|
|
47
|
+
expect(checkReportSummary({ status: "none", base: "HEAD", hooks: [] })).toEqual([]);
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
describe("chant ci check --summary (#4914)", () => {
|
|
52
|
+
afterEach(() => vi.restoreAllMocks());
|
|
53
|
+
|
|
54
|
+
test("the flag parses", () => {
|
|
55
|
+
expect(parseArgs(["ci", "check", "--base", "HEAD", "--summary", ".terragucci/check/report.md"])).toMatchObject({ checkSummary: ".terragucci/check/report.md" });
|
|
56
|
+
expect(() => parseArgs(["ci", "check", "--summary"])).toThrow(/--summary needs a file/);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
test("appends the section to the file after the check hooks ran", async () => {
|
|
60
|
+
const cwd = mkdtempSync(join(tmpdir(), "chant-4914-summary-"));
|
|
61
|
+
const git = (...args: string[]) => 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();
|
|
62
|
+
git("init", "--quiet");
|
|
63
|
+
writeFileSync(join(cwd, "chant.workspace.json"), JSON.stringify({ name: "acme", schema: 1, members: [], ci: { hooks: { check: [{ name: "ok", command: ["true"] }] } } }, null, 2) + "\n");
|
|
64
|
+
git("add", ".");
|
|
65
|
+
git("commit", "--quiet", "-m", "base");
|
|
66
|
+
const file = join(cwd, "out", "report.md");
|
|
67
|
+
vi.spyOn(process, "cwd").mockReturnValue(cwd);
|
|
68
|
+
const said: string[] = [];
|
|
69
|
+
vi.spyOn(console, "error").mockImplementation((l: string) => void said.push(String(l)));
|
|
70
|
+
vi.stubEnv("GITHUB_STEP_SUMMARY", "");
|
|
71
|
+
const { runCiCheck } = await import("../cli/handlers/ci-check");
|
|
72
|
+
const code = await runCiCheck({ args: parseArgs(["ci", "check", "--base", "HEAD", "--output", join(cwd, ".chant/check"), "--summary", file]), plugins: [{} as never] } as unknown as CommandContext);
|
|
73
|
+
vi.unstubAllEnvs();
|
|
74
|
+
expect(code, said.join("\n")).toBe(0);
|
|
75
|
+
expect(said.join("\n")).toContain("1 passed");
|
|
76
|
+
expect(readFileSync(file, "utf-8")).toContain("- passed: `ok`");
|
|
77
|
+
});
|
|
78
|
+
});
|
|
@@ -192,7 +192,7 @@ async function signHooks(options: { dir?: string; evidence?: CheckStageEvidence
|
|
|
192
192
|
const signer = options.evidence.signer;
|
|
193
193
|
const at = options.evidence.at ?? "HEAD";
|
|
194
194
|
const wanted = passed.map((h) => ({ check: h.check, claim: JSON.stringify(h.runs) }));
|
|
195
|
-
const signed = isLocalSigner(signer) ? signLocalChecks(repo, at, wanted, signer) : signChecks(repo, at, wanted, signer);
|
|
195
|
+
const signed = isLocalSigner(signer) ? signLocalChecks(repo, at, wanted, signer) : await signChecks(repo, at, wanted, signer);
|
|
196
196
|
const push = { push: options.evidence.push !== false };
|
|
197
197
|
const pushed = isLocalSigner(signer) ? await recordLocalChecks(repo, signed, push) : await recordChecks(repo, signed, push);
|
|
198
198
|
for (const s of signed) log(`ci check: signed ${isLocalSigner(signer) ? "local " : ""}evidence for ${s.check} at ${s.commit.slice(0, 12)} as ${s.runner}`);
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The pull request's check job and the ref gate's status job (#4935), for
|
|
3
|
+
* the forge lexicons to render beside the plan jobs: the pull request loop
|
|
4
|
+
* (`chant build --pr-loop --check-job --ref-gate-status`) and the product
|
|
5
|
+
* pipeline (`productPipelineJobs({ checkJob, refGateStatus })`).
|
|
6
|
+
*
|
|
7
|
+
* - The check job runs `chant ci check --base <base>` on the pull request's
|
|
8
|
+
* commit: the `ci.hooks.check` hooks the declaration at base names and the
|
|
9
|
+
* lexicons' check steps. A hook whose current local evidence the policy at
|
|
10
|
+
* base accepts is skipped (#4868). The job runs the change's code, so it
|
|
11
|
+
* follows the plan job's handover (#4295): the checkout script alone sees
|
|
12
|
+
* the forge token, every later step starts without it, and the check is
|
|
13
|
+
* the job's last step, handing `.chant/check` on as the job's outputs.
|
|
14
|
+
* It holds no runner key and no OIDC token for signing either (#4328).
|
|
15
|
+
* - With `evidence` (#4870, #4869) the `check-evidence` job signs each hook
|
|
16
|
+
* that passed, by name, from the check job's report, in a job that checks
|
|
17
|
+
* out the target branch's commit and runs none of the change's code, as
|
|
18
|
+
* the plan note job signs `plan` and `policy` from the plan job's report.
|
|
19
|
+
* It pushes `refs/notes/chant/evidence`. On GitLab it runs in the target
|
|
20
|
+
* branch's plan notes pipeline (#4914), as the plan's `<plan job>-evidence`
|
|
21
|
+
* job does: `ci evidence sign --open` signs every open merge request's
|
|
22
|
+
* settled check job from its artifact, so no job of the merge request's
|
|
23
|
+
* own pipeline holds the key.
|
|
24
|
+
* - The `ref-gate` job runs `chant workspace ref-gate status` (#4867) for
|
|
25
|
+
* the pull request's commit once the plan note and the check evidence are
|
|
26
|
+
* in: it reads the evidence notes, decides the update a merge into the
|
|
27
|
+
* target branch would make under the policy at base, and sets the
|
|
28
|
+
* `chant/ref-gate` status (or the policy's own status name), which a
|
|
29
|
+
* project can then make a required status. GitLab sets a status only with
|
|
30
|
+
* the protected token a target-branch pipeline holds (#4328), so there the
|
|
31
|
+
* job runs in the plan notes pipeline and posts for every open merge
|
|
32
|
+
* request into the branch (`ref-gate status --open`).
|
|
33
|
+
*
|
|
34
|
+
* The commit is the one the plan job checked out and every other status of
|
|
35
|
+
* the loop names: `github.sha` on GitHub and Forgejo, `CI_COMMIT_SHA` in a
|
|
36
|
+
* GitLab merge request pipeline.
|
|
37
|
+
*/
|
|
38
|
+
|
|
39
|
+
import type { ForgeKind } from "../pr-forge";
|
|
40
|
+
import { GITHUB_JOB_TOKEN } from "../ci-jobs";
|
|
41
|
+
import { assertPipelineEvidence, evidenceIdTokens, evidenceKeyEnv, evidenceKeyless, gitlabOpenEvidenceDir, openEvidenceLines, planEvidenceLines, type PipelineEvidence } from "../ci-evidence-jobs";
|
|
42
|
+
import { withProductBin } from "./pr-pipeline";
|
|
43
|
+
|
|
44
|
+
/** The check job's name (#4935). */
|
|
45
|
+
export const PR_CHECK_JOB = "check";
|
|
46
|
+
|
|
47
|
+
/** The job that signs the check job's hooks (#4935). */
|
|
48
|
+
export const PR_CHECK_EVIDENCE_JOB = "check-evidence";
|
|
49
|
+
|
|
50
|
+
/** The job that sets the ref gate's status (#4935). */
|
|
51
|
+
export const PR_REF_GATE_JOB = "ref-gate";
|
|
52
|
+
|
|
53
|
+
/** Where `chant ci check` writes its report: `CHECK_HOOKS_DIR` in ./check-hooks.ts, kept here so a generator does not load the check runner. */
|
|
54
|
+
export const PR_CHECK_REPORT_DIR = ".chant/check";
|
|
55
|
+
|
|
56
|
+
/** The artifact the check report is kept as. */
|
|
57
|
+
export const PR_CHECK_ARTIFACT = "chant-pr-check";
|
|
58
|
+
|
|
59
|
+
/** The check job (#4935): its command and the values it reads. */
|
|
60
|
+
export interface PrCheckJob {
|
|
61
|
+
jobName: string;
|
|
62
|
+
/** `chant ci check --base "$BASE_SHA"`, through the words' bin. */
|
|
63
|
+
command: string;
|
|
64
|
+
/** `BASE_SHA`, as the forge spells it. */
|
|
65
|
+
env: Record<string, string>;
|
|
66
|
+
/** The report directory it writes and hands on. */
|
|
67
|
+
dir: string;
|
|
68
|
+
/**
|
|
69
|
+
* With `evidence`: the signing job's lines and variables. GitHub and
|
|
70
|
+
* Forgejo run them in `check-evidence` after taking the report back;
|
|
71
|
+
* GitLab in `check-evidence` in the target branch's plan notes pipeline
|
|
72
|
+
* (#4914), for every open merge request's check job, keeping `dir`.
|
|
73
|
+
* Signing keyless, the job asks for an OIDC token: `idToken` (GitHub's
|
|
74
|
+
* `id-token: write`, Forgejo's `enable-openid-connect`) or GitLab's
|
|
75
|
+
* `idTokens`.
|
|
76
|
+
*/
|
|
77
|
+
evidence?: { jobName: string; lines: string[]; env: Record<string, string>; dir?: string; idToken?: true; idTokens?: Record<string, { aud: string }> };
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/** The check job for `forge` (#4935), with the check evidence job when `evidence` names a runner identity. */
|
|
81
|
+
export function prCheckJob(forge: ForgeKind, opts: { bin?: string; evidence?: PipelineEvidence; noForks?: boolean } = {}): PrCheckJob {
|
|
82
|
+
assertPipelineEvidence(opts.evidence);
|
|
83
|
+
const gitlab = forge === "gitlab";
|
|
84
|
+
const base = gitlab ? "$CI_MERGE_REQUEST_DIFF_BASE_SHA" : "${{ github.event.pull_request.base.sha }}";
|
|
85
|
+
const job: PrCheckJob = {
|
|
86
|
+
jobName: PR_CHECK_JOB,
|
|
87
|
+
command: withProductBin('chant ci check --base "$BASE_SHA"', opts.bin),
|
|
88
|
+
env: { BASE_SHA: base },
|
|
89
|
+
dir: PR_CHECK_REPORT_DIR,
|
|
90
|
+
};
|
|
91
|
+
const evidence = opts.evidence;
|
|
92
|
+
if (!evidence) return job;
|
|
93
|
+
const key = evidenceKeyEnv(forge, evidence);
|
|
94
|
+
const bin = opts.bin ? { bin: opts.bin } : {};
|
|
95
|
+
if (gitlab) {
|
|
96
|
+
// #4914: the job runs in the target branch's plan notes pipeline and signs every open merge request's
|
|
97
|
+
// settled check job from its artifact; no job of a merge request pipeline holds the key.
|
|
98
|
+
const dir = gitlabOpenEvidenceDir(PR_CHECK_JOB);
|
|
99
|
+
return {
|
|
100
|
+
...job,
|
|
101
|
+
evidence: {
|
|
102
|
+
jobName: PR_CHECK_EVIDENCE_JOB,
|
|
103
|
+
// A fork's check job runs too, as it holds nothing; with noForks (a product plan's forks: "skip") its hooks are not signed for.
|
|
104
|
+
lines: openEvidenceLines({ job: PR_CHECK_JOB, dir: PR_CHECK_REPORT_DIR, out: dir, ...bin, ...(opts.noForks ? { noForks: true } : {}) }),
|
|
105
|
+
env: key,
|
|
106
|
+
dir,
|
|
107
|
+
...(evidenceKeyless(evidence) ? { idTokens: evidenceIdTokens(evidence) } : {}),
|
|
108
|
+
},
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
return {
|
|
112
|
+
...job,
|
|
113
|
+
evidence: {
|
|
114
|
+
jobName: PR_CHECK_EVIDENCE_JOB,
|
|
115
|
+
lines: planEvidenceLines({ dir: PR_CHECK_REPORT_DIR, at: '"$HEAD_SHA"', base: '"$BASE_SHA"', result: '"$CHECK_RESULT"', ...bin }),
|
|
116
|
+
env: { HEAD_SHA: "${{ github.sha }}", BASE_SHA: base, CHECK_RESULT: `\${{ needs.${PR_CHECK_JOB}.result }}`, ...key },
|
|
117
|
+
...(evidenceKeyless(evidence) ? { idToken: true as const } : {}),
|
|
118
|
+
},
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/** The ref gate's status job (#4935): its lines and the values they read. */
|
|
123
|
+
export interface PrRefGateJob {
|
|
124
|
+
jobName: string;
|
|
125
|
+
/** The fetches of the pull request's commit and the evidence notes, before the command. */
|
|
126
|
+
setup: string[];
|
|
127
|
+
/** `chant workspace ref-gate status`, through the words' bin. */
|
|
128
|
+
command: string;
|
|
129
|
+
/** The values the lines read, as the forge spells them, the token included on GitHub and Forgejo. */
|
|
130
|
+
env: Record<string, string>;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* The ref gate's status job for `forge` (#4935). `branch` is the target
|
|
135
|
+
* branch on GitHub and Forgejo (default `main`); GitLab's job runs in a
|
|
136
|
+
* pipeline of the target branch and names it from `CI_COMMIT_BRANCH`.
|
|
137
|
+
*/
|
|
138
|
+
export function prRefGateJob(forge: ForgeKind, opts: { bin?: string; branch?: string } = {}): PrRefGateJob {
|
|
139
|
+
const notes = "'+refs/notes/chant/evidence:refs/notes/chant/evidence'";
|
|
140
|
+
if (forge === "gitlab") {
|
|
141
|
+
return {
|
|
142
|
+
jobName: PR_REF_GATE_JOB,
|
|
143
|
+
// The heads are fetched by the command, one merge request at a time.
|
|
144
|
+
setup: [`git fetch --quiet --no-tags origin ${notes} || true`],
|
|
145
|
+
command: withProductBin('chant workspace ref-gate status --open --ref "refs/heads/$CI_COMMIT_BRANCH" --base "$CI_COMMIT_SHA"', opts.bin),
|
|
146
|
+
env: {},
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
const branch = opts.branch ?? "main";
|
|
150
|
+
if (!/^[A-Za-z0-9._\/-]+$/.test(branch)) throw new Error(`the ref gate's branch ${JSON.stringify(branch)} is not a branch name`);
|
|
151
|
+
return {
|
|
152
|
+
jobName: PR_REF_GATE_JOB,
|
|
153
|
+
setup: [`git fetch --quiet --no-tags origin "$HEAD_SHA" ${notes} || git fetch --quiet --no-tags origin "$HEAD_SHA" || true`],
|
|
154
|
+
command: withProductBin(`chant workspace ref-gate status --ref refs/heads/${branch} --at "$HEAD_SHA" --base "$BASE_SHA"`, opts.bin),
|
|
155
|
+
env: { HEAD_SHA: "${{ github.sha }}", BASE_SHA: "${{ github.event.pull_request.base.sha }}", GITHUB_TOKEN: GITHUB_JOB_TOKEN },
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
export { CHECK_JOB_FLOOR, GITLAB_OPEN_EVIDENCE_FLOOR, PR_LOOP_EVIDENCE_FLOOR, REF_GATE_STATUS_JOB_FLOOR } from "../release-floors";
|
|
@@ -101,6 +101,7 @@ import { commandWord, commentLine, PRODUCT_ACTION_ENV, PRODUCT_ACTION_EVENT_FLAG
|
|
|
101
101
|
import { CHANT_EXIT } from "../exit-codes";
|
|
102
102
|
import type { ControlTarget } from "../control/dispatch";
|
|
103
103
|
import { CI_RESPOND_ENV, respondList, type CiResponses } from "../ci-respond";
|
|
104
|
+
import type { PipelineEvidence } from "../ci-evidence-jobs";
|
|
104
105
|
|
|
105
106
|
/** The variable `chant ci run` reads its runner key from (`RUNNER_KEY_ENV` in ../workspace/ci-green.ts). */
|
|
106
107
|
const RUNNER_KEY_ENV = "CHANT_RUNNER_KEY";
|
|
@@ -391,6 +392,44 @@ export interface PrLoopPipelineOptions {
|
|
|
391
392
|
* to `pr-post`. Needed with `respond.description: "check"`.
|
|
392
393
|
*/
|
|
393
394
|
decide?: { backend: string; model: string };
|
|
395
|
+
/**
|
|
396
|
+
* The pipeline's runner identity (#4935, as #4870's `PipelineEvidence`):
|
|
397
|
+
* the plan-note job signs the plan job's `plan` and `policy` checks from
|
|
398
|
+
* its report before it posts, with the runner key from the named secret or
|
|
399
|
+
* (#4869) keyless from the job's OIDC identity. On GitLab a
|
|
400
|
+
* `<plan job>-evidence` job after the plan job signs from its artifact.
|
|
401
|
+
* With `checkJob`, the `check-evidence` job signs each passed hook. Set
|
|
402
|
+
* from `--evidence-runner-key-secret`, or `--evidence-identity oidc` with
|
|
403
|
+
* an optional `--evidence-audience`. Absent: nothing is signed, and every
|
|
404
|
+
* job is as before. Refused on a workspace member's pipeline: the checks
|
|
405
|
+
* are the commit's, so one pipeline signs them.
|
|
406
|
+
*/
|
|
407
|
+
evidence?: PipelineEvidence;
|
|
408
|
+
/**
|
|
409
|
+
* The check job (#4935, ./pr-checks.ts): `chant ci check --base <base>` on
|
|
410
|
+
* the pull request's commit, with no forge token, runner key or OIDC token
|
|
411
|
+
* while the hooks run. Set from `--check-job`. Refused on a member's
|
|
412
|
+
* pipeline: the hooks are the workspace's.
|
|
413
|
+
*/
|
|
414
|
+
checkJob?: boolean;
|
|
415
|
+
/**
|
|
416
|
+
* The ref gate's status job (#4935, ./pr-checks.ts): `chant workspace
|
|
417
|
+
* ref-gate status` for the pull request's commit, after the note and the
|
|
418
|
+
* check evidence, so `chant/ref-gate` can be a required status. Set from
|
|
419
|
+
* `--ref-gate-status`. Refused on a member's pipeline.
|
|
420
|
+
*/
|
|
421
|
+
refGateStatus?: boolean;
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
/**
|
|
425
|
+
* Refuse the loop's `evidence`, `checkJob` and `refGateStatus` (#4935) on a
|
|
426
|
+
* workspace member's pipeline: a check and its evidence are the commit's,
|
|
427
|
+
* so the root pipeline runs and signs them once.
|
|
428
|
+
*/
|
|
429
|
+
export function assertRootChecks(options: Pick<PrLoopPipelineOptions, "evidence" | "checkJob" | "refGateStatus">, member: string | undefined): void {
|
|
430
|
+
if (!member) return;
|
|
431
|
+
const given = [...(options.evidence ? ["evidence"] : []), ...(options.checkJob ? ["checkJob"] : []), ...(options.refGateStatus ? ["refGateStatus"] : [])];
|
|
432
|
+
if (given.length > 0) throw new Error(`${given.join(", ")} sign and judge the pull request's commit once, for the whole workspace, so give ${given.length === 1 ? "it" : "them"} on the root pipeline, not member ${member}'s`);
|
|
394
433
|
}
|
|
395
434
|
|
|
396
435
|
/** The `CHANT_RESPOND` value of `respond` (#4629), or undefined when every event is at its default. Throws on a description check with no decide service. */
|
|
@@ -427,7 +466,8 @@ export function prLoopRunner(options: Pick<PrLoopPipelineOptions, "runners">, st
|
|
|
427
466
|
*/
|
|
428
467
|
export function prLoopJobStage(name: string, member?: string): PrLoopRunnerStage {
|
|
429
468
|
const bare = member && name.startsWith(`${member}-`) ? name.slice(member.length + 1) : name;
|
|
430
|
-
|
|
469
|
+
// #4935: the check job runs the change's code, as the plan does.
|
|
470
|
+
if (bare === "plan" || bare === PR_COMMENT_PREVIEW_JOB || bare === "check") return "plan";
|
|
431
471
|
if (bare === "apply" || bare === "record" || bare === PR_ACTION_JOB || /^apply-wave-\d+$/.test(bare) || bare === "env-up" || bare === "env-down" || bare === "env-sweep") return "apply";
|
|
432
472
|
return "default";
|
|
433
473
|
}
|
|
@@ -42,7 +42,9 @@ import { resolveAgentSpec, type OpAgentSpec } from "../ci-agent";
|
|
|
42
42
|
import { resolveCommitSpec, type OpCommitSpec } from "../ci-commit";
|
|
43
43
|
import type { CiResponses } from "../ci-respond";
|
|
44
44
|
import { planEvidenceOf, productPlanJobs, type ProductPlanJob, type ProductPlanOptions } from "./product-plan";
|
|
45
|
-
import type
|
|
45
|
+
import { gitlabOpenEvidenceDir, type PipelineEvidence } from "../ci-evidence-jobs";
|
|
46
|
+
import { prCheckJob, prRefGateJob, type PrCheckJob, type PrRefGateJob } from "./pr-checks";
|
|
47
|
+
import { assertRootChecks } from "./pr-pipeline";
|
|
46
48
|
|
|
47
49
|
/** Where the generator writes a product's waves spec, which chant reads at base (#4550). */
|
|
48
50
|
export const PRODUCT_WAVES_SPEC_DIR = ".chant/op-waves";
|
|
@@ -201,6 +203,15 @@ export interface ProductPipelineJobs {
|
|
|
201
203
|
action?: PrActionJob & { runner?: CiRunner };
|
|
202
204
|
/** The product plan's jobs (#4799), with `productPlan`: a plan job and a plan-note job per target. */
|
|
203
205
|
productPlan?: ProductPlanJob[];
|
|
206
|
+
/**
|
|
207
|
+
* The check job (#4935), with `checkJob`: `chant ci check` on the pull
|
|
208
|
+
* request's commit through the words' bin, and with `evidence` the
|
|
209
|
+
* `check-evidence` job's lines that sign each passed hook from its report
|
|
210
|
+
* (./pr-checks.ts). The forge lexicons render the same jobs.
|
|
211
|
+
*/
|
|
212
|
+
check?: PrCheckJob & { runner?: CiRunner; evidenceRunner?: CiRunner };
|
|
213
|
+
/** The ref gate's status job (#4935), with `refGateStatus` (./pr-checks.ts). */
|
|
214
|
+
refGate?: PrRefGateJob & { runner?: CiRunner };
|
|
204
215
|
}
|
|
205
216
|
|
|
206
217
|
/** An agent's settings as a product passes them (#4616): {@link OpAgentSpec} without the trigger, which the pipeline names. */
|
|
@@ -305,6 +316,8 @@ export function productPipelineJobs(forge: ForgeKind, env: string, options: Prod
|
|
|
305
316
|
const words = assertProductWords({ ...options.words, applyMode }, { jobs });
|
|
306
317
|
const { waves: given, wavesSpecFile, member, agent: _agent, commits: _commits, actions: _actions, componentWaves, productPlan, evidence, ...loop } = options;
|
|
307
318
|
const { respond } = options;
|
|
319
|
+
// #4935: the check job and the ref gate's status judge the commit once, from the root pipeline.
|
|
320
|
+
assertRootChecks({ checkJob: options.checkJob, refGateStatus: options.refGateStatus }, member);
|
|
308
321
|
// #4629: the pull request loop puts the responses on the apply and note jobs, as `chant build --pr-loop --respond` does.
|
|
309
322
|
const prLoop: PrLoopPipelineOptions = { ...loop, words, gate: options.gate ?? words.prGate };
|
|
310
323
|
const [plan, apply, record] = prLoopJobs(forge, env, prLoop, member);
|
|
@@ -318,7 +331,9 @@ export function productPipelineJobs(forge: ForgeKind, env: string, options: Prod
|
|
|
318
331
|
}
|
|
319
332
|
// #4619: the loop's control target, else the waves spec's.
|
|
320
333
|
const controlTarget = options.control?.target ?? (given?.control ? opWavesControlTarget(given.control) : undefined);
|
|
321
|
-
const
|
|
334
|
+
const post0 = prLoopPostJob(forge, env, member, words, { ...(options.staleNotes ? { staleNotes: true } : {}), ...(respond ? { respond } : {}), ...(options.decide ? { decide: options.decide } : {}) });
|
|
335
|
+
// #4914: on GitLab the signing job of the plan notes pipeline keeps each merge request's evidence, which the note reads.
|
|
336
|
+
const post = evidence && forge === "gitlab" ? { ...post0, command: `${post0.command} --evidence-dir ${gitlabOpenEvidenceDir(plan!.jobName)}` } : post0;
|
|
322
337
|
const out: ProductPipelineJobs = {
|
|
323
338
|
words,
|
|
324
339
|
plan: plan!,
|
|
@@ -329,6 +344,12 @@ export function productPipelineJobs(forge: ForgeKind, env: string, options: Prod
|
|
|
329
344
|
// #4799: the product's plan verb, a plan job and a note job per target.
|
|
330
345
|
...(productPlan ? { productPlan: productPlanJobs(forge, env, { ...prLoop, plan: productPlan }, words, evidence) } : {}),
|
|
331
346
|
};
|
|
347
|
+
// #4935: the check job runs the change's code on the plan runner; the signing and the status run on the default one.
|
|
348
|
+
if (options.checkJob) {
|
|
349
|
+
const planRunner = prLoopRunner(options, "plan");
|
|
350
|
+
out.check = { ...prCheckJob(forge, { ...(words.bin ? { bin: words.bin } : {}), ...(evidence ? { evidence } : {}), ...(productPlan?.forks === "skip" ? { noForks: true } : {}) }), ...(planRunner !== undefined ? { runner: planRunner } : {}), ...(runnerOfDefault !== undefined ? { evidenceRunner: runnerOfDefault } : {}) };
|
|
351
|
+
}
|
|
352
|
+
if (options.refGateStatus) out.refGate = { ...prRefGateJob(forge, { ...(words.bin ? { bin: words.bin } : {}), ...(options.branch ? { branch: options.branch } : {}) }), ...defaultRunner };
|
|
332
353
|
const locks = prCommentLockJobs(forge, { locks: options.locks, words });
|
|
333
354
|
if (locks.length > 0) out.locks = locks.map((job) => ({ ...job, ...defaultRunner }));
|
|
334
355
|
const action = prActionJob(forge, prLoop);
|
|
@@ -336,7 +357,8 @@ export function productPipelineJobs(forge: ForgeKind, env: string, options: Prod
|
|
|
336
357
|
const stale = prStaleJob(forge, env, prLoop, member);
|
|
337
358
|
if (stale) out.stale = { ...stale, ...defaultRunner };
|
|
338
359
|
// #4785: GitLab's comment commands, polled from the notes; waves on merge are retried by an apply on a merged merge request.
|
|
339
|
-
|
|
360
|
+
// #4899: the product plan's comment re-plan runs in the preview's pipeline, so the poll starts it as it starts a preview.
|
|
361
|
+
const notes = prNoteCommandsJob(forge, { ...prLoop, ...(options.waves || options.componentWaves ? { applyOnMerge: true } : {}), ...(productPlan?.replan ? { previewComment: true } : {}) });
|
|
340
362
|
if (notes) out.noteCommands = { ...notes, ...defaultRunner };
|
|
341
363
|
const preview = prCommentPreviewJob(forge, env, prLoop, member);
|
|
342
364
|
if (preview) out.preview = { ...preview, ...(defaultRunner.runner !== undefined ? { noteRunner: defaultRunner.runner } : {}) };
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
import { describe, expect, test } from "vitest";
|
|
7
7
|
import { productPipelineJobs } from "./product-pipeline";
|
|
8
8
|
import { PR_PLAN_NOTE_WORDS_ENV } from "./product-plan";
|
|
9
|
+
import { PLAN_WATCHES_ENV } from "../op/schedule-overdue";
|
|
9
10
|
import { TERRAGUCCI, TERRAGUCCI_NOTE, YODEL } from "../__fixtures__/product-words";
|
|
10
11
|
import type { CiProductCommand } from "../ci-product-words";
|
|
11
12
|
|
|
@@ -53,6 +54,17 @@ describe("the product plan (#4799)", () => {
|
|
|
53
54
|
expect(JSON.parse(plan!.post.env[PR_PLAN_NOTE_WORDS_ENV]!)).toEqual(TERRAGUCCI_NOTE);
|
|
54
55
|
});
|
|
55
56
|
|
|
57
|
+
// #4888: the product's own scheduled jobs reach the note job's pr-post from the pipeline, as terragucci's drift-schedule.json did from the plan job.
|
|
58
|
+
test.each(["github", "forgejo", "gitlab"] as const)("on %s, the product's watches reach the note job, and a watch that is not one is refused", (forge) => {
|
|
59
|
+
const drift = { op: "tf-drift", cron: "0 6 * * *", files: [".github/workflows/terragucci-drift.yml"], ...(forge === "gitlab" ? { schedule: { variable: "TERRAGUCCI_SCHEDULE", not: ["comments"] } } : {}) };
|
|
60
|
+
const [plan] = productPipelineJobs(forge, "default", { words: terragucci, productPlan: { command: "terragucci plan --pr-note {output}", watches: [drift] } }).productPlan!;
|
|
61
|
+
expect(JSON.parse(plan!.post.env[PLAN_WATCHES_ENV]!)).toEqual([drift]);
|
|
62
|
+
const [none] = productPipelineJobs(forge, "default", { words: terragucci, productPlan: { command: "terragucci plan --pr-note {output}" } }).productPlan!;
|
|
63
|
+
expect(none!.post.env).not.toHaveProperty(PLAN_WATCHES_ENV);
|
|
64
|
+
expect(() => productPipelineJobs(forge, "default", { words: terragucci, productPlan: { command: "terragucci plan", watches: [{ op: "tf-drift", cron: "daily" }] } })).toThrow(/the product plan's watches: watch tf-drift's cron "daily" is not five fields/);
|
|
65
|
+
expect(() => productPipelineJobs(forge, "default", { words: terragucci, productPlan: { command: "terragucci plan", watches: [drift, drift] } })).toThrow(/name an Op twice/);
|
|
66
|
+
});
|
|
67
|
+
|
|
56
68
|
test("the pipeline's passed values reach every target, and a name both give is refused", () => {
|
|
57
69
|
const [staging] = productPipelineJobs("github", "default", { words: yodel, variables: { YODEL_LOG: "info" }, productPlan: environments }).productPlan!;
|
|
58
70
|
expect(staging!.env.YODEL_LOG).toBe("info");
|
|
@@ -82,6 +94,95 @@ describe("the product plan (#4799)", () => {
|
|
|
82
94
|
test("PRODUCT_PLAN_FLOOR marks the product plan in the ci-product entry", async () => {
|
|
83
95
|
const { NEXT_RELEASE } = await import("../release-floors");
|
|
84
96
|
const ciProduct = (await import("../ci-product")) as Record<string, unknown>;
|
|
85
|
-
expect(ciProduct.PRODUCT_PLAN_FLOOR).toBe(
|
|
97
|
+
expect(ciProduct.PRODUCT_PLAN_FLOOR).toBe("0.124.86");
|
|
86
98
|
expect(typeof ciProduct.planNoteHandoff).toBe("function");
|
|
87
99
|
});
|
|
100
|
+
|
|
101
|
+
describe("the product plan's steps beside the plan verb (#4899, #4931)", () => {
|
|
102
|
+
const login = { aws: { role: "arn:aws:iam::123456789012:role/yodel-reader", region: "eu-west-1" } };
|
|
103
|
+
|
|
104
|
+
test("a config without the new options gives jobs without their fields", () => {
|
|
105
|
+
const [staging] = productPipelineJobs("github", "default", { words: yodel, productPlan: environments }).productPlan!;
|
|
106
|
+
for (const key of ["jobEnv", "login", "idTokens", "pending", "control", "setup", "report", "replan", "noteSteps"]) expect(staging).not.toHaveProperty(key);
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
test.each(["github", "forgejo", "gitlab"] as const)("on %s, a target's login is chant's ci-login, and the job asks for its tokens", (forge) => {
|
|
110
|
+
const [staging, prod] = productPipelineJobs(forge, "default", { words: yodel, productPlan: { ...environments, login, targets: [{ ...environments.targets[0]!, login: { gcp: { provider: "projects/1/locations/global/workloadIdentityPools/p/providers/q", serviceAccount: "r@p.iam.gserviceaccount.com" } } }, environments.targets[1]!] } }).productPlan!;
|
|
111
|
+
expect(staging!.login![0]!.name).toBe("Cloud login (chant ci-login: gcp)");
|
|
112
|
+
expect(prod!.login![0]!.name).toBe("Cloud login (chant ci-login: aws)");
|
|
113
|
+
expect(prod!.idTokens).toEqual({ CHANT_ID_TOKEN_AWS: "sts.amazonaws.com" });
|
|
114
|
+
expect(staging!.idTokens).toEqual({ CHANT_ID_TOKEN_GCP: "https://iam.googleapis.com/projects/1/locations/global/workloadIdentityPools/p/providers/q" });
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
test("the product's own id tokens, the job's env, the pending status, the setup steps and the report line", () => {
|
|
118
|
+
const [plan] = productPipelineJobs("github", "default", {
|
|
119
|
+
words: terragucci,
|
|
120
|
+
productPlan: {
|
|
121
|
+
command: "terragucci plan --pr-note {output}",
|
|
122
|
+
idTokens: { TERRAGUCCI_OIDC: "sts.amazonaws.com" },
|
|
123
|
+
env: { TG_LOG: "info" },
|
|
124
|
+
pending: true,
|
|
125
|
+
setup: [{ name: "Restore the cache", uses: "actions/cache/restore@v4", with: { path: "~/.cache" } }],
|
|
126
|
+
report: "terragucci report --out {output}/report",
|
|
127
|
+
},
|
|
128
|
+
}).productPlan!;
|
|
129
|
+
expect(plan).toMatchObject({ idTokens: { TERRAGUCCI_OIDC: "sts.amazonaws.com" }, jobEnv: { TG_LOG: "info" }, pending: { context: "terragucci/plan", description: "planning" }, report: "terragucci report --out .chant/pr/report" });
|
|
130
|
+
// GitLab's plan job holds no token, so it posts no pending status.
|
|
131
|
+
expect(productPipelineJobs("gitlab", "default", { words: terragucci, productPlan: { command: "x", pending: true } }).productPlan![0]).not.toHaveProperty("pending");
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
test("the comment re-plan answers the plan command and the words' aliases for it, per target", () => {
|
|
135
|
+
const [staging] = productPipelineJobs("github", "default", { words: { ...yodel, commands: { plan: "plan" as const } }, productPlan: { ...environments, replan: true } }).productPlan!;
|
|
136
|
+
expect(staging!.replan).toMatchObject({ jobName: "replan-staging", noteJobName: "replan-note-staging", comments: ["/yodel plan"], gated: [], artifact: "chant-pr-plan-staging-replan" });
|
|
137
|
+
expect(staging!.replan!.post.env.HEAD_SHA).toBe("${{ needs.replan-staging.outputs.head }}");
|
|
138
|
+
const [tg] = productPipelineJobs("gitlab", "default", { words: { ...TERRAGUCCI, commands: { plan: "plan" as const }, aliases: [TERRAGUCCI.aliases[0]!] }, noteCommands: true, productPlan: { command: "terragucci plan", replan: true } }).productPlan!;
|
|
139
|
+
expect(tg!.replan).toMatchObject({ jobName: "replan", comments: ["/terragucci plan"], gated: [{ comment: "atlantis plan", when: "TG_ATLANTIS_COMMENTS" }] });
|
|
140
|
+
expect(tg!.replan!.post.command).toContain("components pr-post --pr \"$PR_NUMBER\" --head \"$HEAD_SHA\" --env default --output .chant/pr --forge gitlab");
|
|
141
|
+
expect(tg!.replan!.post.command).not.toContain("--result");
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
test.each([
|
|
145
|
+
["replan without a plan command", { replan: true }, /words name no plan command/],
|
|
146
|
+
["a setup step with both run and uses", { setup: [{ run: "x", uses: "y" }] }, /gives one of run and uses/],
|
|
147
|
+
["a forge token in the job's env", { env: { GITHUB_TOKEN: "x" } }, /GITHUB_TOKEN is one the jobs set or drop/],
|
|
148
|
+
["a concurrency group that is not a name", { concurrency: { group: "a b" } }, /concurrency group/],
|
|
149
|
+
["an id token with no audience", { idTokens: { T: "" } }, /names no audience/],
|
|
150
|
+
])("refuses %s", (_what, extra, error) => {
|
|
151
|
+
expect(() => productPipelineJobs("github", "default", { words: yodel, productPlan: { command: "yodel plan {target}", ...extra } })).toThrow(error);
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
test("noteSteps are refused on GitLab, and noteCommands without replan", () => {
|
|
155
|
+
expect(() => productPipelineJobs("gitlab", "default", { words: yodel, productPlan: { command: "x", noteSteps: { before: ["y"] } } })).toThrow(/GitLab's note job posts every open merge request's note/);
|
|
156
|
+
expect(() => productPipelineJobs("gitlab", "default", { words: yodel, noteCommands: true, productPlan: { command: "x" } })).toThrow(/noteCommands without replan/);
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
test("with replan, GitLab's note-commands job starts the preview's pipeline", () => {
|
|
160
|
+
const jobs = productPipelineJobs("gitlab", "default", { words: { ...yodel, commands: { plan: "plan" as const } }, noteCommands: true, productPlan: { command: "x", replan: true } });
|
|
161
|
+
expect(jobs.noteCommands!.command).toContain("--preview-comment");
|
|
162
|
+
});
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
describe("the re-plan decision and the pending status scripts (#4899)", () => {
|
|
166
|
+
test("hold no single quote, so they go in a node -e '...' line", async () => {
|
|
167
|
+
const { REPLAN_DECIDE_JS, PENDING_JS } = await import("./product-plan");
|
|
168
|
+
expect(REPLAN_DECIDE_JS).not.toContain("'");
|
|
169
|
+
expect(PENDING_JS).not.toContain("'");
|
|
170
|
+
expect(() => new Function(REPLAN_DECIDE_JS)).not.toThrow();
|
|
171
|
+
expect(() => new Function(PENDING_JS)).not.toThrow();
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
test("the GitLab rule matches the command alone or with this target, and the aliases behind their variable", async () => {
|
|
175
|
+
const { gitlabReplanCommentIf } = await import("./product-plan");
|
|
176
|
+
expect(gitlabReplanCommentIf({ comments: ["/yodel plan"], gated: [] }, "prod")).toBe("$CHANT_PREVIEW_COMMENT =~ /^\\/yodel plan( +prod)? *$/");
|
|
177
|
+
expect(gitlabReplanCommentIf({ comments: ["/terragucci plan"], gated: [{ comment: "atlantis plan", when: "TG_ATLANTIS_COMMENTS" }] })).toBe(
|
|
178
|
+
"$CHANT_PREVIEW_COMMENT =~ /^\\/terragucci plan( +[A-Za-z0-9_.\\/@+=,:-]+)? *$/ || ($TG_ATLANTIS_COMMENTS && $CHANT_PREVIEW_COMMENT =~ /^atlantis plan( +[A-Za-z0-9_.\\/@+=,:-]+)? *$/)",
|
|
179
|
+
);
|
|
180
|
+
});
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
test("PRODUCT_PLAN_STEPS_FLOOR marks the plan-job steps in the ci-product entry", async () => {
|
|
184
|
+
const { NEXT_RELEASE } = await import("../release-floors");
|
|
185
|
+
const ciProduct = (await import("../ci-product")) as Record<string, unknown>;
|
|
186
|
+
expect(ciProduct.PRODUCT_PLAN_STEPS_FLOOR).toBe(NEXT_RELEASE);
|
|
187
|
+
expect(ciProduct.PLAN_NOTE_NOTICES_ENV).toBe("CHANT_PLAN_NOTE_NOTICES");
|
|
188
|
+
});
|