@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
|
@@ -15,6 +15,26 @@
|
|
|
15
15
|
* deny it (a `pr-plan.json`'s `policy`, a plan note hand-off's overrides).
|
|
16
16
|
* It writes `evidence.json` in `<dir>`, which `pr-post` reads to say in the
|
|
17
17
|
* note which checks were signed.
|
|
18
|
+
* - `sign --from-report <dir>` on a check job's report (#4935), a
|
|
19
|
+
* `check-hooks.json` from `chant ci check`, is the `check-evidence` job's
|
|
20
|
+
* form: it signs each hook that passed, by name, with the runs as its
|
|
21
|
+
* claim, as `ci check` with a runner identity signs them. A hook skipped on
|
|
22
|
+
* local evidence did not pass here and is not signed. With `--result`, a
|
|
23
|
+
* check job that neither succeeded nor failed signs nothing.
|
|
24
|
+
* - `sign --open --job <job> --from-report <dir> -o <out>` (#4914) is the
|
|
25
|
+
* GitLab signing job's form, in a pipeline of the target branch: for each
|
|
26
|
+
* open merge request it reads the report from the newest pipeline's
|
|
27
|
+
* `<job>` artifact, fetches the head and signs it as `--from-report`
|
|
28
|
+
* does, skipping a check already signed for the head's tree, and keeps
|
|
29
|
+
* `<out>/<iid>/evidence.json` for the note job. No job of a merge request
|
|
30
|
+
* pipeline, which the change's own files build, holds the key.
|
|
31
|
+
* - `sign --from-job <job> --check-id <id>[,<id>...] [--claims <dir>]`
|
|
32
|
+
* (#4926) is a wave's evidence job's form: it reads the job of that name
|
|
33
|
+
* in this run through the forge, refuses one of another run or commit,
|
|
34
|
+
* and signs each check whose step (named in `CHANT_EVIDENCE_SOURCES`; on
|
|
35
|
+
* GitLab, whose jobs have no steps, the job) the forge reports passed and
|
|
36
|
+
* whose claim file in `<dir>` says so. Each statement names the run, job
|
|
37
|
+
* and step it relied on (`source`).
|
|
18
38
|
* - `verify --check-id <id>[,<id>...]` reads the evidence for `--at`'s tree
|
|
19
39
|
* and verifies it against the runner keys at `--base`; exits 1 when one
|
|
20
40
|
* is not current.
|
|
@@ -27,7 +47,8 @@
|
|
|
27
47
|
* `local.keys` at base lists, and pushes `refs/notes/chant/local-evidence`;
|
|
28
48
|
* `verify --local` says whether CI would skip each check on that evidence.
|
|
29
49
|
*/
|
|
30
|
-
import {
|
|
50
|
+
import { execFileSync, spawnSync } from "node:child_process";
|
|
51
|
+
import { existsSync, readFileSync, writeFileSync } from "node:fs";
|
|
31
52
|
import { join } from "node:path";
|
|
32
53
|
import { CHANT_EXIT } from "../../exit-codes";
|
|
33
54
|
import { formatError } from "../format";
|
|
@@ -48,6 +69,8 @@ import { CHECK_EVIDENCE_FILE, LOCAL_EVIDENCE_KEY_ENV, planReportChecks, type Che
|
|
|
48
69
|
|
|
49
70
|
const USAGE =
|
|
50
71
|
"chant ci evidence sign (--check-id <id>[,<id>...] | --from-report <dir> --result <result>) [--at <rev>] [--base <rev>] [--key <file>] [--claim <file>] [--no-push] [--json]\n" +
|
|
72
|
+
" chant ci evidence sign --open --job <job> --from-report <dir> -o <out> [--branch <branch>] [--base <rev>] [--key <file>] [--no-push] [--json]\n" +
|
|
73
|
+
" chant ci evidence sign --from-job <job> --check-id <id>[,<id>...] [--claims <dir>] [--at <rev>] [--base <rev>] [--key <file>] [--no-push] [--json]\n" +
|
|
51
74
|
" chant ci evidence sign --local --check-id <id>[,<id>...] [--at <rev>] [--base <rev>] [--key <file>] [--claim <file>] [--no-push] [--json]\n" +
|
|
52
75
|
" chant ci evidence verify [--local] --check-id <id>[,<id>...] [--at <rev>] [--base <rev>] [--json]";
|
|
53
76
|
|
|
@@ -110,49 +133,220 @@ async function verifyLocal(ctx: CommandContext, repo: string, base: string, at:
|
|
|
110
133
|
return verdicts.every((v) => v.status === "accepted") ? CHANT_EXIT.done : CHANT_EXIT.failed;
|
|
111
134
|
}
|
|
112
135
|
|
|
136
|
+
/**
|
|
137
|
+
* `sign --from-job <job>` (#4926): the wave's evidence job, signing each
|
|
138
|
+
* named check whose step in that job of this run and commit the forge
|
|
139
|
+
* reports as passed (../../ci-evidence-from-job.ts). Exits 1 when the job is
|
|
140
|
+
* another run's or commit's.
|
|
141
|
+
*/
|
|
142
|
+
async function signFromJobCommand(ctx: CommandContext, repo: string, base: string): Promise<number> {
|
|
143
|
+
const { args } = ctx;
|
|
144
|
+
const checks = idsOf(args.checkId);
|
|
145
|
+
if (checks.length === 0) return usage("sign --from-job needs --check-id <id>[,<id>...], the checks the job ran");
|
|
146
|
+
if (args.fromReport) return usage("--from-job and --from-report are two ways to sign; pass one");
|
|
147
|
+
const pem = args.key ? readFileSync(args.key, "utf-8") : undefined;
|
|
148
|
+
try {
|
|
149
|
+
const { forgeTargetFromEnv } = await import("../../pr-forge");
|
|
150
|
+
const { forgeReadsFor } = await import("../../pr-forge-reads");
|
|
151
|
+
const { signFromJob } = await import("../../ci-evidence-from-job");
|
|
152
|
+
const reads = forgeReadsFor(forgeTargetFromEnv(process.env));
|
|
153
|
+
const done = await signFromJob({ repo, base, fromJob: args.fromJob!, checks, ...(args.claims ? { claims: args.claims } : {}), ...(args.at ? { at: args.at } : {}), reads, ...(pem ? { key: pem } : {}), push: !args.noPush });
|
|
154
|
+
if ("refused" in done) {
|
|
155
|
+
console.error(formatError({ message: `ci evidence: ${done.refused}`, hint: USAGE }));
|
|
156
|
+
return CHANT_EXIT.failed;
|
|
157
|
+
}
|
|
158
|
+
if (args.json) console.log(JSON.stringify({ signed: done.signed, skipped: done.skipped }, null, 2));
|
|
159
|
+
return CHANT_EXIT.done;
|
|
160
|
+
} catch (err) {
|
|
161
|
+
console.error(formatError({ message: err instanceof Error ? err.message : String(err), hint: USAGE }));
|
|
162
|
+
return CHANT_EXIT.failed;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
113
166
|
async function sign(ctx: CommandContext, repo: string, base: string, at: string): Promise<number> {
|
|
114
167
|
const { args } = ctx;
|
|
168
|
+
if (args.open && args.fromJob) return usage("--open and --from-job are two ways to sign; pass one");
|
|
169
|
+
if (args.open) return signOpen(ctx, repo, base);
|
|
170
|
+
if (args.fromJob) return signFromJobCommand(ctx, repo, base);
|
|
115
171
|
const fromReport = args.fromReport;
|
|
116
172
|
if (!fromReport && idsOf(args.checkId).length === 0) return usage("sign needs --check-id <id>, or --from-report <dir> in a plan note job");
|
|
117
173
|
const pem = args.key ? readFileSync(args.key, "utf-8") : process.env[CHECK_EVIDENCE_KEY_ENV];
|
|
174
|
+
let wanted: Array<{ check: string; claim?: Buffer | string }> | undefined;
|
|
175
|
+
if (!fromReport) {
|
|
176
|
+
const claim = args.claim ? readFileSync(args.claim) : undefined;
|
|
177
|
+
wanted = idsOf(args.checkId).map((check) => ({ check, ...(claim ? { claim } : {}) }));
|
|
178
|
+
}
|
|
179
|
+
const done = await signChecksOf(repo, base, at, { ...(fromReport ? { fromReport } : {}), ...(wanted ? { wanted } : {}), ...(args.planResult ? { result: args.planResult } : {}), pem, push: !args.noPush });
|
|
180
|
+
if ("usage" in done) return usage(done.usage);
|
|
181
|
+
if (fromReport) writeFileSync(join(fromReport, CHECK_EVIDENCE_FILE), JSON.stringify(done.note, null, 2) + "\n");
|
|
182
|
+
if (args.json) console.log(JSON.stringify(done.note, null, 2));
|
|
183
|
+
return done.code;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* Sign the checks of a report directory (`fromReport`) or the named ones
|
|
188
|
+
* (`wanted`) at `at`, against the runner identities at `base`. With
|
|
189
|
+
* `skipCurrent` (#4914), a check whose current evidence the notes already
|
|
190
|
+
* hold is not signed again and is listed as signed by that runner, so a
|
|
191
|
+
* pipeline that runs on every schedule signs each head once.
|
|
192
|
+
*/
|
|
193
|
+
async function signChecksOf(
|
|
194
|
+
repo: string,
|
|
195
|
+
base: string,
|
|
196
|
+
at: string,
|
|
197
|
+
opts: { fromReport?: string; wanted?: Array<{ check: string; claim?: Buffer | string }>; result?: string; pem?: string; push: boolean; skipCurrent?: boolean },
|
|
198
|
+
): Promise<{ note: CheckEvidenceNote; code: number } | { usage: string }> {
|
|
199
|
+
const { fromReport, pem } = opts;
|
|
118
200
|
const identity = pem !== undefined && pem !== "" ? "key" : process.env[RUNNER_IDENTITY_ENV] ? "oidc" : undefined;
|
|
119
201
|
const note: CheckEvidenceNote = { signed: [], skipped: [] };
|
|
120
202
|
let wanted: Array<{ check: string; claim?: Buffer | string }>;
|
|
121
|
-
if (fromReport) {
|
|
122
|
-
|
|
203
|
+
if (fromReport && isCheckReportDir(fromReport)) {
|
|
204
|
+
// #4935: a check job's report, each passed hook signed by name.
|
|
205
|
+
const decided = await checkReportChecks(fromReport, opts.result);
|
|
206
|
+
if ("error" in decided) return { usage: decided.error };
|
|
207
|
+
wanted = decided.sign;
|
|
208
|
+
note.skipped.push(...decided.skipped);
|
|
209
|
+
} else if (fromReport) {
|
|
210
|
+
const decided = planReportChecks(fromReport, opts.result);
|
|
123
211
|
wanted = decided.sign;
|
|
124
212
|
note.skipped.push(...decided.skipped);
|
|
125
213
|
} else {
|
|
126
|
-
|
|
127
|
-
wanted = idsOf(args.checkId).map((check) => ({ check, ...(claim ? { claim } : {}) }));
|
|
214
|
+
wanted = opts.wanted ?? [];
|
|
128
215
|
}
|
|
129
|
-
const finish = (code: number): number => {
|
|
130
|
-
if (fromReport) writeFileSync(join(fromReport, CHECK_EVIDENCE_FILE), JSON.stringify(note, null, 2) + "\n");
|
|
131
|
-
if (args.json) console.log(JSON.stringify(note, null, 2));
|
|
132
|
-
return code;
|
|
133
|
-
};
|
|
134
216
|
if (!identity) {
|
|
135
217
|
note.skipped.push(...wanted.map((w) => ({ check: w.check, reason: noRunnerIdentity() })));
|
|
136
218
|
console.error(`ci evidence: ${noRunnerIdentity()}, so no check was signed`);
|
|
137
|
-
return
|
|
219
|
+
return { note, code: CHANT_EXIT.done };
|
|
138
220
|
}
|
|
139
221
|
let signer: EvidenceSigner;
|
|
140
222
|
try {
|
|
141
223
|
signer = (await runnerEvidenceSigner(repo, base, pem ? { key: pem } : {}))!;
|
|
142
224
|
} catch (err) {
|
|
143
225
|
console.error(formatError({ message: err instanceof Error ? err.message : String(err), hint: USAGE }));
|
|
144
|
-
return
|
|
226
|
+
return { note, code: CHANT_EXIT.failed };
|
|
145
227
|
}
|
|
146
228
|
for (const s of note.skipped) console.error(`ci evidence: ${s.check} not signed: ${s.reason}`);
|
|
147
|
-
if (wanted.length
|
|
229
|
+
if (opts.skipCurrent && wanted.length > 0) {
|
|
230
|
+
const { tree } = commitTree(repo, at);
|
|
231
|
+
const current = (await readCheckEvidence(repo, at, base, wanted.map((w) => w.check))).filter((v) => v.status === "current");
|
|
232
|
+
for (const v of current) {
|
|
233
|
+
note.signed.push({ check: v.check, runner: v.runner, commit: v.commit, tree });
|
|
234
|
+
console.error(`ci evidence: ${v.check} at ${at.slice(0, 12)} is already signed by ${v.runner}`);
|
|
235
|
+
}
|
|
236
|
+
const kept = new Set(current.map((v) => v.check));
|
|
237
|
+
wanted = wanted.filter((w) => !kept.has(w.check));
|
|
238
|
+
}
|
|
239
|
+
if (wanted.length === 0) return { note, code: CHANT_EXIT.done };
|
|
148
240
|
const signed = await signChecks(repo, at, wanted, signer);
|
|
149
|
-
const pushed = await recordChecks(repo, signed, { push:
|
|
241
|
+
const pushed = await recordChecks(repo, signed, { push: opts.push });
|
|
150
242
|
for (const s of signed) {
|
|
151
243
|
note.signed.push({ check: s.check, runner: s.runner, commit: s.commit, tree: s.tree });
|
|
152
244
|
console.error(`ci evidence: signed ${s.check} at ${s.commit.slice(0, 12)} as ${s.runner}`);
|
|
153
245
|
}
|
|
154
|
-
if (
|
|
155
|
-
return
|
|
246
|
+
if (opts.push && !pushed.pushed && pushed.pushWarning) console.error(`ci evidence: the evidence is attached here, and the push did not land: ${pushed.pushWarning}`);
|
|
247
|
+
return { note, code: CHANT_EXIT.done };
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/** A commit's full sha and tree, read with git. */
|
|
251
|
+
function commitTree(repo: string, rev: string): { commit: string; tree: string } {
|
|
252
|
+
const read = (spec: string) => execFileSync("git", ["rev-parse", "--verify", spec], { cwd: repo, encoding: "utf-8", stdio: ["ignore", "pipe", "pipe"] }).trim();
|
|
253
|
+
return { commit: read(`${rev}^{commit}`), tree: read(`${rev}^{tree}`) };
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* `sign --open --job <job> --from-report <dir> -o <out>` (#4914): in a
|
|
258
|
+
* GitLab pipeline of the target branch, sign each open merge request's
|
|
259
|
+
* settled `job` from its artifact (../../workspace/trust/open-evidence.ts),
|
|
260
|
+
* against the policy at `--base` (the generated job passes the branch's
|
|
261
|
+
* commit). The branch is `--branch`, else the pipeline's own. Exits 0 once
|
|
262
|
+
* each merge request is signed or said, and 1 when the job's runner
|
|
263
|
+
* identity is not one the policy at base lists.
|
|
264
|
+
*/
|
|
265
|
+
async function signOpen(ctx: CommandContext, repo: string, base: string): Promise<number> {
|
|
266
|
+
const { args } = ctx;
|
|
267
|
+
if (!args.ciJob || !/^[A-Za-z0-9][A-Za-z0-9_.-]*$/.test(args.ciJob)) return usage("sign --open needs the job to sign for, by name: --job plan");
|
|
268
|
+
if (!args.fromReport) return usage("sign --open needs the job's report directory as its artifact keeps it: --from-report .chant/pr");
|
|
269
|
+
if (!args.output) return usage("sign --open needs where to keep each merge request's evidence.json: -o .chant/evidence/<job>");
|
|
270
|
+
if (args.checkId || args.at || args.planResult) return usage("sign --open finds each merge request's head and its job's result itself, so it takes no --check-id, --at or --result");
|
|
271
|
+
const branch = args.branch ?? process.env.CI_COMMIT_BRANCH;
|
|
272
|
+
if (!branch) return usage("sign --open signs for the merge requests into a branch: run it in a branch pipeline, or pass --branch <branch>");
|
|
273
|
+
const pem = args.key ? readFileSync(args.key, "utf-8") : process.env[CHECK_EVIDENCE_KEY_ENV];
|
|
274
|
+
const { forgeFromEnv } = await import("../../pr-forge");
|
|
275
|
+
const { signOpenReports } = await import("../../workspace/trust/open-evidence");
|
|
276
|
+
// The notes there are the ones to skip a head already signed by, and to add to.
|
|
277
|
+
spawnSync("git", ["fetch", "--quiet", "--no-tags", "origin", "+refs/notes/chant/evidence:refs/notes/chant/evidence"], { cwd: repo, encoding: "utf-8" });
|
|
278
|
+
let failed = false;
|
|
279
|
+
let done: Awaited<ReturnType<typeof signOpenReports>>;
|
|
280
|
+
try {
|
|
281
|
+
done = await signOpenReports({
|
|
282
|
+
forge: forgeFromEnv("gitlab"),
|
|
283
|
+
branch,
|
|
284
|
+
job: args.ciJob,
|
|
285
|
+
artifactDir: args.fromReport,
|
|
286
|
+
out: args.output,
|
|
287
|
+
...(args.noForks ? { noForks: true } : {}),
|
|
288
|
+
fetchHead: (pr, head) => fetchMergeRequestHead(repo, pr, head),
|
|
289
|
+
sign: async (dir, head, result) => {
|
|
290
|
+
const r = await signChecksOf(repo, base, head, { fromReport: dir, result, ...(pem ? { pem } : {}), push: !args.noPush, skipCurrent: true });
|
|
291
|
+
if ("usage" in r) throw new Error(r.usage);
|
|
292
|
+
if (r.code !== CHANT_EXIT.done) failed = true;
|
|
293
|
+
return r.note;
|
|
294
|
+
},
|
|
295
|
+
});
|
|
296
|
+
} catch (err) {
|
|
297
|
+
console.error(formatError({ message: err instanceof Error ? err.message : String(err), hint: USAGE }));
|
|
298
|
+
return CHANT_EXIT.failed;
|
|
299
|
+
}
|
|
300
|
+
for (const w of done.warnings) console.error(`ci evidence: ${w}`);
|
|
301
|
+
for (const d of done.done) {
|
|
302
|
+
if (d.skipped) console.error(`ci evidence: !${d.pr}: ${d.skipped}`);
|
|
303
|
+
else console.error(`ci evidence: !${d.pr} at ${d.head.slice(0, 12)}: signed ${d.note!.signed.map((s) => s.check).join(", ") || "nothing"}`);
|
|
304
|
+
}
|
|
305
|
+
if (done.done.length === 0) console.error(`ci evidence: no open merge request into ${branch} has a ${args.ciJob} job`);
|
|
306
|
+
if (args.json) console.log(JSON.stringify(done.done, null, 2));
|
|
307
|
+
return failed ? CHANT_EXIT.failed : CHANT_EXIT.done;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
/** Fetch merge request `pr`'s head (`refs/merge-requests/<iid>/head`, a fork's too), else the commit itself; true once it is here. */
|
|
311
|
+
function fetchMergeRequestHead(repo: string, pr: number, head: string): boolean {
|
|
312
|
+
const here = () => spawnSync("git", ["cat-file", "-e", `${head}^{commit}`], { cwd: repo }).status === 0;
|
|
313
|
+
if (here()) return true;
|
|
314
|
+
spawnSync("git", ["fetch", "--quiet", "--no-tags", "origin", `refs/merge-requests/${pr}/head`], { cwd: repo, encoding: "utf-8" });
|
|
315
|
+
if (here()) return true;
|
|
316
|
+
spawnSync("git", ["fetch", "--quiet", "--no-tags", "origin", head], { cwd: repo, encoding: "utf-8" });
|
|
317
|
+
return here();
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
/** Whether `dir` holds a check job's report and no plan report (#4935). */
|
|
321
|
+
function isCheckReportDir(dir: string): boolean {
|
|
322
|
+
return existsSync(join(dir, "check-hooks.json")) && !existsSync(join(dir, "pr-plan.json")) && !existsSync(join(dir, "pr-plan-note.json"));
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
/**
|
|
326
|
+
* The hooks to sign from a check job's report (#4935): each hook whose every
|
|
327
|
+
* run passed, with its runs as the claim, as the check runner signs them
|
|
328
|
+
* (../../components/check-steps.ts). The report is the check job's, which ran
|
|
329
|
+
* the change's code, so it is read as data: a hook with no name or outcome is
|
|
330
|
+
* left out. A job `result` other than success or failure signs none.
|
|
331
|
+
*/
|
|
332
|
+
async function checkReportChecks(dir: string, result: string | undefined): Promise<{ sign: Array<{ check: string; claim: string }>; skipped: CheckEvidenceNote["skipped"] } | { error: string }> {
|
|
333
|
+
const { CHECK_HOOKS_REPORT_FILE, passedCheckHooks } = await import("../../components/check-hooks");
|
|
334
|
+
let doc: unknown;
|
|
335
|
+
try {
|
|
336
|
+
doc = JSON.parse(readFileSync(join(dir, CHECK_HOOKS_REPORT_FILE), "utf-8"));
|
|
337
|
+
} catch (err) {
|
|
338
|
+
return { error: `--from-report ${dir}: ${CHECK_HOOKS_REPORT_FILE} does not read: ${err instanceof Error ? err.message : String(err)}` };
|
|
339
|
+
}
|
|
340
|
+
const hooks = doc && typeof doc === "object" && Array.isArray((doc as { hooks?: unknown }).hooks) ? ((doc as { hooks: unknown[] }).hooks as Array<Record<string, unknown>>) : undefined;
|
|
341
|
+
if (!hooks) return { error: `--from-report ${dir}: ${CHECK_HOOKS_REPORT_FILE} lists no hooks` };
|
|
342
|
+
const runs = hooks.filter((h) => h && typeof h.name === "string" && h.name.length > 0 && h.name.length <= 200 && (h.outcome === "passed" || h.outcome === "failed" || h.outcome === "skipped"));
|
|
343
|
+
const passed = passedCheckHooks(runs as unknown as Parameters<typeof passedCheckHooks>[0]);
|
|
344
|
+
if (result !== undefined && result !== "success" && result !== "failure") {
|
|
345
|
+
return { sign: [], skipped: passed.map((p) => ({ check: p.check, reason: `the check job's result is ${result}` })) };
|
|
346
|
+
}
|
|
347
|
+
const signed = new Set(passed.map((p) => p.check));
|
|
348
|
+
const skipped = [...new Set(runs.map((h) => h.name as string))].filter((n) => !signed.has(n)).map((check) => ({ check, reason: "the hook did not pass in the check job" }));
|
|
349
|
+
return { sign: passed.map((p) => ({ check: p.check, claim: JSON.stringify(p.runs) })), skipped };
|
|
156
350
|
}
|
|
157
351
|
|
|
158
352
|
async function verify(ctx: CommandContext, repo: string, base: string, at: string): Promise<number> {
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* `chant ci forge-check [--env <env>] [--member <name>] [--forge <forge>]
|
|
3
|
-
* [--repo <owner/name>] [--branch <default>] [--require-clouds]
|
|
4
|
-
* (#4608): read the live forge, the clouds and
|
|
5
|
-
* pull-request pipelines `ci.identity.cloud` gives
|
|
6
|
-
* per expected setting.
|
|
3
|
+
* [--repo <owner/name>] [--branch <default>] [--require-clouds]
|
|
4
|
+
* [--ref-gate-status] [--json]` (#4608): read the live forge, the clouds and
|
|
5
|
+
* Pulumi Cloud against the pull-request pipelines `ci.identity.cloud` gives
|
|
6
|
+
* the workspace, one row per expected setting. With `--ref-gate-status`
|
|
7
|
+
* (#4913), for pipelines built with it, the default branch also requires
|
|
8
|
+
* the ref gate's status, named as the policy at `origin/<default>` (else
|
|
9
|
+
* `HEAD`) names it. Read-only. Exits chant's `failed` (1) on a
|
|
7
10
|
* mismatch, or with --require-clouds on a cloud left unchecked; `done` (0)
|
|
8
11
|
* otherwise. See ../../forge-check/index.ts.
|
|
9
12
|
*/
|
|
@@ -12,7 +15,7 @@ import type { CloudIdentityDeclaration } from "../../ci-identity";
|
|
|
12
15
|
import type { ForgeFetch } from "../../pr-forge";
|
|
13
16
|
import type { CommandContext } from "../registry";
|
|
14
17
|
|
|
15
|
-
const USAGE = "chant ci forge-check [--env <env>] [--member <name>] [--forge github|gitlab|forgejo] [--repo <owner/name>] [--branch <default>] [--require-clouds] [--json]";
|
|
18
|
+
const USAGE = "chant ci forge-check [--env <env>] [--member <name>] [--forge github|gitlab|forgejo] [--repo <owner/name>] [--branch <default>] [--require-clouds] [--ref-gate-status] [--json]";
|
|
16
19
|
|
|
17
20
|
/** The environment chant's generated pull-request pipelines default to. */
|
|
18
21
|
const DEFAULT_ENV = "production";
|
|
@@ -62,29 +65,39 @@ export async function runCiForgeCheck(ctx: CommandContext): Promise<number> {
|
|
|
62
65
|
});
|
|
63
66
|
const words = activeProductWords();
|
|
64
67
|
const host = target.host;
|
|
68
|
+
// #4913: with --ref-gate-status the default branch requires the ref gate's status too, named as the policy names it.
|
|
69
|
+
let gate: { status?: string; note?: string; problem?: string } = {};
|
|
70
|
+
const statusFor = args.refGateStatus ? (await import("../../ref-gate-rules")).refGateStatusFor : undefined;
|
|
65
71
|
const result = await forgeCheck(
|
|
66
72
|
{
|
|
67
73
|
target,
|
|
68
74
|
words,
|
|
69
75
|
...(args.requireClouds ? { requireClouds: true } : {}),
|
|
70
|
-
contract: (live) =>
|
|
71
|
-
|
|
76
|
+
contract: (live) => {
|
|
77
|
+
const defaultBranch = args.branch ?? live.defaultBranch ?? "main";
|
|
78
|
+
if (statusFor) gate = statusFor(found?.dir ?? process.cwd(), defaultBranch);
|
|
79
|
+
const status = gate.status;
|
|
80
|
+
return pipelineContract({
|
|
72
81
|
forge: target.kind,
|
|
73
82
|
repository: {
|
|
74
83
|
host,
|
|
75
84
|
path: live.path ?? target.repo,
|
|
76
|
-
defaultBranch
|
|
85
|
+
defaultBranch,
|
|
77
86
|
...(live.ownerId ? { ownerId: live.ownerId } : {}),
|
|
78
87
|
...(live.repoId ? { repoId: live.repoId } : {}),
|
|
79
88
|
},
|
|
80
89
|
pipelines,
|
|
81
90
|
words,
|
|
82
|
-
|
|
91
|
+
...(status ? { refGateStatus: status } : {}),
|
|
92
|
+
});
|
|
93
|
+
},
|
|
83
94
|
},
|
|
84
95
|
{ fetch: globalThis.fetch as unknown as ForgeFetch, env: process.env },
|
|
85
96
|
);
|
|
97
|
+
if (gate.problem) return fail(`--ref-gate-status: ${gate.problem}`);
|
|
86
98
|
if (args.json) console.log(JSON.stringify(result, null, 2));
|
|
87
99
|
else console.log(describeForgeCheck(result));
|
|
100
|
+
if (gate.note) console.error(`ci forge-check: ${gate.note}`);
|
|
88
101
|
if (!decl) console.error("ci forge-check: no ci.identity.cloud in the workspace declaration, so no trust was checked");
|
|
89
102
|
else if (pipelines.length === 0) console.error(`ci forge-check: no rule of ci.identity.cloud covers environment ${env}, so no trust was checked`);
|
|
90
103
|
return forgeCheckExit(result);
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `chant dev generated-check [<render>...] [--json]` (#4909): render the
|
|
3
|
+
* product's declared generated files (`chantGenerated` in its root
|
|
4
|
+
* package.json) into a directory under the OS temp directory, compare each
|
|
5
|
+
* with the committed file, and exit 1 naming every one that drifted. The
|
|
6
|
+
* directory is left in place and printed. Exit 2 when the product declares
|
|
7
|
+
* no `chantGenerated`.
|
|
8
|
+
*/
|
|
9
|
+
import { checkGenerated, readGeneratedCheckConfig } from "../../generated-check";
|
|
10
|
+
import { formatError } from "../format";
|
|
11
|
+
import type { CommandContext } from "../registry";
|
|
12
|
+
|
|
13
|
+
const USAGE = "chant dev generated-check [<render>...] [--json]";
|
|
14
|
+
|
|
15
|
+
export async function runDevGeneratedCheck(ctx: CommandContext): Promise<number> {
|
|
16
|
+
const productDir = process.cwd();
|
|
17
|
+
let config;
|
|
18
|
+
try {
|
|
19
|
+
config = readGeneratedCheckConfig(productDir);
|
|
20
|
+
} catch (err) {
|
|
21
|
+
console.error(formatError({ message: err instanceof Error ? err.message : String(err), hint: USAGE }));
|
|
22
|
+
return 2;
|
|
23
|
+
}
|
|
24
|
+
if (!config) {
|
|
25
|
+
console.error(formatError({ message: "package.json here declares no chantGenerated", hint: USAGE }));
|
|
26
|
+
return 2;
|
|
27
|
+
}
|
|
28
|
+
const only = (ctx.args.positionals ?? []).slice(1);
|
|
29
|
+
const result = await checkGenerated(productDir, config, { only });
|
|
30
|
+
if (ctx.args.json) {
|
|
31
|
+
console.log(JSON.stringify(result, null, 2));
|
|
32
|
+
} else {
|
|
33
|
+
for (const f of result.matched) console.error(` generated-check: ${f} matches its render`);
|
|
34
|
+
for (const p of result.problems) console.error(`generated-check: ${p}`);
|
|
35
|
+
console.error(`generated-check: the renders are in ${result.out}`);
|
|
36
|
+
if (result.ok) console.error(`generated-check: ${result.matched.length} files match ${result.renders.length} renders`);
|
|
37
|
+
}
|
|
38
|
+
return result.ok ? 0 : 1;
|
|
39
|
+
}
|
|
@@ -517,6 +517,26 @@ describe("runLifecycleDiff --live", () => {
|
|
|
517
517
|
expect(seen?.attributes?.chart).toBe("web-1.2.3");
|
|
518
518
|
});
|
|
519
519
|
|
|
520
|
+
test("--live --json writes a lexicon's liveAbsentStatus as its section's absent, and nothing for one that sets none (#4896)", async () => {
|
|
521
|
+
buildMock.mockResolvedValue(makeBuildResult({ sql: ["events"], aws: ["bucket"] }));
|
|
522
|
+
fetchLifecycleMock.mockResolvedValue(undefined);
|
|
523
|
+
readSnapshotMock.mockResolvedValue(null);
|
|
524
|
+
const plugins: LexiconPlugin[] = [
|
|
525
|
+
{ ...createMockPlugin({ name: "sql", describeResources: staticObservation({}) }), liveAbsentStatus: "missing" },
|
|
526
|
+
createMockPlugin({ name: "aws", describeResources: staticObservation({}) }),
|
|
527
|
+
];
|
|
528
|
+
await runLifecycleDiff({
|
|
529
|
+
args: makeArgs({ command: "state", path: "diff", extraPositional: "prod", live: true, json: true }),
|
|
530
|
+
plugins,
|
|
531
|
+
serializers: plugins.map((p) => p.serializer),
|
|
532
|
+
} as never);
|
|
533
|
+
const payload = JSON.parse(stdoutBuf.join("\n")) as { lexicons: Record<string, { absent?: string; resources?: { missing: string[] } }> };
|
|
534
|
+
expect(payload.lexicons.sql.resources?.missing).toEqual(["events"]);
|
|
535
|
+
expect(payload.lexicons.sql.absent).toBe("missing");
|
|
536
|
+
expect(payload.lexicons.aws.resources?.missing).toEqual(["bucket"]);
|
|
537
|
+
expect("absent" in payload.lexicons.aws).toBe(false);
|
|
538
|
+
});
|
|
539
|
+
|
|
520
540
|
test("--live lists artifacts for a configured lexicon with NO built entities — the deploy-step estate shape", async () => {
|
|
521
541
|
// kubemicrovm-ops: helm is a configured lexicon whose releases exist only
|
|
522
542
|
// as component helm-upgrade steps, so the built manifest carries no helm
|
|
@@ -811,6 +811,8 @@ interface LiveDiffOutcome {
|
|
|
811
811
|
string,
|
|
812
812
|
{
|
|
813
813
|
resources?: LiveDiffResult;
|
|
814
|
+
/** The lexicon's `liveAbsentStatus` (#4896): what an entity in `resources.missing` is. Present only when the lexicon sets it. */
|
|
815
|
+
absent?: "pending" | "missing";
|
|
814
816
|
observed?: Record<string, ResourceMetadata>;
|
|
815
817
|
/** Declared entities the lexicon could not read (#1089), keyed by name. */
|
|
816
818
|
unobserved?: Record<string, UnobservedEntity>;
|
|
@@ -997,6 +999,8 @@ async function runLifecycleDiffLive(args: LiveDiffArgs): Promise<LiveDiffOutcome
|
|
|
997
999
|
if (args.json) {
|
|
998
1000
|
const entry = (byLexicon[lexiconName] ??= {});
|
|
999
1001
|
entry.resources = diff;
|
|
1002
|
+
// What a confirmed-absent entity is, when the lexicon says (#4896); left out for every other lexicon.
|
|
1003
|
+
if (plugin.liveAbsentStatus) entry.absent = plugin.liveAbsentStatus;
|
|
1000
1004
|
entry.observed = observedNow; // live state (#862) — status/attributes per resource
|
|
1001
1005
|
if (Object.keys(observed.unobserved).length > 0) entry.unobserved = observed.unobserved;
|
|
1002
1006
|
} else renderLiveDiff(lexiconName, args.environment, diff);
|
|
@@ -7,12 +7,13 @@
|
|
|
7
7
|
import { spawnSync } from "node:child_process";
|
|
8
8
|
import { join, resolve } from "node:path";
|
|
9
9
|
import { checkBundle, readBundleCheckConfig, type BundleCheckResult } from "../../bundle-check";
|
|
10
|
-
import { installLocalChant, LocalChantError, productManifests, resetLocalChant, type LocalChantResult } from "../../local-chant";
|
|
10
|
+
import { installLocalChant, LocalChantError, localChantImage, productManifests, resetLocalChant, type LocalChantResult } from "../../local-chant";
|
|
11
11
|
import { formatError } from "../format";
|
|
12
12
|
import type { CommandContext } from "../registry";
|
|
13
13
|
|
|
14
14
|
const LOCAL_USAGE = "chant dev local <chant-dir> [--with <package>]... [--build '<command>'] [--json] | chant dev local --reset [--build '<command>']";
|
|
15
15
|
const CHECK_USAGE = "chant dev bundle-check [<package-dir>] [--json]";
|
|
16
|
+
const IMAGE_USAGE = "chant dev local-image [--with <package>]... [--json] [-- <docker build arguments>...]";
|
|
16
17
|
|
|
17
18
|
/** The product packages that declare `chantBundleCheck`, as directories. */
|
|
18
19
|
function checkedPackages(productDir: string): string[] {
|
|
@@ -75,6 +76,7 @@ export async function runDevLocal(ctx: CommandContext): Promise<number> {
|
|
|
75
76
|
console.log(JSON.stringify({ reset, local: installed ? { commit: installed.mark.commit, dir: installed.mark.dir, packed: installed.packed.map((p) => ({ name: p.name, version: p.version })), marked: installed.marked } : undefined, checks: results }, null, 2));
|
|
76
77
|
} else if (installed) {
|
|
77
78
|
console.log(`chant commit: ${installed.mark.commit}`);
|
|
79
|
+
console.log(`chant version: ${installed.packed[0]?.version ?? "none"} (local build)`);
|
|
78
80
|
}
|
|
79
81
|
return ok ? 0 : 1;
|
|
80
82
|
}
|
|
@@ -104,3 +106,39 @@ export async function runDevBundleCheck(ctx: CommandContext): Promise<number> {
|
|
|
104
106
|
if (ctx.args.json) console.log(JSON.stringify(results, null, 2));
|
|
105
107
|
return ok ? 0 : 1;
|
|
106
108
|
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* `chant dev local-image [--with <package>]... [-- <docker build arguments>]`
|
|
112
|
+
* (#4909): build a product's image with the chant the product has installed.
|
|
113
|
+
* With no docker arguments it prints the chant version the image would
|
|
114
|
+
* install (the pin, or `local-<commit>`), for a label that rebuilds the image
|
|
115
|
+
* when it changes; `--json` prints the version, the mark and the arguments.
|
|
116
|
+
* With them it runs `docker build` with `--build-arg CHANT_VERSION=<version>`
|
|
117
|
+
* and, for a `chant dev local` build, `--build-context
|
|
118
|
+
* chant-local=<product>/.chant-local` first. `--with` names a package the
|
|
119
|
+
* image installs from the tarballs besides core. Exit 1 when the local build's
|
|
120
|
+
* tarballs are missing or docker fails, 2 for a usage error.
|
|
121
|
+
*/
|
|
122
|
+
export async function runDevLocalImage(ctx: CommandContext): Promise<number> {
|
|
123
|
+
const docker = (ctx.args.positionals ?? []).slice(1);
|
|
124
|
+
let image;
|
|
125
|
+
try {
|
|
126
|
+
image = localChantImage(process.cwd(), { with: ctx.args.withPackages });
|
|
127
|
+
} catch (err) {
|
|
128
|
+
if (!(err instanceof LocalChantError)) throw err;
|
|
129
|
+
console.error(formatError({ message: err.message, hint: IMAGE_USAGE }));
|
|
130
|
+
return 1;
|
|
131
|
+
}
|
|
132
|
+
if (docker.length === 0) {
|
|
133
|
+
if (ctx.args.json) console.log(JSON.stringify(image, null, 2));
|
|
134
|
+
else console.log(image.version);
|
|
135
|
+
return 0;
|
|
136
|
+
}
|
|
137
|
+
console.error(`chant dev local-image: docker build with chant ${image.version}`);
|
|
138
|
+
const r = spawnSync("docker", ["build", ...image.args, ...docker], { cwd: process.cwd(), stdio: "inherit" });
|
|
139
|
+
if (r.error) {
|
|
140
|
+
console.error(formatError({ message: `docker build: ${r.error.message}` }));
|
|
141
|
+
return 1;
|
|
142
|
+
}
|
|
143
|
+
return r.status === 0 ? 0 : 1;
|
|
144
|
+
}
|
package/src/cli/handlers/pr.ts
CHANGED
|
@@ -1033,10 +1033,14 @@ async function newMigrations(p: Prepared): Promise<PrMigrationFile[]> {
|
|
|
1033
1033
|
* the Ops cannot be read, nothing is checked and the plan goes on. The
|
|
1034
1034
|
* generated plan holds no forge token (#4295), so there the plan-note job's
|
|
1035
1035
|
* `pr-post` asks instead, reading the Ops at the target branch's commit.
|
|
1036
|
+
* A product plan's own watches (#4888) come from `CHANT_PLAN_WATCHES`, which
|
|
1037
|
+
* the generated note job sets from the pipeline.
|
|
1036
1038
|
*/
|
|
1037
1039
|
async function overdueOps(forge: PrForge | undefined, member: string | undefined): Promise<PrOverdue[]> {
|
|
1038
|
-
const { overdueOpsAt } = await import("../../op/schedule-overdue");
|
|
1039
|
-
|
|
1040
|
+
const { overdueOpsAt, plannedWatchesFromEnv } = await import("../../op/schedule-overdue");
|
|
1041
|
+
const log = (line: string): void => console.error(formatWarning({ message: line }));
|
|
1042
|
+
const watches = plannedWatchesFromEnv(process.env, log);
|
|
1043
|
+
return overdueOpsAt({ forge, cwd: resolve("."), ...(member ? { member } : {}), ...(watches.length > 0 ? { watches } : {}), log });
|
|
1040
1044
|
}
|
|
1041
1045
|
|
|
1042
1046
|
/** chant components pr-apply --base <ref> [--pr <n>] [--env <env>] [--gate <name>] [--forge <kind>] [--require-review] [--before-merge [--requires <list>]] [--output <dir>] [--json] [--events-json] [--report-url <url>] */
|
|
@@ -2817,13 +2821,41 @@ export async function runComponentsPrPost(ctx: CommandContext): Promise<number>
|
|
|
2817
2821
|
// #4628: the target branch's commit for the note's tip line, and the job summary where the forge keeps one.
|
|
2818
2822
|
...(args.tip ? { baseTip: args.tip } : {}),
|
|
2819
2823
|
...(args.forge !== "gitlab" && process.env.GITHUB_STEP_SUMMARY ? { summaryFile: process.env.GITHUB_STEP_SUMMARY } : {}),
|
|
2824
|
+
// #4899: the product plan job's run record, kept on chant/lifecycle with the note.
|
|
2825
|
+
...(args.recordRun ? { recordRun: await planRunRecorder(args.forge as ForgeKind, args.recordRun) } : {}),
|
|
2820
2826
|
});
|
|
2821
2827
|
for (const message of posted.warnings) console.error(formatWarning({ message }));
|
|
2822
2828
|
if (posted.refused) console.error(formatWarning({ message: `the plan report was not used: ${posted.refused}` }));
|
|
2823
|
-
console.error(formatInfo(`pr-post: ${prStatusContext("plan", member)} ${posted.state}: ${posted.description}${posted.noted ? "; note posted" : ""}`));
|
|
2829
|
+
console.error(formatInfo(`pr-post: ${prStatusContext("plan", member)} ${posted.state}: ${posted.description}${posted.noted ? "; note posted" : ""}${posted.recorded ? `; run ${posted.recorded} recorded` : ""}`));
|
|
2824
2830
|
return 0;
|
|
2825
2831
|
}
|
|
2826
2832
|
|
|
2833
|
+
/**
|
|
2834
|
+
* How `pr-post --record-run <plan job>` keeps a product plan job's run
|
|
2835
|
+
* record (#4899): its run is this run on GitHub and Forgejo, named by the
|
|
2836
|
+
* plan job's key, and this pipeline on GitLab, where a re-plan's note job
|
|
2837
|
+
* runs in the re-plan's own pipeline. The record is appended to the run
|
|
2838
|
+
* ledger once, by its id, and `chant/lifecycle` is pushed.
|
|
2839
|
+
*/
|
|
2840
|
+
async function planRunRecorder(forge: ForgeKind, job: string): Promise<import("../../pr-post").PlanRunRecorder> {
|
|
2841
|
+
const { resolveCiJob, resolveCiRun } = await import("../../lifecycle/release-ledger");
|
|
2842
|
+
const ci = forge === "gitlab" ? resolveCiRun(process.env) : resolveCiJob(process.env);
|
|
2843
|
+
const origin = ci ? (forge === "gitlab" ? ci.runOrigin : { ...ci.runOrigin, jobId: job }) : undefined;
|
|
2844
|
+
return { ...(origin ? { origin } : {}), keep: keepPlanRunRecord };
|
|
2845
|
+
}
|
|
2846
|
+
|
|
2847
|
+
/** Append `record` to the run ledger unless a record with its id is there, and push `chant/lifecycle` (#4899). Returns a warning when the push did not land. */
|
|
2848
|
+
async function keepPlanRunRecord(record: import("../../op/runtime").OpRunRecordInput): Promise<string | undefined> {
|
|
2849
|
+
const { fetchLifecycleStatus, pushLifecycleReport } = await import("../../lifecycle/git");
|
|
2850
|
+
const { appendRunRecord, readRunLedger } = await import("../../lifecycle/run-ledger");
|
|
2851
|
+
await fetchLifecycleStatus().catch(() => undefined);
|
|
2852
|
+
const { records } = await readRunLedger(record.env, record.op);
|
|
2853
|
+
if (records.some((r) => r.id === record.id)) return undefined;
|
|
2854
|
+
await appendRunRecord(record);
|
|
2855
|
+
const pushed = await pushLifecycleReport();
|
|
2856
|
+
return pushed.pushed ? undefined : `the plan job's run record is on this job's chant/lifecycle only: ${pushed.pushWarning ?? "the push did not land"}`;
|
|
2857
|
+
}
|
|
2858
|
+
|
|
2827
2859
|
/**
|
|
2828
2860
|
* The description check pr-post runs after the note (#4629), when the
|
|
2829
2861
|
* responses turn it on (`--respond description=check`, or `CHANT_RESPOND`):
|
|
@@ -2901,7 +2933,9 @@ async function runComponentsPrPostStale(ctx: CommandContext): Promise<number> {
|
|
|
2901
2933
|
* (`postOpenPlanReports`, ../../pr-post.ts). The branch is `--branch`, else
|
|
2902
2934
|
* the pipeline's own (`CI_COMMIT_BRANCH`). The plan job is `plan`, or
|
|
2903
2935
|
* `<member>-plan` with `--member`, as the gitlab lexicon names it, and the
|
|
2904
|
-
* artifact path is `--output` from the repository root.
|
|
2936
|
+
* artifact path is `--output` from the repository root. With
|
|
2937
|
+
* `--evidence-dir <dir>` (#4914) each note ends with the checks the
|
|
2938
|
+
* pipeline's signing job signed for that head. It exits 0 once it
|
|
2905
2939
|
* has posted, as `pr-post` does.
|
|
2906
2940
|
*/
|
|
2907
2941
|
async function runComponentsPrPostOpen(ctx: CommandContext): Promise<number> {
|
|
@@ -2940,6 +2974,10 @@ async function runComponentsPrPostOpen(ctx: CommandContext): Promise<number> {
|
|
|
2940
2974
|
...(description ? { description } : {}),
|
|
2941
2975
|
// #4628: the target branch's commit this pipeline runs at, which each note's tip line names.
|
|
2942
2976
|
...(args.tip ? { baseTip: args.tip } : {}),
|
|
2977
|
+
// #4899: each product plan job's run record, from its artifacts.
|
|
2978
|
+
...(args.recordRun ? { recordRun: { ...(process.env.CI_PROJECT_PATH ? { repo: process.env.CI_PROJECT_PATH } : {}), keep: keepPlanRunRecord } } : {}),
|
|
2979
|
+
// #4914: each merge request's evidence.json from this pipeline's signing job, for the note's checks line.
|
|
2980
|
+
...(args.evidenceDir ? { evidenceDir: resolve(args.evidenceDir) } : {}),
|
|
2943
2981
|
});
|
|
2944
2982
|
} catch (err) {
|
|
2945
2983
|
return fail(err instanceof Error ? err.message : String(err));
|
|
@@ -2953,7 +2991,7 @@ async function runComponentsPrPostOpen(ctx: CommandContext): Promise<number> {
|
|
|
2953
2991
|
const posted = p.posted!;
|
|
2954
2992
|
for (const message of posted.warnings) console.error(formatWarning({ message: `!${p.pr}: ${message}` }));
|
|
2955
2993
|
if (posted.refused) console.error(formatWarning({ message: `!${p.pr}: the plan report was not used: ${posted.refused}` }));
|
|
2956
|
-
console.error(formatInfo(`pr-post: !${p.pr} ${prStatusContext("plan", member)} ${posted.state}: ${posted.description}${posted.noted ? "; note posted" : ""}`));
|
|
2994
|
+
console.error(formatInfo(`pr-post: !${p.pr} ${prStatusContext("plan", member)} ${posted.state}: ${posted.description}${posted.noted ? "; note posted" : ""}${posted.recorded ? `; run ${posted.recorded} recorded` : ""}`));
|
|
2957
2995
|
}
|
|
2958
2996
|
if (done.posts.length === 0) console.error(formatInfo(`pr-post: no open merge request into ${branch} has a ${gitlabPlanJobName(member)} job`));
|
|
2959
2997
|
return 0;
|
|
@@ -88,6 +88,10 @@ async function runOpWaveJobCommand(ctx: CommandContext): Promise<number> {
|
|
|
88
88
|
console.error(formatError({ message: `--decide and --${args.share !== undefined ? "share" : "group"} are two different jobs; pass one` }));
|
|
89
89
|
return 1;
|
|
90
90
|
}
|
|
91
|
+
if (args.policyOnly && (args.share !== undefined || args.group !== undefined)) {
|
|
92
|
+
console.error(formatError({ message: `--policy-only runs a wave's policy in its own or its deciding job; a --${args.share !== undefined ? "share" : "group"} job has none of its own` }));
|
|
93
|
+
return 1;
|
|
94
|
+
}
|
|
91
95
|
let spec: OpWavesSpec | undefined;
|
|
92
96
|
const job = { ...(args.share !== undefined ? { share: args.share } : {}), ...(args.group !== undefined ? { group: args.group } : {}) };
|
|
93
97
|
if (args.eventsJson && args.json) {
|
|
@@ -113,11 +117,14 @@ async function runOpWaveJobCommand(ctx: CommandContext): Promise<number> {
|
|
|
113
117
|
specFile: relative(process.cwd(), path),
|
|
114
118
|
wave: args.wave,
|
|
115
119
|
...(args.decide ? { decide: true } : {}),
|
|
120
|
+
...(args.policyOnly ? { policyOnly: true } : {}),
|
|
116
121
|
...(args.share !== undefined ? { share: args.share } : {}),
|
|
117
122
|
...(args.group !== undefined ? { group: args.group } : {}),
|
|
118
123
|
...(args.base ? { base: args.base } : {}),
|
|
119
124
|
});
|
|
120
125
|
if (args.json) console.log(JSON.stringify(result, null, 2));
|
|
126
|
+
// #4926: the policy step applied nothing; the wave's own step tells people how it went.
|
|
127
|
+
if (args.policyOnly) return result.exitCode;
|
|
121
128
|
// #3761: tell people, when the spec says where. Delivery never changes the exit code.
|
|
122
129
|
await notifyOpWave(spec, args.wave, { result }, job);
|
|
123
130
|
// #4629: a refused wave's diff and a failed apply's triage, on the pull request or a tracking issue.
|