@intentius/chant 0.124.87 → 0.124.89
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 +47 -0
- package/dist/actor.d.ts.map +1 -0
- package/dist/actor.js +56 -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 +203 -2
- package/dist/ci-base.d.ts +30 -0
- package/dist/ci-base.d.ts.map +1 -0
- package/dist/ci-base.js +33 -0
- package/dist/ci-comment-commands.d.ts +177 -0
- package/dist/ci-comment-commands.d.ts.map +1 -0
- package/dist/ci-comment-commands.js +325 -0
- package/dist/ci-comment-replies.d.ts +40 -0
- package/dist/ci-comment-replies.d.ts.map +1 -0
- package/dist/ci-comment-replies.js +59 -0
- 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 +128 -0
- package/dist/ci-evidence-from-job.d.ts.map +1 -0
- package/dist/ci-evidence-from-job.js +203 -0
- package/dist/ci-evidence-jobs.d.ts +68 -4
- package/dist/ci-evidence-jobs.d.ts.map +1 -1
- package/dist/ci-evidence-jobs.js +82 -5
- 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 +65 -10
- package/dist/ci-image.d.ts.map +1 -1
- package/dist/ci-image.js +101 -22
- 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-note-commands.d.ts +63 -3
- package/dist/ci-note-commands.d.ts.map +1 -1
- package/dist/ci-note-commands.js +69 -35
- package/dist/ci-product-words.d.ts +62 -1
- package/dist/ci-product-words.d.ts.map +1 -1
- package/dist/ci-product-words.js +52 -1
- package/dist/ci-product.d.ts +52 -2
- package/dist/ci-product.d.ts.map +1 -1
- package/dist/ci-product.js +51 -2
- package/dist/cli/commands/build.d.ts.map +1 -1
- package/dist/cli/commands/build.js +29 -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/approve.d.ts.map +1 -1
- package/dist/cli/handlers/approve.js +2 -1
- 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 +1 -1
- package/dist/cli/handlers/ci-check.d.ts.map +1 -1
- package/dist/cli/handlers/ci-check.js +37 -7
- package/dist/cli/handlers/ci-evidence.d.ts.map +1 -1
- package/dist/cli/handlers/ci-evidence.js +255 -20
- 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/components.d.ts.map +1 -1
- package/dist/cli/handlers/components.js +3 -1
- package/dist/cli/handlers/generated-check.d.ts +11 -0
- package/dist/cli/handlers/generated-check.d.ts.map +1 -0
- package/dist/cli/handlers/generated-check.js +71 -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/lock.d.ts.map +1 -1
- package/dist/cli/handlers/lock.js +121 -4
- package/dist/cli/handlers/pr-comment.d.ts +21 -0
- package/dist/cli/handlers/pr-comment.d.ts.map +1 -0
- package/dist/cli/handlers/pr-comment.js +112 -0
- package/dist/cli/handlers/pr-env.d.ts.map +1 -1
- package/dist/cli/handlers/pr-env.js +6 -3
- package/dist/cli/handlers/pr.d.ts +23 -1
- package/dist/cli/handlers/pr.d.ts.map +1 -1
- package/dist/cli/handlers/pr.js +97 -14
- package/dist/cli/handlers/promote.d.ts.map +1 -1
- package/dist/cli/handlers/promote.js +2 -1
- package/dist/cli/handlers/release.d.ts.map +1 -1
- package/dist/cli/handlers/release.js +11 -2
- package/dist/cli/handlers/run-wave.d.ts.map +1 -1
- package/dist/cli/handlers/run-wave.js +36 -2
- package/dist/cli/handlers/run.d.ts.map +1 -1
- package/dist/cli/handlers/run.js +2 -1
- package/dist/cli/main.d.ts.map +1 -1
- package/dist/cli/main.js +60 -4
- package/dist/cli/parse-args.d.ts.map +1 -1
- package/dist/cli/parse-args.js +82 -0
- package/dist/cli/registry.d.ts +35 -0
- package/dist/cli/registry.d.ts.map +1 -1
- package/dist/components/auto-release.d.ts.map +1 -1
- package/dist/components/auto-release.js +2 -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 +169 -0
- package/dist/components/pr-checks.d.ts.map +1 -0
- package/dist/components/pr-checks.js +180 -0
- package/dist/components/pr-pipeline.d.ts +38 -0
- package/dist/components/pr-pipeline.d.ts.map +1 -1
- package/dist/components/pr-pipeline.js +6 -1
- package/dist/components/product-pipeline.d.ts +58 -2
- package/dist/components/product-pipeline.d.ts.map +1 -1
- package/dist/components/product-pipeline.js +76 -9
- package/dist/components/product-plan.d.ts +445 -7
- package/dist/components/product-plan.d.ts.map +1 -1
- package/dist/components/product-plan.js +426 -15
- 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 +52 -5
- package/dist/drift-record.d.ts.map +1 -1
- package/dist/drift-record.js +46 -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 +81 -21
- package/dist/floor-table.js +10 -7
- package/dist/forge-check/contract.d.ts +19 -1
- package/dist/forge-check/contract.d.ts.map +1 -1
- package/dist/forge-check/contract.js +8 -2
- package/dist/forge-check/index.d.ts +4 -0
- package/dist/forge-check/index.d.ts.map +1 -1
- package/dist/forge-check/index.js +4 -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/gate-resume-run.d.ts +9 -1
- package/dist/gate-resume-run.d.ts.map +1 -1
- package/dist/gate-resume-run.js +26 -3
- package/dist/generated-check.d.ts +88 -0
- package/dist/generated-check.d.ts.map +1 -0
- package/dist/generated-check.js +248 -0
- package/dist/image-pins.d.ts +26 -0
- package/dist/image-pins.d.ts.map +1 -0
- package/dist/image-pins.js +19 -0
- package/dist/lexicon.d.ts +27 -0
- package/dist/lexicon.d.ts.map +1 -1
- package/dist/lifecycle/git.d.ts +11 -0
- package/dist/lifecycle/git.d.ts.map +1 -1
- package/dist/lifecycle/git.js +30 -3
- package/dist/lifecycle/publish-npm.d.ts +26 -0
- package/dist/lifecycle/publish-npm.d.ts.map +1 -1
- package/dist/lifecycle/publish-npm.js +76 -4
- package/dist/lifecycle/reach-locks.d.ts +131 -0
- package/dist/lifecycle/reach-locks.d.ts.map +1 -0
- package/dist/lifecycle/reach-locks.js +118 -0
- package/dist/lifecycle/release-cut.d.ts +3 -1
- package/dist/lifecycle/release-cut.d.ts.map +1 -1
- package/dist/lifecycle/release-cut.js +15 -0
- 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 +26 -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/notify-product.d.ts +12 -3
- package/dist/notify-product.d.ts.map +1 -1
- package/dist/notify-product.js +10 -6
- package/dist/op/activities/source-release.d.ts.map +1 -1
- package/dist/op/activities/source-release.js +2 -1
- package/dist/op/activities/source-rollback.d.ts.map +1 -1
- package/dist/op/activities/source-rollback.js +2 -1
- package/dist/op/index.d.ts +2 -0
- package/dist/op/index.d.ts.map +1 -1
- package/dist/op/index.js +1 -0
- package/dist/op/op-waves-evidence-jobs.d.ts +97 -0
- package/dist/op/op-waves-evidence-jobs.d.ts.map +1 -0
- package/dist/op/op-waves-evidence-jobs.js +118 -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-render-spec.d.ts +100 -0
- package/dist/op/op-waves-render-spec.d.ts.map +1 -0
- package/dist/op/op-waves-render-spec.js +162 -0
- package/dist/op/op-waves-run.d.ts +14 -1
- package/dist/op/op-waves-run.d.ts.map +1 -1
- package/dist/op/op-waves-run.js +56 -4
- package/dist/op/op-waves.d.ts +12 -0
- package/dist/op/op-waves.d.ts.map +1 -1
- package/dist/op/op-waves.js +14 -1
- 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 +148 -10
- package/dist/op/wave-stop.d.ts +64 -0
- package/dist/op/wave-stop.d.ts.map +1 -0
- package/dist/op/wave-stop.js +127 -0
- package/dist/planned-files.d.ts +76 -0
- package/dist/planned-files.d.ts.map +1 -0
- package/dist/planned-files.js +108 -0
- package/dist/pr-forge-job.d.ts +22 -0
- package/dist/pr-forge-job.d.ts.map +1 -0
- package/dist/pr-forge-job.js +46 -0
- 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-loop.d.ts +3 -6
- package/dist/pr-loop.d.ts.map +1 -1
- package/dist/pr-loop.js +4 -81
- package/dist/pr-plan-note.d.ts +121 -0
- package/dist/pr-plan-note.d.ts.map +1 -1
- package/dist/pr-plan-note.js +104 -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 +68 -3
- package/dist/pr-post.d.ts.map +1 -1
- package/dist/pr-post.js +218 -13
- 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/pr-status.d.ts +16 -0
- package/dist/pr-status.d.ts.map +1 -0
- package/dist/pr-status.js +90 -0
- package/dist/ref-gate-init.d.ts +90 -0
- package/dist/ref-gate-init.d.ts.map +1 -0
- package/dist/ref-gate-init.js +155 -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 +100 -16
- package/dist/release-floors.d.ts.map +1 -1
- package/dist/release-floors.js +101 -17
- package/dist/render-module.d.ts +15 -0
- package/dist/render-module.d.ts.map +1 -0
- package/dist/render-module.js +73 -0
- package/dist/state-migration.d.ts +24 -1
- package/dist/state-migration.d.ts.map +1 -1
- package/dist/state-migration.js +39 -4
- 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 +307 -297
- package/dist/workspace/ci-green-cli.d.ts.map +1 -1
- package/dist/workspace/ci-green-cli.js +15 -8
- 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-train.d.ts.map +1 -1
- package/dist/workspace/release-train.js +2 -1
- package/dist/workspace/release-workflow.d.ts +27 -3
- package/dist/workspace/release-workflow.d.ts.map +1 -1
- package/dist/workspace/release-workflow.js +52 -7
- package/dist/workspace/trust/check-evidence-report.d.ts +25 -2
- package/dist/workspace/trust/check-evidence-report.d.ts.map +1 -1
- package/dist/workspace/trust/check-evidence-report.js +28 -8
- 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 +10 -1
- package/dist/workspace/trust/ref-gate-cli.d.ts.map +1 -1
- package/dist/workspace/trust/ref-gate-cli.js +93 -11
- 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/dist/workspace/workspace-run.d.ts.map +1 -1
- package/dist/workspace/workspace-run.js +2 -1
- package/package.json +1 -1
- package/src/action-pins.ts +2 -0
- package/src/actor.test.ts +78 -0
- package/src/actor.ts +79 -0
- package/src/bundle-check.test.ts +22 -0
- package/src/bundle-check.ts +33 -5
- package/src/chant-install.test.ts +108 -1
- package/src/chant-install.ts +242 -2
- package/src/ci-base.test.ts +41 -0
- package/src/ci-base.ts +43 -0
- package/src/ci-comment-commands.test.ts +376 -0
- package/src/ci-comment-commands.ts +389 -0
- package/src/ci-comment-replies.ts +78 -0
- package/src/ci-commit.test.ts +51 -6
- 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 +165 -0
- package/src/ci-evidence-from-job.ts +251 -0
- package/src/ci-evidence-jobs.ts +88 -6
- 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 +187 -16
- package/src/ci-image.ts +157 -25
- 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-note-commands.ts +104 -41
- package/src/ci-product-words.ts +89 -0
- package/src/ci-product.ts +62 -1
- package/src/cli/commands/__fixtures__/source-dir-root/migrations/0001-init/backfill.ts +3 -0
- package/src/cli/commands/build.test.ts +41 -0
- package/src/cli/commands/build.ts +27 -2
- package/src/cli/handlers/approve-confirm.test.ts +35 -0
- package/src/cli/handlers/approve-confirm.ts +44 -0
- package/src/cli/handlers/approve.ts +2 -1
- 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 +37 -7
- package/src/cli/handlers/ci-evidence-open.test.ts +164 -0
- package/src/cli/handlers/ci-evidence.ts +233 -18
- package/src/cli/handlers/ci-forge-check.ts +22 -9
- package/src/cli/handlers/components.ts +3 -1
- package/src/cli/handlers/generated-check.ts +69 -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/lock-reach.test.ts +103 -0
- package/src/cli/handlers/lock.ts +100 -4
- package/src/cli/handlers/pr-comment.ts +104 -0
- package/src/cli/handlers/pr-env.ts +6 -3
- package/src/cli/handlers/pr-record.test.ts +1 -1
- package/src/cli/handlers/pr.ts +93 -15
- package/src/cli/handlers/promote.ts +2 -1
- package/src/cli/handlers/release.e2e.test.ts +35 -0
- package/src/cli/handlers/release.ts +14 -2
- package/src/cli/handlers/run-wave.ts +35 -2
- package/src/cli/handlers/run.ts +2 -1
- package/src/cli/main.ts +60 -4
- package/src/cli/parse-args.ts +58 -0
- package/src/cli/registry.ts +35 -0
- package/src/components/auto-release.ts +2 -1
- package/src/components/check-hooks.ts +22 -0
- package/src/components/check-report-summary.test.ts +78 -0
- package/src/components/pr-checks.ts +254 -0
- package/src/components/pr-pipeline.ts +43 -1
- package/src/components/product-pipeline.ts +113 -9
- package/src/components/product-plan.test.ts +140 -1
- package/src/components/product-plan.ts +707 -20
- 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 +45 -0
- package/src/drift-record.ts +71 -6
- package/src/floor-table.data.ts +81 -21
- package/src/floor-table.ts +12 -9
- package/src/forge-check/contract.ts +23 -2
- package/src/forge-check/forge-check.test.ts +25 -0
- package/src/forge-check/index.ts +4 -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/gate-resume-run.ts +27 -3
- package/src/generated-check.e2e.test.ts +118 -0
- package/src/generated-check.test.ts +170 -0
- package/src/generated-check.ts +310 -0
- package/src/image-pins.ts +31 -0
- package/src/lexicon.ts +28 -0
- package/src/lifecycle/git.test.ts +48 -0
- package/src/lifecycle/git.ts +27 -4
- package/src/lifecycle/publish-npm.ts +87 -4
- package/src/lifecycle/reach-locks.test.ts +87 -0
- package/src/lifecycle/reach-locks.ts +169 -0
- package/src/lifecycle/release-catalog.test.ts +2 -2
- package/src/lifecycle/release-cut.ts +17 -1
- package/src/lifecycle/release-images-dockerfile.test.ts +20 -0
- package/src/lifecycle/release-images.test.ts +100 -0
- package/src/lifecycle/release-images.ts +38 -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/notify-product.ts +19 -8
- package/src/op/activities/source-release.ts +2 -1
- package/src/op/activities/source-rollback.ts +2 -1
- package/src/op/gate-resume.test.ts +27 -0
- package/src/op/index.ts +10 -0
- package/src/op/op-waves-evidence-jobs.ts +140 -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-notify-words.test.ts +18 -0
- package/src/op/op-waves-render-spec.test.ts +160 -0
- package/src/op/op-waves-render-spec.ts +171 -0
- package/src/op/op-waves-run.ts +59 -3
- package/src/op/op-waves.ts +16 -2
- package/src/op/schedule-overdue.test.ts +126 -1
- package/src/op/schedule-overdue.ts +164 -12
- package/src/op/wave-stop.test.ts +72 -0
- package/src/op/wave-stop.ts +137 -0
- package/src/planned-files.test.ts +80 -0
- package/src/planned-files.ts +134 -0
- package/src/pr-forge-job.test.ts +53 -0
- package/src/pr-forge-job.ts +46 -0
- 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-loop-narrowed.test.ts +2 -1
- package/src/pr-loop-words.test.ts +2 -1
- package/src/pr-loop.test.ts +1 -2
- package/src/pr-loop.ts +4 -80
- package/src/pr-plan-note.ts +184 -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-replan.test.ts +144 -0
- package/src/pr-post-subject.test.ts +230 -0
- package/src/pr-post.test.ts +32 -1
- package/src/pr-post.ts +254 -15
- package/src/pr-requires.test.ts +20 -0
- package/src/pr-requires.ts +10 -1
- package/src/pr-status.ts +91 -0
- package/src/ref-gate-init.ts +208 -0
- package/src/ref-gate-rules.ts +26 -0
- package/src/release-floors.ts +139 -17
- package/src/render-module.ts +73 -0
- package/src/state-migration-record.test.ts +89 -0
- package/src/state-migration.test.ts +1 -1
- package/src/state-migration.ts +52 -4
- package/src/state-unlock.test.ts +33 -1
- package/src/state-unlock.ts +49 -1
- package/src/workspace/ci-green-cli.ts +14 -7
- package/src/workspace/ci-green-workflow.test.ts +32 -1
- 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-train.ts +2 -1
- package/src/workspace/release-workflow.test.ts +104 -3
- package/src/workspace/release-workflow.ts +60 -9
- package/src/workspace/trust/check-evidence-report.ts +39 -8
- package/src/workspace/trust/check-evidence.test.ts +5 -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 +88 -10
- package/src/workspace/trust/ref-gate-pieces.test.ts +220 -0
- package/src/workspace/trust/ref-gate.e2e.test.ts +17 -0
- package/src/workspace/trust/ref-gate.test.ts +10 -0
- package/src/workspace/trust/ref-gate.ts +87 -6
- package/src/workspace/workspace-run.ts +2 -1
|
@@ -25,6 +25,9 @@
|
|
|
25
25
|
* target's own variables and secrets, and an optional write probe before the
|
|
26
26
|
* plan. A target is the note's and the status's member: `pr-post --member
|
|
27
27
|
* <target>`, so each target has its note and its `<product>/plan/<target>`.
|
|
28
|
+
* With `evidence`, a target's note job (GitLab: `<target>-plan-evidence`)
|
|
29
|
+
* signs `plan:<target>` and `policy:<target>` (#4978,
|
|
30
|
+
* `targetEvidenceCheck`): one target's plan says nothing of another's.
|
|
28
31
|
*
|
|
29
32
|
* The forge lexicons render these descriptors
|
|
30
33
|
* (`generateProductPlanPipeline` in each): the products call them in
|
|
@@ -35,8 +38,19 @@ import type { ForgeKind } from "../pr-forge";
|
|
|
35
38
|
import type { CiRunner } from "../ci-jobs";
|
|
36
39
|
import type { CiProductWords } from "../ci-product-words";
|
|
37
40
|
import type { PrPlanNoteWords } from "../pr-plan-note";
|
|
38
|
-
import { assertPipelineEvidence, evidenceIdTokens, evidenceKeyEnv, evidenceKeyless, planEvidenceLines, type PipelineEvidence } from "../ci-evidence-jobs";
|
|
39
|
-
import { gitlabPlanJobName, PR_LOOP_REPORT_DIR, PR_PLAN_NOTE_JOB, prLoopPassedEnv, prLoopPostJob, prLoopRunner, type PrLoopPipelineOptions } from "./pr-pipeline";
|
|
41
|
+
import { assertPipelineEvidence, evidenceIdTokens, evidenceKeyEnv, evidenceKeyless, gitlabOpenEvidenceDir, openEvidenceLines, planEvidenceLines, type PipelineEvidence } from "../ci-evidence-jobs";
|
|
42
|
+
import { gitlabPlanJobName, PR_LOCK_JOB, PR_LOOP_REPORT_DIR, PR_PLAN_NOTE_JOB, prLoopPassedEnv, prLoopPostJob, prLoopRunner, withProductBin, type PrLoopPipelineOptions } from "./pr-pipeline";
|
|
43
|
+
import { LOCK_REACH_ENV } from "../lifecycle/reach-locks";
|
|
44
|
+
import { GITHUB_JOB_TOKEN } from "../ci-jobs";
|
|
45
|
+
import { cloudLogin, type CloudLoginSpec } from "../ci-login";
|
|
46
|
+
import type { OpWaveRunStep } from "../lexicon";
|
|
47
|
+
import { controlNoteCheckout, type ControlNoteCheckout, type ControlTarget } from "../control/dispatch";
|
|
48
|
+
import { commentLine, productStatusContext } from "../ci-product-words";
|
|
49
|
+
import { PLAN_WATCHES_ENV, scheduledWatchProblem, type ScheduledWatch } from "../op/schedule-overdue";
|
|
50
|
+
import { PLAN_RUN_OP, PLAN_RUN_RECORD_FILE } from "../pr-plan-record";
|
|
51
|
+
import { idTokenVar, tradedClouds, type CloudTradeSpec } from "../ci-identity";
|
|
52
|
+
import { prNoteMarker } from "../pr-loop";
|
|
53
|
+
import { PRODUCT_MARKER_NAME } from "../pr-plan-note";
|
|
40
54
|
|
|
41
55
|
/** The variable the plan-note job reads the product's note words from (#4799), as JSON. Set from the pipeline, never from the report. */
|
|
42
56
|
export const PR_PLAN_NOTE_WORDS_ENV = "CHANT_PLAN_NOTE_WORDS";
|
|
@@ -56,8 +70,105 @@ export interface ProductPlanTarget {
|
|
|
56
70
|
* tokens are dropped.
|
|
57
71
|
*/
|
|
58
72
|
writeProbe?: string;
|
|
73
|
+
/**
|
|
74
|
+
* This target's cloud login (#4899, #4931), in place of the plan's
|
|
75
|
+
* {@link ProductPlanOptions.login}: chant's login from the OIDC token file
|
|
76
|
+
* (`@intentius/chant/ci-login`, #4788), run before the write probe.
|
|
77
|
+
*/
|
|
78
|
+
login?: CloudLoginSpec;
|
|
79
|
+
/** OIDC tokens this target's plan job requests besides its login's, `{ <variable>: <audience> }`, in place of the plan's {@link ProductPlanOptions.idTokens}. */
|
|
80
|
+
idTokens?: Record<string, string>;
|
|
81
|
+
/** This target's trade (#4963), in place of the plan's {@link ProductPlanOptions.trade}. A target gives one of `login` and `trade`. */
|
|
82
|
+
trade?: CloudTradeSpec;
|
|
59
83
|
}
|
|
60
84
|
|
|
85
|
+
/**
|
|
86
|
+
* What the comment re-plan does besides answering the plan command (#4963),
|
|
87
|
+
* `replan: { ... }` in place of `replan: true`.
|
|
88
|
+
*/
|
|
89
|
+
export interface ProductPlanReplanOptions {
|
|
90
|
+
/**
|
|
91
|
+
* Re-plan from `workflow_dispatch` too, on GitHub and Forgejo: the inputs
|
|
92
|
+
* `pr` (the pull request) and `argument` (default `argument`; the target,
|
|
93
|
+
* or the one word {@link PLAN_ARGUMENT_ENV} reads, such as terragucci's
|
|
94
|
+
* `root`). Either forge lets only someone who can write to the repository
|
|
95
|
+
* dispatch, so the decision asks no permission for it. On GitLab a web
|
|
96
|
+
* pipeline of the target branch with `CHANT_PREVIEW_PR` and
|
|
97
|
+
* `CHANT_PREVIEW_COMMENT` is the dispatch already, so it renders nothing
|
|
98
|
+
* more there.
|
|
99
|
+
*/
|
|
100
|
+
dispatch?: boolean | { argument?: string };
|
|
101
|
+
/**
|
|
102
|
+
* Reply to a `/<product>` comment no other job takes (#4963), on GitHub
|
|
103
|
+
* and Forgejo: a word that is not the plan command, a target that is none
|
|
104
|
+
* of the plan's, and a pull request from a fork with `forks: "skip"`. The
|
|
105
|
+
* reply names the commands. `others` are the comments the product's own
|
|
106
|
+
* jobs answer, such as `/terragucci apply`: the re-plan leaves them alone.
|
|
107
|
+
* With targets, the first target's re-plan job replies. GitLab's
|
|
108
|
+
* note-commands job answers every comment already.
|
|
109
|
+
*/
|
|
110
|
+
reply?: boolean | { others?: string[] };
|
|
111
|
+
/**
|
|
112
|
+
* Reply "not affected" for a re-plan narrowed to one argument the change
|
|
113
|
+
* does not reach (#4963): when the hand-off's note says `nothing` (or a
|
|
114
|
+
* `PrReport` says `nothing`), the re-plan's note job comments
|
|
115
|
+
* `<product>: <argument> is not affected by this pull request, so
|
|
116
|
+
* nothing was planned.` and leaves the note and the status as they were
|
|
117
|
+
* (`pr-post --not-affected <argument>`).
|
|
118
|
+
*/
|
|
119
|
+
notAffected?: boolean;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* A step a product's plan job runs before its setup lines (#4899): a shell
|
|
124
|
+
* line (`run`), or on GitHub and Forgejo an action (`uses`), such as a
|
|
125
|
+
* cache restore. A `run` step starts without the forge tokens, as every
|
|
126
|
+
* step after the checkout does. GitLab has no actions, so it leaves a
|
|
127
|
+
* `uses` step out; its generator's `cache` is GitLab's cache.
|
|
128
|
+
*/
|
|
129
|
+
export interface ProductPlanSetupStep {
|
|
130
|
+
name?: string;
|
|
131
|
+
run?: string;
|
|
132
|
+
uses?: string;
|
|
133
|
+
with?: Record<string, unknown>;
|
|
134
|
+
env?: Record<string, string>;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* The comment re-plan (#4899): `/<product> <plan word>` (or a words' alias
|
|
139
|
+
* for the plan command) plans an open pull request again. With `targets`,
|
|
140
|
+
* `/<product> plan <target>` plans that target alone, and the bare command
|
|
141
|
+
* plans every target. Without targets, the one word after the command
|
|
142
|
+
* reaches the plan verb as {@link PLAN_ARGUMENT_ENV}, such as terragucci's
|
|
143
|
+
* root.
|
|
144
|
+
*/
|
|
145
|
+
export interface ProductPlanReplanJob {
|
|
146
|
+
/** `replan` or `replan-<target>` on GitHub and Forgejo, `replan` or `<target>-replan` on GitLab. */
|
|
147
|
+
jobName: string;
|
|
148
|
+
/** `replan-note` or `replan-note-<target>`, `<target>-replan-note` on GitLab. */
|
|
149
|
+
noteJobName: string;
|
|
150
|
+
/** The comments it answers: the plan command, then each alias for it that is on. */
|
|
151
|
+
comments: string[];
|
|
152
|
+
/** Aliases whose words name a variable that turns them on, with that variable. */
|
|
153
|
+
gated: Array<{ comment: string; when: string }>;
|
|
154
|
+
/** The note job's command and variables, which read the pull request and head from the re-plan job. */
|
|
155
|
+
post: { command: string; env: Record<string, string>; setup?: string[] };
|
|
156
|
+
/** The artifact the note job (GitHub, Forgejo) or the re-plan job (GitLab) keeps the directory as. */
|
|
157
|
+
artifact: string;
|
|
158
|
+
/** With `dispatch` (#4963), GitHub and Forgejo: the `workflow_dispatch` input that names the argument. */
|
|
159
|
+
dispatch?: { argument: string };
|
|
160
|
+
/** With `reply` (#4963), GitHub and Forgejo, on one re-plan job: the product's prefix and the comments other jobs answer. */
|
|
161
|
+
reply?: { prefix: string; others: string[] };
|
|
162
|
+
/** With `notAffected` (#4963): the note job's command carries `--not-affected`, and reads the argument as {@link PLAN_ARGUMENT_ENV}. */
|
|
163
|
+
notAffected?: true;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/** The variable a comment re-plan's one argument reaches the plan verb in (#4899). Empty on a pull request's own plan. */
|
|
167
|
+
export const PLAN_ARGUMENT_ENV = "CHANT_PLAN_ARGUMENT";
|
|
168
|
+
|
|
169
|
+
/** The file the note job's own lines write extra notices to, one a line (#4931): `pr-post` adds them under the note's counts. */
|
|
170
|
+
export const PLAN_NOTE_NOTICES_ENV = "CHANT_PLAN_NOTE_NOTICES";
|
|
171
|
+
|
|
61
172
|
/** The product plan (#4799): {@link ProductPipelineOptions.plan}. */
|
|
62
173
|
export interface ProductPlanOptions {
|
|
63
174
|
/**
|
|
@@ -84,8 +195,207 @@ export interface ProductPlanOptions {
|
|
|
84
195
|
noteWords?: PrPlanNoteWords;
|
|
85
196
|
/** The workflow's name (GitHub and Forgejo) or the pipeline's (GitLab). Default `chant-pr-<env>`. */
|
|
86
197
|
workflow?: string;
|
|
198
|
+
/**
|
|
199
|
+
* Variables for the whole plan job (#4899), every step of it: the job's
|
|
200
|
+
* `env` on GitHub and Forgejo, its `variables` on GitLab. A forge token's
|
|
201
|
+
* name is refused.
|
|
202
|
+
*/
|
|
203
|
+
env?: Record<string, string>;
|
|
204
|
+
/**
|
|
205
|
+
* The plan job's cloud login (#4899, #4931), for every target without
|
|
206
|
+
* its own: chant's login from the OIDC token file
|
|
207
|
+
* (`@intentius/chant/ci-login`, #4788), after the setup lines and before
|
|
208
|
+
* the write probe. The job asks for the OIDC token: `id-token: write`
|
|
209
|
+
* (Forgejo `enable-openid-connect`), GitLab `id_tokens`.
|
|
210
|
+
*/
|
|
211
|
+
login?: CloudLoginSpec;
|
|
212
|
+
/**
|
|
213
|
+
* OIDC tokens the plan job requests for a login the product's command
|
|
214
|
+
* does itself (#4931), `{ <variable>: <audience> }`: GitLab `id_tokens`,
|
|
215
|
+
* and `id-token: write` on GitHub and Forgejo, where the command asks the
|
|
216
|
+
* forge for its token by audience.
|
|
217
|
+
*/
|
|
218
|
+
idTokens?: Record<string, string>;
|
|
219
|
+
/**
|
|
220
|
+
* Post the plan status pending ("planning") before the checkout (#4899),
|
|
221
|
+
* on GitHub and Forgejo, from a step that alone holds the job's token.
|
|
222
|
+
* The job asks for `statuses: write`. GitLab's plan job holds no token,
|
|
223
|
+
* so there the pipeline's own status says the plan runs.
|
|
224
|
+
*/
|
|
225
|
+
pending?: boolean;
|
|
226
|
+
/**
|
|
227
|
+
* The control repo the plan reads (#4899), as terragucci reads it for
|
|
228
|
+
* estate ownership: chant's read-only fetch of its `chant/lifecycle`
|
|
229
|
+
* (`controlNoteCheckout`), right after the checkout and before any of the
|
|
230
|
+
* change's code runs. It sets `CHANT_CONTROL_DIR`.
|
|
231
|
+
*/
|
|
232
|
+
controlRead?: ControlTarget;
|
|
233
|
+
/** Steps after the checkout and the control read, before the setup lines (#4899): a cache restore, an install. */
|
|
234
|
+
setup?: ProductPlanSetupStep[];
|
|
235
|
+
/**
|
|
236
|
+
* A shell line run after the plan verb whatever its exit (#4899), such as
|
|
237
|
+
* sql-yodeler's `yodel report {target} --out {output}/report`, in the plan
|
|
238
|
+
* step, so it is not a step after the change's code. `{target}` and
|
|
239
|
+
* `{output}` are filled as in `command`. The step then exits with the plan
|
|
240
|
+
* verb's status. What it writes under `{output}` is kept with the report.
|
|
241
|
+
*/
|
|
242
|
+
report?: string;
|
|
243
|
+
/**
|
|
244
|
+
* One run at a time per pull request (#4899): a workflow-level
|
|
245
|
+
* `concurrency` group `<group>-<pull request>` on GitHub and Forgejo
|
|
246
|
+
* (default group: the workflow's name), cancelling the run before it when
|
|
247
|
+
* `cancelInProgress`. A comment's run, with `replan`, is in a group of its
|
|
248
|
+
* own comment, so a comment never cancels a plan. On GitLab
|
|
249
|
+
* `cancelInProgress` makes the plan jobs `interruptible`, which GitLab's
|
|
250
|
+
* auto-cancel of redundant pipelines stops.
|
|
251
|
+
*/
|
|
252
|
+
concurrency?: { group?: string; cancelInProgress?: boolean };
|
|
253
|
+
/**
|
|
254
|
+
* The comment re-plan (#4899, {@link ProductPlanReplanJob}). The words
|
|
255
|
+
* need a plan command. On GitHub the commenter must be an owner, member or
|
|
256
|
+
* collaborator; on Forgejo the job asks the forge whether the commenter
|
|
257
|
+
* can write. On GitLab the note-commands job (`noteCommands`) starts a
|
|
258
|
+
* pipeline of the target branch for the comment, which runs the re-plan
|
|
259
|
+
* jobs whose target the comment names.
|
|
260
|
+
*/
|
|
261
|
+
replan?: boolean | ProductPlanReplanOptions;
|
|
262
|
+
/**
|
|
263
|
+
* The plan job's trade (#4963): chant's trade of the job's OIDC token for
|
|
264
|
+
* the plan identities' own credentials (`@intentius/chant/ci-identity`,
|
|
265
|
+
* #4296), before the change is checked out, as terragucci's re-plan
|
|
266
|
+
* trades. The plan job and the re-plan job trade in a step of their own
|
|
267
|
+
* (GitHub, Forgejo: after the pending status and the re-plan's decision,
|
|
268
|
+
* before the checkout; GitLab: the script's first lines, before the
|
|
269
|
+
* re-plan checks out the head), and every later step starts without the
|
|
270
|
+
* variables a token is requested with, so the change's code holds the
|
|
271
|
+
* traded credentials and no OIDC token. Give one of `login` and `trade`.
|
|
272
|
+
*/
|
|
273
|
+
trade?: CloudTradeSpec;
|
|
274
|
+
/**
|
|
275
|
+
* The previous note's product marker for the plan verb (#4963), on GitHub
|
|
276
|
+
* and Forgejo: a step before the checkout, which alone holds the job's
|
|
277
|
+
* token, finds the pull request's note by chant's marker and sets
|
|
278
|
+
* `CHANT_PLAN_PREVIOUS_MARKER` to the body of its second line, the
|
|
279
|
+
* product's own (`noteWords.productMarker`, a hand-off's `marker`), so a
|
|
280
|
+
* plan verb such as `yodel plan` reads the digest subject it left there
|
|
281
|
+
* and says what moved. Empty when there is no note yet. The body was
|
|
282
|
+
* checked against the marker's pattern before chant posted it, and is
|
|
283
|
+
* checked again. Needs `noteWords.productMarker`. GitLab's plan job holds
|
|
284
|
+
* no token to read a note with, so it takes none.
|
|
285
|
+
*
|
|
286
|
+
* @deprecated #4972: hand the plan's `subject` in the plan note hand-off
|
|
287
|
+
* instead. The note job compares it with the previous note's on every
|
|
288
|
+
* forge and says what changed, so the plan job reads no note. This option
|
|
289
|
+
* still works on GitHub and Forgejo.
|
|
290
|
+
*/
|
|
291
|
+
previousMarker?: boolean;
|
|
292
|
+
/**
|
|
293
|
+
* Lines the note job runs (#4931), on GitHub and Forgejo, in the job that
|
|
294
|
+
* holds the token and none of the change's code: `before` after the report
|
|
295
|
+
* is taken back and before `pr-post`, `after` once it posted. A `before`
|
|
296
|
+
* line may write notices, one a line, to the file
|
|
297
|
+
* `$CHANT_PLAN_NOTE_NOTICES` names, and `pr-post` adds them under the
|
|
298
|
+
* note's counts, such as terragucci's notice naming whose review does not
|
|
299
|
+
* count. They reach the job's token as `GITHUB_TOKEN`. GitLab's note job
|
|
300
|
+
* posts every open merge request's note in one run, so it takes none.
|
|
301
|
+
*
|
|
302
|
+
* With `pullRequest` (#4963) the lines also read the pull request and the
|
|
303
|
+
* commit planned as `PR_NUMBER` and `HEAD_SHA`, the note's own, which in
|
|
304
|
+
* a re-plan's note job come from the re-plan job, such as terragucci's
|
|
305
|
+
* notice and approval status, which ask the forge about the head.
|
|
306
|
+
*/
|
|
307
|
+
noteSteps?: { before?: string[]; after?: string[]; pullRequest?: boolean };
|
|
308
|
+
/**
|
|
309
|
+
* The product's own scheduled jobs the note job checks for having stopped
|
|
310
|
+
* (#4888), such as terragucci's drift job: each a `ScheduledWatch` with
|
|
311
|
+
* its cron, the files the product's generator wrote it in, and on GitLab
|
|
312
|
+
* its schedule selector. The note job holds the token the plan job lacks,
|
|
313
|
+
* so `pr-post` asks the forge when each last ran, in its checkout of the
|
|
314
|
+
* target branch's commit, and adds the line for one that is overdue under
|
|
315
|
+
* the note's counts. They reach it as `CHANT_PLAN_WATCHES`, from the
|
|
316
|
+
* pipeline, never from the plan job's report.
|
|
317
|
+
*/
|
|
318
|
+
watches?: ScheduledWatch[];
|
|
319
|
+
/**
|
|
320
|
+
* A run record for the plan job (#4899), as `chant ci run plan --in-place`
|
|
321
|
+
* writes one for `pr-plan`'s: Op `pr-plan` in the run ledger,
|
|
322
|
+
* `<env>/runs__pr-plan.jsonl` on `chant/lifecycle`. The plan job holds no
|
|
323
|
+
* token, so its plan step writes the record into the hand-off
|
|
324
|
+
* ({@link PLAN_RUN_RECORD_FILE}) once the plan verb and the report line ran,
|
|
325
|
+
* and the note job, which holds the token, appends it to the ledger and
|
|
326
|
+
* pushes it with the note (`pr-post --record-run <plan job>`). The note job
|
|
327
|
+
* reads the record as data: it keeps the record's id, times and exit code,
|
|
328
|
+
* and names the op, environment, commit, run and status from what it knows
|
|
329
|
+
* itself. The note job then asks `contents: write` on GitHub and Forgejo.
|
|
330
|
+
* Unsigned, as `pr-plan`'s is (#4328). Default off.
|
|
331
|
+
*/
|
|
332
|
+
record?: boolean;
|
|
333
|
+
/**
|
|
334
|
+
* What the lock job locks under `locks: "plan"` (#4979): the targets the
|
|
335
|
+
* change reaches, by the product's reach line, in place of what a
|
|
336
|
+
* `PrReport` selected. `command` is one shell line that prints the target
|
|
337
|
+
* names the change from `$BASE_SHA` to `$HEAD_SHA` reaches, one a line,
|
|
338
|
+
* reading the change's files as data from git (`git diff`, `git show`),
|
|
339
|
+
* such as terragucci's roots, Terragrunt units or Atmos instances. It
|
|
340
|
+
* runs at the target branch's commit, after chant fetched the pull
|
|
341
|
+
* request's head and checked it is the head the job was started for
|
|
342
|
+
* (`chant lock --reach`, ../lifecycle/reach-locks.ts), so none of the
|
|
343
|
+
* change's code runs in the job that holds the write token. `gate` names
|
|
344
|
+
* the lock file, `_locks/<gate>.json` (default the pull request loop's).
|
|
345
|
+
*
|
|
346
|
+
* GitHub and Forgejo run one `lock` job on each push of a pull request
|
|
347
|
+
* from this repository, beside the plan, and the `unlock` job on close.
|
|
348
|
+
* On GitLab, where a merge request's pipeline is built from its own files,
|
|
349
|
+
* the `lock` job runs in the target branch's plan notes pipeline and locks
|
|
350
|
+
* every open merge request (`--open`), releasing the locks of one that is
|
|
351
|
+
* no longer open; with `noteCommands` the comment lock and unlock jobs
|
|
352
|
+
* answer `/<product> lock` and `/<product> unlock` there too.
|
|
353
|
+
*/
|
|
354
|
+
reach?: { command: string; gate?: string };
|
|
87
355
|
}
|
|
88
356
|
|
|
357
|
+
/** The lock job a product plan with {@link ProductPlanOptions.reach} writes (#4979): its command and the values the command reads. */
|
|
358
|
+
export interface ProductPlanReachLock {
|
|
359
|
+
jobName: typeof PR_LOCK_JOB;
|
|
360
|
+
command: string;
|
|
361
|
+
env: Record<string, string>;
|
|
362
|
+
runner?: CiRunner;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
/**
|
|
366
|
+
* The reach lock job (#4979), under `locks: "plan"` with `reach`: `chant lock
|
|
367
|
+
* --reach` through the words' bin, with the reach line as
|
|
368
|
+
* {@link LOCK_REACH_ENV}. On GitHub and Forgejo it locks the pull request of
|
|
369
|
+
* the event; on GitLab every open merge request into the branch.
|
|
370
|
+
*/
|
|
371
|
+
export function productPlanReachLock(forge: ForgeKind, loop: Pick<PrLoopPipelineOptions, "locks" | "runners"> & { plan: Pick<ProductPlanOptions, "reach"> }, words: CiProductWords): ProductPlanReachLock | undefined {
|
|
372
|
+
const reach = loop.plan.reach;
|
|
373
|
+
if (!reach) return undefined;
|
|
374
|
+
if (loop.locks !== "plan") throw new Error("the product plan's reach says what the lock job locks, and there is none without locks: \"plan\"; set locks: \"plan\", or drop reach");
|
|
375
|
+
if (!reach.command.trim()) throw new Error("the product plan's reach.command is empty; give the line that prints the targets a change reaches");
|
|
376
|
+
if (/[\r\n]/.test(reach.command)) throw new Error("the product plan's reach.command is one shell line");
|
|
377
|
+
if (reach.gate !== undefined) {
|
|
378
|
+
// The lock file's name, as ../lifecycle/target-lock.ts takes it.
|
|
379
|
+
if (!/^[A-Za-z0-9][A-Za-z0-9_.-]{0,127}$/.test(reach.gate)) throw new Error(`the product plan's reach.gate ${JSON.stringify(reach.gate)} is not a lock file name: letters, digits, '.', '_' and '-', starting with a letter or digit`);
|
|
380
|
+
}
|
|
381
|
+
const gate = reach.gate !== undefined ? ["--gate", reach.gate] : [];
|
|
382
|
+
const github = forge !== "gitlab";
|
|
383
|
+
const line = github
|
|
384
|
+
? ["chant", "lock", "--reach", "--pr", '"$PR_NUMBER"', "--head", '"$HEAD_SHA"', "--base", '"$BASE_SHA"', "--stage", "plan", ...gate, "--forge", forge]
|
|
385
|
+
: ["chant", "lock", "--reach", "--open", "--base", '"$CI_COMMIT_SHA"', "--stage", "plan", ...gate, "--forge", "gitlab"];
|
|
386
|
+
const env: Record<string, string> = github
|
|
387
|
+
? { PR_NUMBER: "${{ github.event.pull_request.number }}", HEAD_SHA: "${{ github.event.pull_request.head.sha }}", BASE_SHA: "${{ github.event.pull_request.base.sha }}", GITHUB_TOKEN: GITHUB_JOB_TOKEN, [LOCK_REACH_ENV]: reach.command }
|
|
388
|
+
: { [LOCK_REACH_ENV]: reach.command };
|
|
389
|
+
const runner = prLoopRunner(loop, "default");
|
|
390
|
+
return { jobName: PR_LOCK_JOB, command: withProductBin(line.join(" "), words.bin), env, ...(runner !== undefined ? { runner } : {}) };
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
/** The file a product plan job writes its run record to under the hand-off directory, and the Op it is recorded under: `pr-plan`'s (#4899, ../pr-plan-record.ts). */
|
|
394
|
+
export { PLAN_RUN_OP, PLAN_RUN_RECORD_FILE } from "../pr-plan-record";
|
|
395
|
+
|
|
396
|
+
/** The variable the plan step reads the record's op, environment and labels from (#4899), as JSON. */
|
|
397
|
+
export const PLAN_RUN_RECORD_ENV = "CHANT_PLAN_RECORD";
|
|
398
|
+
|
|
89
399
|
/** One plan job and its note job, for one target or for the whole pipeline (#4799). */
|
|
90
400
|
export interface ProductPlanJob {
|
|
91
401
|
/** The target, when the plan has targets. Also the note's and the status's member. */
|
|
@@ -110,14 +420,42 @@ export interface ProductPlanJob {
|
|
|
110
420
|
noteRunner?: CiRunner;
|
|
111
421
|
/**
|
|
112
422
|
* With the pipeline's `evidence` (#4870): the lines that sign the plan
|
|
113
|
-
* job's `plan` and `policy` checks from its report
|
|
423
|
+
* job's `plan` and `policy` checks from its report (with a target,
|
|
424
|
+
* `plan:<target>` and `policy:<target>`, #4978), and their variables
|
|
114
425
|
* (the runner key from its secret). GitHub and Forgejo run them in the
|
|
115
|
-
* note job before `pr-post`; GitLab in a job of their own
|
|
116
|
-
*
|
|
117
|
-
*
|
|
426
|
+
* note job before `pr-post`; GitLab in a job of their own, `jobName`, in
|
|
427
|
+
* the target branch's plan notes pipeline before the note job (#4914),
|
|
428
|
+
* which keeps `dir` as its artifact and names the environment
|
|
429
|
+
* `GITLAB_EVIDENCE_ENVIRONMENT`; the note job reads `dir`
|
|
430
|
+
* (`--evidence-dir`). Signing keyless (#4869), the job asks for an OIDC
|
|
431
|
+
* token: `idToken` (GitHub's `id-token: write`, Forgejo's
|
|
118
432
|
* `enable-openid-connect`) or GitLab's `idTokens`.
|
|
119
433
|
*/
|
|
120
|
-
evidence?: { lines: string[]; env: Record<string, string>; jobName?: string; idToken?: true; idTokens?: Record<string, { aud: string }> };
|
|
434
|
+
evidence?: { lines: string[]; env: Record<string, string>; jobName?: string; dir?: string; idToken?: true; idTokens?: Record<string, { aud: string }> };
|
|
435
|
+
/** The job's own variables (#4899), every step's. */
|
|
436
|
+
jobEnv?: Record<string, string>;
|
|
437
|
+
/** The cloud login's steps (#4931), after the setup lines and before the write probe. GitLab: their lines in the script. */
|
|
438
|
+
login?: OpWaveRunStep[];
|
|
439
|
+
/** The OIDC tokens the plan job requests (#4931), `{ <variable>: <audience> }`: the login's and the product's own. */
|
|
440
|
+
idTokens?: Record<string, string>;
|
|
441
|
+
/** The pending status posted before the checkout (#4899), on GitHub and Forgejo. */
|
|
442
|
+
pending?: { context: string; description: string };
|
|
443
|
+
/** The control repo read after the checkout (#4899). */
|
|
444
|
+
control?: ControlNoteCheckout;
|
|
445
|
+
/** The steps before the setup lines (#4899). */
|
|
446
|
+
setup?: ProductPlanSetupStep[];
|
|
447
|
+
/** The report line after the plan verb (#4899), `{target}` and `{output}` filled. */
|
|
448
|
+
report?: string;
|
|
449
|
+
/** The comment re-plan's jobs for this target (#4899). */
|
|
450
|
+
replan?: ProductPlanReplanJob;
|
|
451
|
+
/** The note job's own lines (#4931); with `pullRequest` (#4963) they read `PR_NUMBER` and `HEAD_SHA`. */
|
|
452
|
+
noteSteps?: { before: string[]; after: string[]; pullRequest?: true };
|
|
453
|
+
/** The trade before the checkout (#4963), and on GitLab the `id_tokens` it reads (in `idTokens` too). */
|
|
454
|
+
trade?: CloudTradeSpec;
|
|
455
|
+
/** With `previousMarker` (#4963): the note's marker and the product marker's name the read step looks for. */
|
|
456
|
+
previous?: { marker: string; name: string };
|
|
457
|
+
/** With `record` (#4899): the plan step writes the run record, `env` its op, environment and labels as {@link PLAN_RUN_RECORD_ENV}; the note job's command records it. */
|
|
458
|
+
record?: { env: Record<string, string> };
|
|
121
459
|
}
|
|
122
460
|
|
|
123
461
|
const TARGET_NAME = /^[A-Za-z0-9][A-Za-z0-9_-]*$/;
|
|
@@ -127,10 +465,9 @@ const NOT_WITH_PLAN: ReadonlyArray<[keyof PrLoopPipelineOptions, string]> = [
|
|
|
127
465
|
["applyBeforeMerge", "the apply before merge runs pr-apply on pr-plan's report"],
|
|
128
466
|
["applyOnMerge", "the apply on merge runs on op waves, from the waves spec"],
|
|
129
467
|
["waveGate", "the apply on merge runs on op waves, from the waves spec"],
|
|
130
|
-
["locks", "the lock job reads pr-plan's report"],
|
|
131
468
|
["previewComment", "the comment preview re-runs pr-plan"],
|
|
132
469
|
["staleNotes", "the stale marking names one note per pipeline"],
|
|
133
|
-
["identity", "
|
|
470
|
+
["identity", "the identity trade runs before pr-plan's checkout; give the product plan's trade or login (or a target's) instead"],
|
|
134
471
|
["build", "the plan verb builds what it plans"],
|
|
135
472
|
["buildCommand", "the plan verb builds what it plans"],
|
|
136
473
|
["refresh", "--refresh is a pr-plan flag"],
|
|
@@ -139,7 +476,6 @@ const NOT_WITH_PLAN: ReadonlyArray<[keyof PrLoopPipelineOptions, string]> = [
|
|
|
139
476
|
["events", "--events-json is a pr-plan flag"],
|
|
140
477
|
["reportUrl", "--report-url is a pr-plan flag"],
|
|
141
478
|
["prEnvironment", "the pull request environment jobs run pr-env"],
|
|
142
|
-
["noteCommands", "the note-commands job starts pr-plan's comment jobs"],
|
|
143
479
|
["actionJob", "the action job is in chant build --pr-loop's workflow"],
|
|
144
480
|
["control", "the control read is the pr-plan report's cross-stack edges"],
|
|
145
481
|
["decide", "the description check reads pr-plan's report"],
|
|
@@ -157,6 +493,11 @@ export function productPlanJobs(forge: ForgeKind, env: string, loop: PrLoopPipel
|
|
|
157
493
|
const value = loop[key];
|
|
158
494
|
if (value !== undefined && value !== false) throw new Error(`the product plan (plan) takes no ${key}: ${why}`);
|
|
159
495
|
}
|
|
496
|
+
// #4946: GitHub's and Forgejo's product plan writes the lock jobs around the plan verb's PrReport.
|
|
497
|
+
// #4979: GitLab's locks what each open merge request reaches, from the plan notes pipeline, so it needs the reach line.
|
|
498
|
+
if (loop.locks && forge === "gitlab" && !plan.reach) throw new Error("the product plan (plan) takes locks on GitLab only with reach: a merge request's pipeline is built from its own files, so the lock job runs in the target branch's plan notes pipeline and locks what reach prints for each open merge request");
|
|
499
|
+
// #4899: GitLab's comment commands start the re-plan, so the note-commands job comes with it.
|
|
500
|
+
if (loop.noteCommands && !plan.replan) throw new Error("the product plan (plan) takes no noteCommands without replan: the note-commands job starts its comment re-plan");
|
|
160
501
|
if (!plan.command.trim()) throw new Error("the product plan's command is empty; give the product's plan verb");
|
|
161
502
|
const targets = plan.targets;
|
|
162
503
|
if (targets !== undefined && targets.length === 0) throw new Error("the product plan's targets are empty; leave targets out for one plan job");
|
|
@@ -168,12 +509,48 @@ export function productPlanJobs(forge: ForgeKind, env: string, loop: PrLoopPipel
|
|
|
168
509
|
}
|
|
169
510
|
const github = forge !== "gitlab";
|
|
170
511
|
const shared = prLoopPassedEnv(forge, loop);
|
|
512
|
+
const jobEnv = plan.env ? prLoopPassedEnv(forge, { variables: plan.env }) : {};
|
|
513
|
+
for (const key of Object.keys(jobEnv)) {
|
|
514
|
+
if (key in shared) throw new Error(`the product plan's env ${key} is the pipeline's too; give it once`);
|
|
515
|
+
}
|
|
516
|
+
for (const s of plan.setup ?? []) {
|
|
517
|
+
if ((s.run === undefined) === (s.uses === undefined)) throw new Error(`the product plan's setup step ${JSON.stringify(s.name ?? s.run ?? s.uses ?? "")} gives one of run and uses`);
|
|
518
|
+
if (s.run !== undefined && s.with !== undefined) throw new Error(`the product plan's setup step ${JSON.stringify(s.name ?? s.run)} runs a line, and only a uses step takes with`);
|
|
519
|
+
}
|
|
520
|
+
if (plan.concurrency?.group !== undefined && !/^[A-Za-z0-9][A-Za-z0-9_.-]*$/.test(plan.concurrency.group)) throw new Error(`the product plan's concurrency group ${JSON.stringify(plan.concurrency.group)} is not a name of letters, digits, ., - and _`);
|
|
521
|
+
const replanComments = plan.replan ? replanCommentsOf(words) : undefined;
|
|
522
|
+
// #4963: what the re-plan does besides the plan command.
|
|
523
|
+
const replanOpts: ProductPlanReplanOptions = typeof plan.replan === "object" ? plan.replan : {};
|
|
524
|
+
const dispatchArg = replanOpts.dispatch ? (typeof replanOpts.dispatch === "object" && replanOpts.dispatch.argument !== undefined ? replanOpts.dispatch.argument : "argument") : undefined;
|
|
525
|
+
if (dispatchArg !== undefined && (dispatchArg === "pr" || !/^[a-z][a-z0-9_-]*$/.test(dispatchArg))) throw new Error(`the product plan's replan.dispatch.argument ${JSON.stringify(dispatchArg)} is not an input name of lowercase letters, digits, - and _ other than pr`);
|
|
526
|
+
const others = typeof replanOpts.reply === "object" ? (replanOpts.reply.others ?? []) : [];
|
|
527
|
+
for (const o of others) {
|
|
528
|
+
if (!o.startsWith(`/${words.product} `) && !o.startsWith(`/${words.product}\t`) && o !== `/${words.product}`) throw new Error(`the product plan's replan.reply.others ${JSON.stringify(o)} is not a /${words.product} comment`);
|
|
529
|
+
if (/['\r\n]/.test(o)) throw new Error(`the product plan's replan.reply.others ${JSON.stringify(o)} holds a quote or a line break`);
|
|
530
|
+
}
|
|
531
|
+
if (plan.previousMarker && !github) throw new Error("the product plan's previousMarker reads the pull request's note before the checkout, with the job's token, and GitLab's plan job holds no token to read a merge request's notes with; leave previousMarker out on GitLab");
|
|
532
|
+
const productMarker = plan.noteWords?.productMarker;
|
|
533
|
+
if (plan.previousMarker && (productMarker === undefined || !PRODUCT_MARKER_NAME.test(productMarker))) throw new Error("the product plan's previousMarker reads the note's product marker, and the note words name none; give noteWords.productMarker");
|
|
534
|
+
if (plan.noteSteps && !github && ((plan.noteSteps.before?.length ?? 0) > 0 || (plan.noteSteps.after?.length ?? 0) > 0)) {
|
|
535
|
+
throw new Error("the product plan's noteSteps run in the note job of one pull request, and GitLab's note job posts every open merge request's note in one run (pr-post --open); leave noteSteps out on GitLab");
|
|
536
|
+
}
|
|
171
537
|
const planRunner = prLoopRunner(loop, "plan");
|
|
172
538
|
const noteRunner = prLoopRunner(loop, "default");
|
|
173
539
|
const base = github
|
|
174
540
|
? { BASE_SHA: "${{ github.event.pull_request.base.sha }}", PR_NUMBER: "${{ github.event.pull_request.number }}" }
|
|
175
541
|
: { BASE_SHA: "$CI_MERGE_REQUEST_DIFF_BASE_SHA", PR_NUMBER: "$CI_MERGE_REQUEST_IID" };
|
|
176
|
-
const
|
|
542
|
+
for (const w of plan.watches ?? []) {
|
|
543
|
+
const problem = scheduledWatchProblem(w);
|
|
544
|
+
if (problem) throw new Error(`the product plan's watches: ${problem}`);
|
|
545
|
+
}
|
|
546
|
+
if (new Set((plan.watches ?? []).map((w) => w.op)).size !== (plan.watches ?? []).length) throw new Error("the product plan's watches name an Op twice");
|
|
547
|
+
// The note job's variables from the pipeline: the note words, and the product's watches (#4888).
|
|
548
|
+
const noteWords: Record<string, string> = {
|
|
549
|
+
...(plan.noteWords ? { [PR_PLAN_NOTE_WORDS_ENV]: JSON.stringify(plan.noteWords) } : {}),
|
|
550
|
+
...(plan.watches?.length ? { [PLAN_WATCHES_ENV]: JSON.stringify(plan.watches) } : {}),
|
|
551
|
+
};
|
|
552
|
+
const fill = (line: string, name: string | undefined): string => line.replaceAll("{target}", name ?? env).replaceAll("{output}", PR_LOOP_REPORT_DIR);
|
|
553
|
+
const control = plan.controlRead ? controlNoteCheckout(forge, plan.controlRead, words) : undefined;
|
|
177
554
|
const one = (target?: ProductPlanTarget): ProductPlanJob => {
|
|
178
555
|
const name = target?.name;
|
|
179
556
|
const jobName = github ? (name ? `plan-${name}` : "plan") : gitlabPlanJobName(name);
|
|
@@ -181,43 +558,353 @@ export function productPlanJobs(forge: ForgeKind, env: string, loop: PrLoopPipel
|
|
|
181
558
|
const own = target ? prLoopPassedEnv(forge, { ...(target.variables ? { variables: target.variables } : {}), ...(target.secrets ? { secrets: target.secrets } : {}) }) : {};
|
|
182
559
|
for (const key of Object.keys(own)) {
|
|
183
560
|
if (key in shared) throw new Error(`target ${name}'s ${key} is the pipeline's too; give it on the target or on the pipeline`);
|
|
561
|
+
if (key in jobEnv) throw new Error(`target ${name}'s ${key} is the product plan's env too; give it once`);
|
|
184
562
|
}
|
|
185
|
-
const
|
|
563
|
+
const post0 = prLoopPostJob(forge, env, name, words);
|
|
564
|
+
// #4899: the note job records the plan job's run, named by that job.
|
|
565
|
+
const post1 = plan.record ? { ...post0, command: `${post0.command} --record-run ${jobName}` } : post0;
|
|
566
|
+
// #4914: on GitLab the signing job of the same pipeline keeps each merge request's evidence, which the note's checks line reads.
|
|
567
|
+
const post = evidence && !github ? { ...post1, command: `${post1.command} --evidence-dir ${gitlabOpenEvidenceDir(jobName)}` } : post1;
|
|
186
568
|
// The note job reads its own plan job's result, by that job's name.
|
|
187
569
|
const postEnv: Record<string, string> = github ? { ...post.env, PLAN_RESULT: `\${{ needs.${jobName}.result }}`, ...noteWords } : { ...post.env, ...noteWords };
|
|
570
|
+
// #4931: the target's login, else the plan's, from the OIDC token file (ci-login, #4788).
|
|
571
|
+
// #4963: a target's own login or trade stands in for both of the plan's.
|
|
572
|
+
const own2 = target?.login !== undefined || target?.trade !== undefined;
|
|
573
|
+
const loginSpec = own2 ? target?.login : plan.login;
|
|
574
|
+
const tradeSpec = own2 ? target?.trade : plan.trade;
|
|
575
|
+
if (loginSpec && tradeSpec) throw new Error(`the product plan${name ? `'s target ${name}` : ""} gives both login and trade; the trade leaves no token for a login to read, so give one`);
|
|
576
|
+
if (tradeSpec && tradedClouds(tradeSpec).length === 0) throw new Error(`the product plan${name ? `'s target ${name}` : ""} trades for no identity; give the trade a cloud`);
|
|
577
|
+
const login = loginSpec ? cloudLogin(forge, loginSpec) : undefined;
|
|
578
|
+
const tradeTokens: Record<string, string> = tradeSpec ? Object.fromEntries(tradedClouds(tradeSpec).map((c) => [idTokenVar(c), tradeSpec[c]!.audience])) : {};
|
|
579
|
+
const ownTokens = target?.idTokens ?? plan.idTokens;
|
|
580
|
+
for (const [v, aud] of Object.entries(ownTokens ?? {})) {
|
|
581
|
+
if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(v)) throw new Error(`the product plan's id token ${JSON.stringify(v)} is not a variable name`);
|
|
582
|
+
if (!aud.trim() || /\s/.test(aud)) throw new Error(`the product plan's id token ${v} names no audience`);
|
|
583
|
+
if (login && v in login.idTokens && login.idTokens[v] !== aud) throw new Error(`the product plan's id token ${v} is the login's, with another audience`);
|
|
584
|
+
if (v in tradeTokens && tradeTokens[v] !== aud) throw new Error(`the product plan's id token ${v} is the trade's, with another audience`);
|
|
585
|
+
}
|
|
586
|
+
const idTokens = { ...(login?.idTokens ?? {}), ...tradeTokens, ...(ownTokens ?? {}) };
|
|
587
|
+
const artifact = plan.artifact ? (name ? `${plan.artifact}-${name}` : plan.artifact) : name ? `chant-pr-plan-${name}` : "chant-pr-plan";
|
|
588
|
+
// #4963: on GitHub and Forgejo the first re-plan job replies to the comments no other job takes.
|
|
589
|
+
const replies = github && Boolean(replanOpts.reply) && (targets === undefined || target === targets[0]);
|
|
590
|
+
const replan0 = replanComments
|
|
591
|
+
? {
|
|
592
|
+
...replanJobOf(forge, env, words, name, artifact, noteWords, { notAffected: replanOpts.notAffected === true }),
|
|
593
|
+
...replanComments,
|
|
594
|
+
...(github && dispatchArg !== undefined ? { dispatch: { argument: dispatchArg } } : {}),
|
|
595
|
+
...(replies ? { reply: { prefix: `/${words.product}`, others } } : {}),
|
|
596
|
+
...(replanOpts.notAffected ? { notAffected: true as const } : {}),
|
|
597
|
+
}
|
|
598
|
+
: undefined;
|
|
599
|
+
const replan = replan0 && plan.record ? { ...replan0, post: { ...replan0.post, command: `${replan0.post.command} --record-run ${replan0.jobName}` } } : replan0;
|
|
600
|
+
const record = plan.record ? { env: { [PLAN_RUN_RECORD_ENV]: JSON.stringify({ op: PLAN_RUN_OP, env, labels: { Env: env, Pipeline: "pr", Job: "plan", ...(name ? { Target: name } : {}) } }) } } : undefined;
|
|
601
|
+
const noteBefore = plan.noteSteps?.before ?? [];
|
|
602
|
+
const noteAfter = plan.noteSteps?.after ?? [];
|
|
188
603
|
return {
|
|
189
604
|
...(name ? { target: name } : {}),
|
|
190
605
|
jobName,
|
|
191
606
|
noteJobName,
|
|
192
|
-
command: plan.command
|
|
607
|
+
command: fill(plan.command, name),
|
|
193
608
|
env: { ...base, ...shared, ...own },
|
|
194
609
|
...(target?.writeProbe ? { writeProbe: target.writeProbe } : {}),
|
|
195
610
|
post: { command: post.command, env: postEnv },
|
|
196
|
-
artifact
|
|
611
|
+
artifact,
|
|
197
612
|
...(planRunner !== undefined ? { runner: planRunner } : {}),
|
|
198
613
|
...(noteRunner !== undefined ? { noteRunner } : {}),
|
|
199
|
-
|
|
614
|
+
// #4978: a target's plan job plans that target alone, so its checks are `plan:<target>` and `policy:<target>`.
|
|
615
|
+
...(evidence ? { evidence: planEvidenceOf(forge, evidence, words, jobName, { ...(plan.forks === "skip" ? { noForks: true } : {}), ...(name ? { member: { name, reportPath: PR_LOOP_REPORT_DIR } } : {}) }) } : {}),
|
|
616
|
+
...(Object.keys(jobEnv).length > 0 ? { jobEnv } : {}),
|
|
617
|
+
...(login && login.steps.length > 0 ? { login: login.steps } : {}),
|
|
618
|
+
...(Object.keys(idTokens).length > 0 ? { idTokens } : {}),
|
|
619
|
+
...(plan.pending && github ? { pending: { context: productStatusContext(words, "plan", name), description: "planning" } } : {}),
|
|
620
|
+
...(control ? { control } : {}),
|
|
621
|
+
...(plan.setup?.length ? { setup: plan.setup } : {}),
|
|
622
|
+
...(plan.report ? { report: fill(plan.report, name) } : {}),
|
|
623
|
+
...(replan ? { replan } : {}),
|
|
624
|
+
...(noteBefore.length > 0 || noteAfter.length > 0 ? { noteSteps: { before: noteBefore, after: noteAfter, ...(plan.noteSteps?.pullRequest ? { pullRequest: true as const } : {}) } } : {}),
|
|
625
|
+
...(record ? { record } : {}),
|
|
626
|
+
...(tradeSpec ? { trade: tradeSpec } : {}),
|
|
627
|
+
...(plan.previousMarker && productMarker ? { previous: { marker: prNoteMarker(env, name), name: productMarker } } : {}),
|
|
200
628
|
};
|
|
201
629
|
};
|
|
202
630
|
return targets ? targets.map(one) : [one()];
|
|
203
631
|
}
|
|
204
632
|
|
|
205
|
-
/** The
|
|
206
|
-
|
|
633
|
+
/** The comments the re-plan answers (#4899): the plan command, then the words' aliases for it. Refused when the words name no plan command. */
|
|
634
|
+
function replanCommentsOf(words: CiProductWords): { comments: string[]; gated: Array<{ comment: string; when: string }> } {
|
|
635
|
+
const command = commentLine(words, "plan");
|
|
636
|
+
if (!command) throw new Error(`the product plan's replan answers /${words.product} <plan command>, and the words name no plan command; name one in the words' commands, or drop replan`);
|
|
637
|
+
const aliases = words.aliases.filter((a) => a.command === "plan");
|
|
638
|
+
return { comments: [command, ...aliases.filter((a) => a.when === undefined).map((a) => a.from)], gated: aliases.filter((a) => a.when !== undefined).map((a) => ({ comment: a.from, when: a.when! })) };
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
/** The re-plan's jobs for one target (#4899), its comments filled in by the caller. */
|
|
642
|
+
function replanJobOf(forge: ForgeKind, env: string, words: CiProductWords, name: string | undefined, artifact: string, noteWords0: Record<string, string>, opts: { notAffected?: boolean } = {}): Omit<ProductPlanReplanJob, "comments" | "gated"> {
|
|
643
|
+
const github = forge !== "gitlab";
|
|
644
|
+
const jobName = github ? (name ? `${REPLAN_JOB}-${name}` : REPLAN_JOB) : name ? `${name}-${REPLAN_JOB}` : REPLAN_JOB;
|
|
645
|
+
const noteJobName = github ? (name ? `${REPLAN_NOTE_JOB}-${name}` : REPLAN_NOTE_JOB) : name ? `${name}-${REPLAN_NOTE_JOB}` : REPLAN_NOTE_JOB;
|
|
646
|
+
// pr-post reads the pull request and the head from the re-plan job, never the comment. GitLab's is GitHub's line with its own --forge.
|
|
647
|
+
const command0 = github ? prLoopPostJob(forge, env, name, words).command : prLoopPostJob("github", env, name, words).command.replace(" --forge github ", " --forge gitlab ");
|
|
648
|
+
// #4963: the argument the re-plan was narrowed to, which pr-post answers "not affected" for when the change does not reach it.
|
|
649
|
+
const command = opts.notAffected ? `${command0} --not-affected "$${PLAN_ARGUMENT_ENV}"` : command0;
|
|
650
|
+
const noteWords = opts.notAffected && github ? { ...noteWords0, [PLAN_ARGUMENT_ENV]: `\${{ needs.${jobName}.outputs.argument }}` } : noteWords0;
|
|
651
|
+
const post = github
|
|
652
|
+
? {
|
|
653
|
+
command,
|
|
654
|
+
env: {
|
|
655
|
+
PR_NUMBER: `\${{ needs.${jobName}.outputs.pr }}`,
|
|
656
|
+
HEAD_SHA: `\${{ needs.${jobName}.outputs.head }}`,
|
|
657
|
+
PLAN_RESULT: `\${{ needs.${jobName}.result }}`,
|
|
658
|
+
GITHUB_TOKEN: GITHUB_JOB_TOKEN,
|
|
659
|
+
...noteWords,
|
|
660
|
+
},
|
|
661
|
+
}
|
|
662
|
+
: {
|
|
663
|
+
// GitLab: the merge request from the pipeline's variable, its head again from the remote, and the re-plan job's result from its artifact.
|
|
664
|
+
command: command.replace(' --result "$PLAN_RESULT"', ""),
|
|
665
|
+
env: { PR_NUMBER: `$${GITLAB_REPLAN_PR_VAR}`, ...noteWords },
|
|
666
|
+
setup: ['HEAD_SHA="$(git ls-remote origin "refs/merge-requests/$PR_NUMBER/head" | cut -f1)" && export HEAD_SHA'],
|
|
667
|
+
};
|
|
668
|
+
return { jobName, noteJobName, post, artifact: `${artifact}-replan` };
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
/** The comment re-plan's job and its note job (#4899). */
|
|
672
|
+
export const REPLAN_JOB = "replan";
|
|
673
|
+
export const REPLAN_NOTE_JOB = "replan-note";
|
|
674
|
+
|
|
675
|
+
/**
|
|
676
|
+
* The GitLab variables the note-commands job starts a re-plan's pipeline
|
|
677
|
+
* with (#4899): the comment preview's (`CHANT_PREVIEW_PR`,
|
|
678
|
+
* `CHANT_PREVIEW_COMMENT`), so `pr-notes --preview-comment` starts it.
|
|
679
|
+
*/
|
|
680
|
+
export const GITLAB_REPLAN_PR_VAR = "CHANT_PREVIEW_PR";
|
|
681
|
+
export const GITLAB_REPLAN_COMMENT_VAR = "CHANT_PREVIEW_COMMENT";
|
|
682
|
+
|
|
683
|
+
/** A regular expression's body that matches `text` literally, for a GitLab rule's `/.../`. */
|
|
684
|
+
function literal(text: string): string {
|
|
685
|
+
return text.replace(/[.*+?^${}()|[\]\\\/]/g, "\\$&");
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
/**
|
|
689
|
+
* The GitLab rule condition that the re-plan pipeline's comment asks for
|
|
690
|
+
* `target` (#4899): the command alone, or with the target's name. Without
|
|
691
|
+
* a target, the command with at most one word after it.
|
|
692
|
+
*/
|
|
693
|
+
export function gitlabReplanCommentIf(replan: Pick<ProductPlanReplanJob, "comments" | "gated">, target?: string): string {
|
|
694
|
+
const arg = target ? `( +${literal(target)})?` : "( +[A-Za-z0-9_.\\/@+=,:-]+)?";
|
|
695
|
+
const one = (c: string): string => `$${GITLAB_REPLAN_COMMENT_VAR} =~ /^${literal(c)}${arg} *$/`;
|
|
696
|
+
return [...replan.comments.map(one), ...replan.gated.map((g) => `($${g.when} && ${one(g.comment)})`)].join(" || ");
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
/**
|
|
700
|
+
* The re-plan job's first step on GitHub and Forgejo (#4899), with the job's
|
|
701
|
+
* token in its environment alone, before anything is checked out: it reads
|
|
702
|
+
* the comment from the event file (never as an expression in a script),
|
|
703
|
+
* decides whether it asks this job to plan, asks the forge for the pull
|
|
704
|
+
* request (open; from this repository with `forks: "skip"`) and, with
|
|
705
|
+
* `CHANT_REPLAN_PERMISSION` set (Forgejo, whose payload says nothing of the
|
|
706
|
+
* commenter), whether the commenter can write. It writes `go=1`, `pr`,
|
|
707
|
+
* `head`, `base` and `argument` to the step's outputs.
|
|
708
|
+
*/
|
|
709
|
+
export const REPLAN_DECIDE_JS = replanDecideJs();
|
|
710
|
+
|
|
711
|
+
/**
|
|
712
|
+
* The re-plan's decision script (#4899) with what `replan`'s options add
|
|
713
|
+
* (#4963). With neither it is {@link REPLAN_DECIDE_JS}, as before.
|
|
714
|
+
*
|
|
715
|
+
* - `dispatch`: on `workflow_dispatch` the pull request is the `pr` input
|
|
716
|
+
* and the argument the input `CHANT_REPLAN_DISPATCH_ARGUMENT` names;
|
|
717
|
+
* a `pr` that is not a number, or an argument that is not one plain
|
|
718
|
+
* word, fails the job. No permission is asked: only a writer dispatches.
|
|
719
|
+
* - `reply`: a comment that starts with `CHANT_REPLAN_PRODUCT` and is not
|
|
720
|
+
* the plan command, nor one of `CHANT_REPLAN_OTHERS`, a target that is
|
|
721
|
+
* none of the plan's, and a fork's pull request with `forks: "skip"`
|
|
722
|
+
* get a reply comment with the reason, once the commenter's permission
|
|
723
|
+
* is known (Forgejo). A dispatch's reason goes to the log alone.
|
|
724
|
+
*/
|
|
725
|
+
export function replanDecideJs(opts: { dispatch?: boolean; reply?: boolean } = {}): string {
|
|
726
|
+
const { dispatch = false, reply = false } = opts;
|
|
727
|
+
const replyLine = reply
|
|
728
|
+
? [
|
|
729
|
+
// The reply, as the product: on a dispatch the log alone.
|
|
730
|
+
`const post=async(t)=>{say(t);${dispatch ? "if(dispatch)return;" : ""}const r=await fetch(api+"/repos/"+repo+"/issues/"+n+"/comments",{method:"POST",headers:{authorization:"token "+process.env.CHANT_REPLAN_TOKEN,accept:"application/json","content-type":"application/json"},body:JSON.stringify({body:product.slice(1)+": "+t})});if(!r.ok)console.error("chant: the reply was not posted: the forge answered "+r.status)};`,
|
|
731
|
+
]
|
|
732
|
+
: [];
|
|
733
|
+
return [
|
|
734
|
+
'const fs=require("fs");',
|
|
735
|
+
'const say=(m)=>console.log("chant: "+m);',
|
|
736
|
+
'const out=(k,v)=>fs.appendFileSync(process.env.GITHUB_OUTPUT,k+"="+v+"\\n");',
|
|
737
|
+
"let e;try{e=JSON.parse(fs.readFileSync(process.env.GITHUB_EVENT_PATH,\"utf8\"))}catch{say(\"the event file does not read, so nothing is planned again\");process.exit(0)}",
|
|
738
|
+
...(dispatch ? ['const dispatch=process.env.GITHUB_EVENT_NAME==="workflow_dispatch",inputs=e.inputs&&typeof e.inputs==="object"?e.inputs:{};'] : []),
|
|
739
|
+
'const body=String((e.comment&&e.comment.body)||"").trim();',
|
|
740
|
+
'const cmds=JSON.parse(process.env.CHANT_REPLAN_COMMANDS||"[]");',
|
|
741
|
+
'for(const g of JSON.parse(process.env.CHANT_REPLAN_GATED||"[]")){const v=process.env[g.when]||"";if(v&&v!=="0"&&v!=="false")cmds.push(g.comment)}',
|
|
742
|
+
"let arg;",
|
|
743
|
+
...(reply ? ['let refusal;const product=process.env.CHANT_REPLAN_PRODUCT||"",others=JSON.parse(process.env.CHANT_REPLAN_OTHERS||"[]");const says=(c)=>body===c||body.startsWith(c+" ")||body.startsWith(c+"\\t");'] : []),
|
|
744
|
+
...(dispatch
|
|
745
|
+
? [
|
|
746
|
+
'if(dispatch){const pv=String(inputs.pr==null?"":inputs.pr).trim();if(!pv){say("the dispatch names no pull request");process.exit(0)}if(!/^[1-9][0-9]{0,9}$/.test(pv)){console.error("chant: the dispatch\\u0027s pr input is a pull request number, like 42");process.exit(1)}',
|
|
747
|
+
'const k=process.env.CHANT_REPLAN_DISPATCH_ARGUMENT||"argument",a=String(inputs[k]==null?"":inputs[k]).trim();if(a&&!/^[A-Za-z0-9_.\\/@+=,:-]+$/.test(a)){console.error("chant: the dispatch\\u0027s "+k+" input is one word of letters, digits and _./@+=,:-");process.exit(1)}arg=a}else ',
|
|
748
|
+
]
|
|
749
|
+
: []),
|
|
750
|
+
'for(const c of cmds){if(body===c){arg="";break}if(body.startsWith(c+" ")){const r=body.slice(c.length).trim();if(/^[A-Za-z0-9_.\\/@+=,:-]+$/.test(r)){arg=r;break}}}',
|
|
751
|
+
reply
|
|
752
|
+
? 'if(arg===undefined){if(product&&says(product)&&!others.some(says)){refusal="the commands are "+cmds.concat(others).map((c)=>"`"+c+"`").join(", ")}else{say("the comment asks for no plan");process.exit(0)}}'
|
|
753
|
+
: 'if(arg===undefined){say("the comment asks for no plan");process.exit(0)}',
|
|
754
|
+
'const target=process.env.CHANT_REPLAN_TARGET||"",targets=JSON.parse(process.env.CHANT_REPLAN_TARGETS||"[]");',
|
|
755
|
+
reply
|
|
756
|
+
? 'if(targets.length&&arg&&!targets.includes(arg)){refusal=arg+" is none of "+targets.join(", ")+", so nothing is planned again";arg=""}'
|
|
757
|
+
: 'if(targets.length&&arg&&!targets.includes(arg)){say(arg+" is none of "+targets.join(", ")+", so nothing is planned again");process.exit(0)}',
|
|
758
|
+
'if(targets.length&&arg&&arg!==target){say("the comment plans "+arg+" again, not "+target);process.exit(0)}',
|
|
759
|
+
dispatch
|
|
760
|
+
? 'const n=dispatch?Number(String(inputs.pr).trim()):e.issue&&e.issue.number;if(!dispatch&&(!Number.isInteger(n)||!(e.issue.pull_request||e.is_pull))){say("the comment is not on a pull request");process.exit(0)}'
|
|
761
|
+
: 'const n=e.issue&&e.issue.number;if(!Number.isInteger(n)||!(e.issue.pull_request||e.is_pull)){say("the comment is not on a pull request");process.exit(0)}',
|
|
762
|
+
'const api=String(process.env.GITHUB_API_URL||"").replace(/\\/+$/,""),repo=process.env.GITHUB_REPOSITORY;',
|
|
763
|
+
'const get=async(p)=>{const r=await fetch(api+"/repos/"+repo+p,{headers:{authorization:"token "+process.env.CHANT_REPLAN_TOKEN,accept:"application/json"}});if(!r.ok)throw new Error(p+" answered "+r.status);return r.json()};',
|
|
764
|
+
...replyLine,
|
|
765
|
+
"(async()=>{",
|
|
766
|
+
...(reply
|
|
767
|
+
? [
|
|
768
|
+
// Who asked comes first: a commenter who cannot write gets no reply.
|
|
769
|
+
`if(process.env.CHANT_REPLAN_PERMISSION${dispatch ? "&&!dispatch" : ""}){const who=e.comment&&e.comment.user&&e.comment.user.login;const p=who?await get("/collaborators/"+encodeURIComponent(who)+"/permission"):{};`,
|
|
770
|
+
'if(!["owner","admin","maintain","write"].includes(p.permission)){say((who||"the commenter")+" cannot write to "+repo+", so nothing is planned again");return}}',
|
|
771
|
+
"if(refusal){await post(refusal);return}",
|
|
772
|
+
'const pr=await get("/pulls/"+n);',
|
|
773
|
+
'if(pr.state!=="open"){say("pull request "+n+" is not open, so it is not planned again");return}',
|
|
774
|
+
'const same=Boolean(pr.head&&pr.head.repo&&pr.head.repo.full_name===repo);',
|
|
775
|
+
'if(!same&&process.env.CHANT_REPLAN_FORKS==="skip"){await post("pull request "+n+" is from a fork, and its code never runs with this repository\\u0027s credentials, so it is not planned again");return}',
|
|
776
|
+
]
|
|
777
|
+
: [
|
|
778
|
+
'const pr=await get("/pulls/"+n);',
|
|
779
|
+
'if(pr.state!=="open"){say("pull request "+n+" is not open, so it is not planned again");return}',
|
|
780
|
+
'const same=Boolean(pr.head&&pr.head.repo&&pr.head.repo.full_name===repo);',
|
|
781
|
+
'if(!same&&process.env.CHANT_REPLAN_FORKS==="skip"){say("pull request "+n+" is from a fork, and its code never runs with this repository\\u0027s credentials");return}',
|
|
782
|
+
`if(process.env.CHANT_REPLAN_PERMISSION${dispatch ? "&&!dispatch" : ""}){const who=e.comment&&e.comment.user&&e.comment.user.login;const p=who?await get("/collaborators/"+encodeURIComponent(who)+"/permission"):{};`,
|
|
783
|
+
'if(!["owner","admin","maintain","write"].includes(p.permission)){say((who||"the commenter")+" cannot write to "+repo+", so nothing is planned again");return}}',
|
|
784
|
+
]),
|
|
785
|
+
'const sha=/^[0-9a-f]{40}$/;if(!sha.test(String(pr.head&&pr.head.sha))||!sha.test(String(pr.base&&pr.base.sha)))throw new Error("the pull request names no head or base commit");',
|
|
786
|
+
'out("go","1");out("pr",String(n));out("head",pr.head.sha);out("base",pr.base.sha);out("argument",arg);',
|
|
787
|
+
'say("planning pull request "+n+" again at "+pr.head.sha.slice(0,12)+(arg?" for "+arg:""))',
|
|
788
|
+
'})().catch((err)=>{console.error("chant: the re-plan could not decide: "+(err&&err.message?err.message:String(err)));process.exit(1)});',
|
|
789
|
+
].join("");
|
|
790
|
+
}
|
|
791
|
+
|
|
792
|
+
/**
|
|
793
|
+
* The previous note's read step on GitHub and Forgejo (#4963): `node -e`,
|
|
794
|
+
* from `/`, with the job's token in `CHANT_PREVIOUS_TOKEN` alone. It pages
|
|
795
|
+
* through pull request `CHANT_PREVIOUS_PR`'s comments for the one whose
|
|
796
|
+
* first line is `CHANT_PREVIOUS_NOTE` (chant's marker), takes its second
|
|
797
|
+
* line's body when it is `<!-- <CHANT_PREVIOUS_NAME> <body> -->` and the
|
|
798
|
+
* body is plain words, and appends `CHANT_PLAN_PREVIOUS_MARKER=<body>` to
|
|
799
|
+
* `$GITHUB_ENV`, empty when there is none. A forge that refuses is a
|
|
800
|
+
* warning: the plan verb plans without it.
|
|
801
|
+
*/
|
|
802
|
+
export const PREVIOUS_MARKER_JS = [
|
|
803
|
+
'const fs=require("fs");',
|
|
804
|
+
'const api=String(process.env.GITHUB_API_URL||"").replace(/\\/+$/,""),repo=process.env.GITHUB_REPOSITORY,n=process.env.CHANT_PREVIOUS_PR||"";',
|
|
805
|
+
'const note=process.env.CHANT_PREVIOUS_NOTE||"",name=process.env.CHANT_PREVIOUS_NAME||"";',
|
|
806
|
+
'const put=(v)=>fs.appendFileSync(process.env.GITHUB_ENV,"CHANT_PLAN_PREVIOUS_MARKER="+v+"\\n");',
|
|
807
|
+
'const esc=(s)=>s.replace(/[.*+?^${}()|[\\]\\\\]/g,"\\\\$&");',
|
|
808
|
+
'const own=new RegExp("^<!-- "+esc(name)+"(?: ([A-Za-z0-9_.,\\\\/@+=:-]+(?: [A-Za-z0-9_.,\\\\/@+=:-]+)*))? -->$");',
|
|
809
|
+
'if(!/^[0-9]+$/.test(n)){console.log("chant: no pull request to read the previous note of");put("");process.exit(0)}',
|
|
810
|
+
"(async()=>{",
|
|
811
|
+
"for(let page=1;page<=50;page++){",
|
|
812
|
+
'const r=await fetch(api+"/repos/"+repo+"/issues/"+n+"/comments?per_page=100&limit=50&page="+page,{headers:{authorization:"token "+process.env.CHANT_PREVIOUS_TOKEN,accept:"application/json"}});',
|
|
813
|
+
'if(!r.ok)throw new Error("the forge answered "+r.status);',
|
|
814
|
+
"const list=await r.json();if(!Array.isArray(list)||list.length===0)break;",
|
|
815
|
+
'for(const c of list){const lines=String(c&&c.body||"").replace(/\\r\\n/g,"\\n").split("\\n");if(lines[0]!==note)continue;const m=own.exec(lines[1]||"");const v=m&&m[1]&&m[1].length<=4096?m[1]:"";put(v);console.log("chant: the previous note"+(v?" carries "+name:" carries no "+name));return}',
|
|
816
|
+
"}",
|
|
817
|
+
'put("");console.log("chant: the pull request has no note yet")',
|
|
818
|
+
'})().catch((err)=>{put("");console.log("chant: the previous note was not read: "+(err&&err.message?err.message:String(err)))});',
|
|
819
|
+
].join("");
|
|
820
|
+
|
|
821
|
+
/** The GitLab re-plan's lines that set {@link PLAN_ARGUMENT_ENV} from the comment's one word after the command (#4899), which the rule already held to plain characters. */
|
|
822
|
+
export function gitlabReplanArgumentLines(replan: Pick<ProductPlanReplanJob, "comments" | "gated">): string[] {
|
|
823
|
+
const byLength = [...replan.comments, ...replan.gated.map((g) => g.comment)].sort((a, b) => b.length - a.length);
|
|
824
|
+
return [
|
|
825
|
+
`case "$${GITLAB_REPLAN_COMMENT_VAR}" in ${byLength.map((c) => `"${c}"*) chant_rest="\${${GITLAB_REPLAN_COMMENT_VAR}#"${c}"}" ;;`).join(" ")} *) chant_rest="" ;; esac`,
|
|
826
|
+
`${PLAN_ARGUMENT_ENV}="$(printf '%s' "$chant_rest" | tr -d ' ')" && export ${PLAN_ARGUMENT_ENV}`,
|
|
827
|
+
];
|
|
828
|
+
}
|
|
829
|
+
|
|
830
|
+
/**
|
|
831
|
+
* The pending step's script on GitHub and Forgejo (#4899): `node -e`, from
|
|
832
|
+
* `/`, posting the plan status pending at `CHANT_PENDING_SHA` with the token
|
|
833
|
+
* in `CHANT_PENDING_TOKEN`. A forge that refuses it is a warning: the note
|
|
834
|
+
* job sets the status the plan ends with.
|
|
835
|
+
*/
|
|
836
|
+
export const PENDING_JS = [
|
|
837
|
+
'const api=String(process.env.GITHUB_API_URL||"").replace(/\\/+$/,""),repo=process.env.GITHUB_REPOSITORY,sha=process.env.CHANT_PENDING_SHA||"";',
|
|
838
|
+
'if(!/^[0-9a-f]{40}$/.test(sha)){console.log("chant: no commit to say the plan started on");process.exit(0)}',
|
|
839
|
+
'const run=process.env.GITHUB_SERVER_URL&&process.env.GITHUB_RUN_ID?process.env.GITHUB_SERVER_URL+"/"+repo+"/actions/runs/"+process.env.GITHUB_RUN_ID:undefined;',
|
|
840
|
+
'fetch(api+"/repos/"+repo+"/statuses/"+sha,{method:"POST",headers:{authorization:"token "+process.env.CHANT_PENDING_TOKEN,accept:"application/json","content-type":"application/json"},body:JSON.stringify({state:"pending",context:process.env.CHANT_PENDING_CONTEXT,description:process.env.CHANT_PENDING_DESCRIPTION,...(run?{target_url:run}:{})})})',
|
|
841
|
+
'.then((r)=>console.log(r.ok?"chant: "+process.env.CHANT_PENDING_CONTEXT+" is pending":"chant: the forge answered "+r.status+" to the pending status"),(err)=>console.log("chant: the pending status was not posted: "+err.message));',
|
|
842
|
+
].join("");
|
|
843
|
+
|
|
844
|
+
/**
|
|
845
|
+
* The plan step's lines for the plan verb (#4899): the verb, then the
|
|
846
|
+
* report line whatever the verb's exit, then the step exits with the verb's
|
|
847
|
+
* status. Without a report line, the verb alone.
|
|
848
|
+
*/
|
|
849
|
+
export function planVerbLines(p: Pick<ProductPlanJob, "command" | "report" | "record">): string[] {
|
|
850
|
+
if (!p.report && !p.record) return [p.command];
|
|
851
|
+
return [
|
|
852
|
+
...(p.record ? ['chant_plan_started="$(date -u +%Y-%m-%dT%H:%M:%SZ)"'] : []),
|
|
853
|
+
"chant_plan_exit=0",
|
|
854
|
+
`${p.command} || chant_plan_exit=$?`,
|
|
855
|
+
...(p.report ? [`${p.report} || echo "chant: the report line exited $?" >&2`] : []),
|
|
856
|
+
// #4899: the run record goes into the hand-off, for the note job to keep on chant/lifecycle.
|
|
857
|
+
...(p.record ? [`CHANT_PLAN_EXIT="$chant_plan_exit" CHANT_PLAN_STARTED="$chant_plan_started" node -e '${PLAN_RECORD_JS}' ${PR_LOOP_REPORT_DIR} || echo "chant: the plan's run record was not written" >&2`] : []),
|
|
858
|
+
'[ "$chant_plan_exit" -eq 0 ] || exit "$chant_plan_exit"',
|
|
859
|
+
];
|
|
860
|
+
}
|
|
861
|
+
|
|
862
|
+
/**
|
|
863
|
+
* The plan step's record line (#4899): `node -e`, writing the run record of
|
|
864
|
+
* the plan verb into the directory it is given, {@link PLAN_RUN_RECORD_FILE}.
|
|
865
|
+
* It reads the op, environment and labels from {@link PLAN_RUN_RECORD_ENV},
|
|
866
|
+
* the verb's exit from `CHANT_PLAN_EXIT`, its start from
|
|
867
|
+
* `CHANT_PLAN_STARTED`, and the commit from git. The shape is an
|
|
868
|
+
* `OpRunRecordInput` (../op/runtime.ts) with no run origin, which the note
|
|
869
|
+
* job names.
|
|
870
|
+
*/
|
|
871
|
+
export const PLAN_RECORD_JS = [
|
|
872
|
+
'const fs=require("fs"),path=require("path"),cp=require("child_process"),crypto=require("crypto");',
|
|
873
|
+
"const c=JSON.parse(process.env.CHANT_PLAN_RECORD||\"{}\"),dir=process.argv[1];",
|
|
874
|
+
'const code=Number(process.env.CHANT_PLAN_EXIT||"1"),ended=new Date().toISOString(),started=new Date(Date.parse(process.env.CHANT_PLAN_STARTED||"")||Date.now()).toISOString();',
|
|
875
|
+
'let sha="";try{sha=cp.execFileSync("git",["rev-parse","HEAD"],{encoding:"utf8",stdio:["ignore","pipe","ignore"]}).trim()}catch{}',
|
|
876
|
+
'const ok=code===0,status=ok?"ok":"fail",ms=Math.max(0,Date.parse(ended)-Date.parse(started));',
|
|
877
|
+
'const rec={id:crypto.randomUUID(),op:c.op,env:c.env,started,ended,status,labels:c.labels||{},outcomes:{},phases:[{name:"plan",status,steps:[{fn:"shellCmd",status,durationMs:ms,...(ok?{}:{error:"command exited "+code})}]}],...(sha?{gitSha:sha}:{}),...(ok?{}:{failure:{code:"command-failed",reason:"the plan verb exited "+code,phase:"plan",exitCode:code}})};',
|
|
878
|
+
`fs.mkdirSync(dir,{recursive:true});fs.writeFileSync(path.join(dir,"${PLAN_RUN_RECORD_FILE}"),JSON.stringify(rec)+"\\n");`,
|
|
879
|
+
].join("");
|
|
880
|
+
|
|
881
|
+
/**
|
|
882
|
+
* The evidence step of one plan job (#4870), as {@link ProductPlanJob.evidence}.
|
|
883
|
+
* #4964: for a workspace member's pipeline (`member`) the checks are signed
|
|
884
|
+
* as `plan:<member>` and `policy:<member>` (`--member`), and on GitLab the
|
|
885
|
+
* report is read from the plan job's artifact at the member's `reportPath`.
|
|
886
|
+
* #4978: a product plan target's plan job is signed the same way, under the
|
|
887
|
+
* target's name.
|
|
888
|
+
*/
|
|
889
|
+
export function planEvidenceOf(forge: ForgeKind, evidence: PipelineEvidence, words: CiProductWords, planJob: string, opts: { noForks?: boolean; member?: { name: string; reportPath: string } } = {}): NonNullable<ProductPlanJob["evidence"]> {
|
|
207
890
|
assertPipelineEvidence(evidence);
|
|
208
891
|
const key = evidenceKeyEnv(forge, evidence);
|
|
209
892
|
const bin = words.bin;
|
|
893
|
+
const member = opts.member ? { member: opts.member.name } : {};
|
|
210
894
|
if (forge === "gitlab") {
|
|
211
|
-
//
|
|
895
|
+
// #4914: the job runs in the target branch's plan notes pipeline, before the note job, and signs every open
|
|
896
|
+
// merge request's settled plan job from its artifact; no job of a merge request pipeline holds the key.
|
|
897
|
+
const dir = gitlabOpenEvidenceDir(planJob);
|
|
212
898
|
return {
|
|
213
899
|
jobName: `${planJob}-evidence`,
|
|
214
|
-
lines:
|
|
900
|
+
lines: openEvidenceLines({ job: planJob, dir: opts.member?.reportPath ?? PR_LOOP_REPORT_DIR, out: dir, ...(bin ? { bin } : {}), ...(opts.noForks ? { noForks: true } : {}), ...member }),
|
|
215
901
|
env: key,
|
|
902
|
+
dir,
|
|
216
903
|
...(evidenceKeyless(evidence) ? { idTokens: evidenceIdTokens(evidence) } : {}),
|
|
217
904
|
};
|
|
218
905
|
}
|
|
219
906
|
return {
|
|
220
|
-
lines: planEvidenceLines({ dir: PR_LOOP_REPORT_DIR, at: '"$HEAD_SHA"', base: '"$BASE_SHA"', result: '"$PLAN_RESULT"', ...(bin ? { bin } : {}) }),
|
|
907
|
+
lines: planEvidenceLines({ dir: PR_LOOP_REPORT_DIR, at: '"$HEAD_SHA"', base: '"$BASE_SHA"', result: '"$PLAN_RESULT"', ...(bin ? { bin } : {}), ...member }),
|
|
221
908
|
env: { HEAD_SHA: "${{ github.sha }}", BASE_SHA: "${{ github.event.pull_request.base.sha }}", PLAN_RESULT: `\${{ needs.${planJob}.result }}`, ...key },
|
|
222
909
|
...(evidenceKeyless(evidence) ? { idToken: true as const } : {}),
|
|
223
910
|
};
|