@intentius/chant 0.124.55 → 0.124.57
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ci-agent.d.ts.map +1 -1
- package/dist/ci-agent.js +1 -2
- package/dist/ci-audit/attribution.d.ts +111 -0
- package/dist/ci-audit/attribution.d.ts.map +1 -0
- package/dist/ci-audit/attribution.js +194 -0
- package/dist/ci-audit/audit-log.d.ts +144 -0
- package/dist/ci-audit/audit-log.d.ts.map +1 -0
- package/dist/ci-audit/audit-log.js +149 -0
- package/dist/ci-audit/index.d.ts +12 -0
- package/dist/ci-audit/index.d.ts.map +1 -0
- package/dist/ci-audit/index.js +11 -0
- package/dist/ci-audit/unrecorded.d.ts +74 -0
- package/dist/ci-audit/unrecorded.d.ts.map +1 -0
- package/dist/ci-audit/unrecorded.js +95 -0
- package/dist/ci-audit.d.ts +3 -0
- package/dist/ci-audit.d.ts.map +1 -0
- package/dist/ci-audit.js +2 -0
- package/dist/ci-control.d.ts.map +1 -1
- package/dist/ci-control.js +3 -4
- package/dist/ci-estate.d.ts +24 -0
- package/dist/ci-estate.d.ts.map +1 -1
- package/dist/ci-estate.js +1 -2
- package/dist/ci-identity.d.ts.map +1 -1
- package/dist/ci-identity.js +2 -3
- package/dist/ci-job-guard.d.ts +139 -0
- package/dist/ci-job-guard.d.ts.map +1 -0
- package/dist/ci-job-guard.js +287 -0
- package/dist/ci-jobs.d.ts +7 -0
- package/dist/ci-jobs.d.ts.map +1 -1
- package/dist/ci-jobs.js +7 -0
- package/dist/ci-product-words.d.ts +7 -1
- package/dist/ci-product-words.d.ts.map +1 -1
- package/dist/ci-product-words.js +38 -4
- package/dist/ci-product.d.ts +35 -0
- package/dist/ci-product.d.ts.map +1 -1
- package/dist/ci-product.js +38 -4
- package/dist/ci-respond-run.d.ts +73 -0
- package/dist/ci-respond-run.d.ts.map +1 -0
- package/dist/ci-respond-run.js +247 -0
- package/dist/ci-respond.d.ts +189 -0
- package/dist/ci-respond.d.ts.map +1 -0
- package/dist/ci-respond.js +285 -0
- package/dist/cli/handlers/audit-log.d.ts +12 -0
- package/dist/cli/handlers/audit-log.d.ts.map +1 -0
- package/dist/cli/handlers/audit-log.js +81 -0
- package/dist/cli/handlers/build.d.ts +7 -0
- package/dist/cli/handlers/build.d.ts.map +1 -1
- package/dist/cli/handlers/build.js +81 -0
- package/dist/cli/handlers/ci-check-job.d.ts +11 -0
- package/dist/cli/handlers/ci-check-job.d.ts.map +1 -0
- package/dist/cli/handlers/ci-check-job.js +27 -0
- package/dist/cli/handlers/ci-check.d.ts.map +1 -1
- package/dist/cli/handlers/ci-check.js +38 -9
- package/dist/cli/handlers/e2e-safe-run.d.ts +12 -0
- package/dist/cli/handlers/e2e-safe-run.d.ts.map +1 -0
- package/dist/cli/handlers/e2e-safe-run.js +23 -0
- package/dist/cli/handlers/lifecycle.d.ts.map +1 -1
- package/dist/cli/handlers/lifecycle.js +14 -0
- package/dist/cli/handlers/pr.d.ts +5 -0
- package/dist/cli/handlers/pr.d.ts.map +1 -1
- package/dist/cli/handlers/pr.js +346 -36
- package/dist/cli/handlers/run-wave.js +89 -1
- package/dist/cli/main.d.ts.map +1 -1
- package/dist/cli/main.js +56 -2
- package/dist/cli/parse-args.d.ts.map +1 -1
- package/dist/cli/parse-args.js +107 -0
- package/dist/cli/registry.d.ts +38 -0
- package/dist/cli/registry.d.ts.map +1 -1
- package/dist/components/adoption.d.ts.map +1 -1
- package/dist/components/adoption.js +1 -2
- package/dist/components/auto-release.d.ts +5 -2
- package/dist/components/auto-release.d.ts.map +1 -1
- package/dist/components/auto-release.js +9 -4
- package/dist/components/capability.d.ts +47 -0
- package/dist/components/capability.d.ts.map +1 -1
- package/dist/components/capability.js +25 -0
- package/dist/components/check-hooks.d.ts +4 -1
- package/dist/components/check-hooks.d.ts.map +1 -1
- package/dist/components/check-steps.d.ts +74 -0
- package/dist/components/check-steps.d.ts.map +1 -0
- package/dist/components/check-steps.js +102 -0
- package/dist/components/ci-services.d.ts.map +1 -1
- package/dist/components/ci-services.js +1 -2
- package/dist/components/deploy-units.d.ts +12 -0
- package/dist/components/deploy-units.d.ts.map +1 -1
- package/dist/components/deploy-units.js +20 -1
- package/dist/components/driver.d.ts +12 -0
- package/dist/components/driver.d.ts.map +1 -1
- package/dist/components/driver.js +35 -1
- package/dist/components/groups.d.ts.map +1 -1
- package/dist/components/groups.js +4 -3
- package/dist/components/pr-env-ledger.d.ts.map +1 -1
- package/dist/components/pr-env-ledger.js +1 -2
- package/dist/components/pr-environment.d.ts +1 -1
- package/dist/components/pr-environment.d.ts.map +1 -1
- package/dist/components/pr-environment.js +1 -1
- package/dist/components/pr-pipeline.d.ts +137 -5
- package/dist/components/pr-pipeline.d.ts.map +1 -1
- package/dist/components/pr-pipeline.js +164 -20
- package/dist/components/pr-run.d.ts +8 -0
- package/dist/components/pr-run.d.ts.map +1 -1
- package/dist/components/pr-run.js +9 -4
- package/dist/components/product-pipeline.d.ts +35 -2
- package/dist/components/product-pipeline.d.ts.map +1 -1
- package/dist/components/product-pipeline.js +24 -5
- package/dist/components/row-lease.d.ts +22 -1
- package/dist/components/row-lease.d.ts.map +1 -1
- package/dist/components/row-lease.js +32 -6
- package/dist/components/wave-plan.d.ts +8 -0
- package/dist/components/wave-plan.d.ts.map +1 -1
- package/dist/components/wave-plan.js +18 -2
- package/dist/e2e-harness/bucket.d.ts +21 -0
- package/dist/e2e-harness/bucket.d.ts.map +1 -0
- package/dist/e2e-harness/bucket.js +61 -0
- package/dist/e2e-harness/claim.d.ts +70 -0
- package/dist/e2e-harness/claim.d.ts.map +1 -0
- package/dist/e2e-harness/claim.js +98 -0
- package/dist/e2e-harness/driver.d.ts +64 -0
- package/dist/e2e-harness/driver.d.ts.map +1 -0
- package/dist/e2e-harness/driver.js +243 -0
- package/dist/e2e-harness/forgejo.d.ts +77 -0
- package/dist/e2e-harness/forgejo.d.ts.map +1 -0
- package/dist/e2e-harness/forgejo.js +205 -0
- package/dist/e2e-harness/git.d.ts +32 -0
- package/dist/e2e-harness/git.d.ts.map +1 -0
- package/dist/e2e-harness/git.js +67 -0
- package/dist/e2e-harness/index.d.ts +22 -0
- package/dist/e2e-harness/index.d.ts.map +1 -0
- package/dist/e2e-harness/index.js +47 -0
- package/dist/e2e-harness/jobs.d.ts +8 -0
- package/dist/e2e-harness/jobs.d.ts.map +1 -0
- package/dist/e2e-harness/jobs.js +34 -0
- package/dist/e2e-harness/pins.d.ts +45 -0
- package/dist/e2e-harness/pins.d.ts.map +1 -0
- package/dist/e2e-harness/pins.js +44 -0
- package/dist/e2e-harness/ports.d.ts +113 -0
- package/dist/e2e-harness/ports.d.ts.map +1 -0
- package/dist/e2e-harness/ports.js +4 -0
- package/dist/e2e-harness/reports.d.ts +45 -0
- package/dist/e2e-harness/reports.d.ts.map +1 -0
- package/dist/e2e-harness/reports.js +57 -0
- package/dist/e2e-harness/safe-run-cli.d.ts +17 -0
- package/dist/e2e-harness/safe-run-cli.d.ts.map +1 -0
- package/dist/e2e-harness/safe-run-cli.js +43 -0
- package/dist/e2e-harness/safe-run.d.ts +61 -0
- package/dist/e2e-harness/safe-run.d.ts.map +1 -0
- package/dist/e2e-harness/safe-run.js +172 -0
- package/dist/e2e-harness/scenario.d.ts +11 -0
- package/dist/e2e-harness/scenario.d.ts.map +1 -0
- package/dist/e2e-harness/scenario.js +89 -0
- package/dist/e2e-harness/schemas/demo-cycle.schema.json +282 -0
- package/dist/e2e-harness/schemas/demo-step.schema.json +245 -0
- package/dist/e2e-harness/schemas/e2e-claim-row.schema.json +33 -0
- package/dist/e2e-harness/schemas/e2e-claims.schema.json +18 -0
- package/dist/e2e-harness/schemas/e2e-scenario.schema.json +150 -0
- package/dist/e2e-harness/schemas/index.d.ts +191 -0
- package/dist/e2e-harness/schemas/index.d.ts.map +1 -0
- package/dist/e2e-harness/schemas/index.js +62 -0
- package/dist/e2e-harness/stack.d.ts +124 -0
- package/dist/e2e-harness/stack.d.ts.map +1 -0
- package/dist/e2e-harness/stack.js +207 -0
- package/dist/e2e-harness/steps.d.ts +11 -0
- package/dist/e2e-harness/steps.d.ts.map +1 -0
- package/dist/e2e-harness/steps.js +22 -0
- package/dist/e2e-harness.d.ts +3 -0
- package/dist/e2e-harness.d.ts.map +1 -0
- package/dist/e2e-harness.js +2 -0
- package/dist/exit-codes.d.ts +7 -1
- package/dist/exit-codes.d.ts.map +1 -1
- package/dist/exit-codes.js +7 -1
- package/dist/lexicon.d.ts +55 -0
- package/dist/lexicon.d.ts.map +1 -1
- package/dist/lifecycle/gate-ledger.d.ts.map +1 -1
- package/dist/lifecycle/gate-ledger.js +2 -3
- package/dist/lifecycle/gated-request.d.ts.map +1 -1
- package/dist/lifecycle/gated-request.js +1 -2
- package/dist/lifecycle/git.d.ts +39 -3
- package/dist/lifecycle/git.d.ts.map +1 -1
- package/dist/lifecycle/git.js +223 -15
- package/dist/lifecycle/lock-rows.d.ts +23 -0
- package/dist/lifecycle/lock-rows.d.ts.map +1 -1
- package/dist/lifecycle/lock-rows.js +47 -8
- package/dist/lifecycle/query.d.ts.map +1 -1
- package/dist/lifecycle/query.js +4 -5
- package/dist/lifecycle/release-catalog.d.ts.map +1 -1
- package/dist/lifecycle/release-catalog.js +1 -1
- package/dist/lifecycle/release-ledger.d.ts.map +1 -1
- package/dist/lifecycle/release-ledger.js +1 -2
- package/dist/lifecycle/release-status.d.ts +20 -0
- package/dist/lifecycle/release-status.d.ts.map +1 -1
- package/dist/lifecycle/release-status.js +1 -22
- package/dist/lifecycle/resource-lock.d.ts +70 -0
- package/dist/lifecycle/resource-lock.d.ts.map +1 -1
- package/dist/lifecycle/resource-lock.js +241 -5
- package/dist/lifecycle/wave-plans.d.ts +23 -7
- package/dist/lifecycle/wave-plans.d.ts.map +1 -1
- package/dist/lifecycle/wave-plans.js +9 -2
- package/dist/op/approval-status.d.ts +103 -0
- package/dist/op/approval-status.d.ts.map +1 -0
- package/dist/op/approval-status.js +197 -0
- package/dist/op/gate.js +21 -4
- package/dist/op/index.d.ts +1 -1
- package/dist/op/index.d.ts.map +1 -1
- package/dist/op/index.js +1 -1
- package/dist/op/op-waves-capability-spec.d.ts +8 -0
- package/dist/op/op-waves-capability-spec.d.ts.map +1 -1
- package/dist/op/op-waves-capability-spec.js +21 -0
- package/dist/op/op-waves-release-port.js +1 -1
- package/dist/op/op-waves-release.d.ts +2 -1
- package/dist/op/op-waves-release.d.ts.map +1 -1
- package/dist/op/op-waves-release.js +1 -2
- package/dist/op/op-waves-run.d.ts +15 -2
- package/dist/op/op-waves-run.d.ts.map +1 -1
- package/dist/op/op-waves-run.js +195 -31
- package/dist/op/op-waves-stand-down.d.ts.map +1 -1
- package/dist/op/op-waves-stand-down.js +1 -2
- package/dist/op/op-waves.d.ts +53 -0
- package/dist/op/op-waves.d.ts.map +1 -1
- package/dist/op/op-waves.js +62 -6
- package/dist/op/runtime.d.ts +4 -0
- package/dist/op/runtime.d.ts.map +1 -1
- package/dist/op/runtime.js +2 -3
- package/dist/otlp.d.ts.map +1 -1
- package/dist/otlp.js +1 -2
- package/dist/parallelism.d.ts +17 -0
- package/dist/parallelism.d.ts.map +1 -0
- package/dist/parallelism.js +33 -0
- package/dist/policy-source.d.ts.map +1 -1
- package/dist/policy-source.js +1 -2
- package/dist/pr-forge.d.ts.map +1 -1
- package/dist/pr-forge.js +56 -39
- package/dist/pr-loop.d.ts +9 -0
- package/dist/pr-loop.d.ts.map +1 -1
- package/dist/pr-loop.js +22 -4
- package/dist/pr-merge.d.ts +64 -0
- package/dist/pr-merge.d.ts.map +1 -0
- package/dist/pr-merge.js +78 -0
- package/dist/pr-post.d.ts +70 -1
- package/dist/pr-post.d.ts.map +1 -1
- package/dist/pr-post.js +116 -5
- package/dist/pr-report-url.d.ts.map +1 -1
- package/dist/pr-report-url.js +1 -2
- package/dist/release-floors.d.ts +1 -1
- package/dist/release-floors.js +1 -1
- package/dist/run-event.d.ts.map +1 -1
- package/dist/run-event.js +1 -2
- package/dist/scheduled-op-cloud.d.ts +32 -0
- package/dist/scheduled-op-cloud.d.ts.map +1 -0
- package/dist/scheduled-op-cloud.js +69 -0
- package/dist/wave-runtime.mjs +351 -328
- package/dist/workspace/ci-lock-grain.d.ts +5 -0
- package/dist/workspace/ci-lock-grain.d.ts.map +1 -1
- package/dist/workspace/ci-lock-grain.js +1 -7
- package/dist/workspace/ci-run.d.ts.map +1 -1
- package/dist/workspace/ci-run.js +5 -1
- package/dist/workspace/pr-report.schema.json +5 -0
- package/package.json +1 -1
- package/src/ci-agent.ts +1 -2
- package/src/ci-audit/__fixtures__/cloudtrail-lookup-bucket.json +37 -0
- package/src/ci-audit/__fixtures__/cloudtrail-writes-window.json +59 -0
- package/src/ci-audit/attribution.ts +260 -0
- package/src/ci-audit/audit-log.ts +220 -0
- package/src/ci-audit/ci-audit.test.ts +175 -0
- package/src/ci-audit/index.ts +14 -0
- package/src/ci-audit/unrecorded.ts +140 -0
- package/src/ci-audit.ts +2 -0
- package/src/ci-control.ts +3 -4
- package/src/ci-estate.ts +1 -2
- package/src/ci-identity-database.test.ts +2 -3
- package/src/ci-identity-targets.test.ts +1 -3
- package/src/ci-identity.ts +2 -3
- package/src/ci-job-guard.test.ts +154 -0
- package/src/ci-job-guard.ts +319 -0
- package/src/ci-jobs.ts +8 -0
- package/src/ci-product-comment-targets.test.ts +45 -0
- package/src/ci-product-words.ts +35 -6
- package/src/ci-product.ts +55 -4
- package/src/ci-respond-run.ts +291 -0
- package/src/ci-respond.test.ts +264 -0
- package/src/ci-respond.ts +412 -0
- package/src/cli/handlers/audit-log.ts +74 -0
- package/src/cli/handlers/build-pr-loop-flags.test.ts +98 -0
- package/src/cli/handlers/build.ts +69 -0
- package/src/cli/handlers/ci-check-job.test.ts +114 -0
- package/src/cli/handlers/ci-check-job.ts +33 -0
- package/src/cli/handlers/ci-check.ts +38 -8
- package/src/cli/handlers/e2e-safe-run.ts +27 -0
- package/src/cli/handlers/lifecycle.ts +13 -0
- package/src/cli/handlers/pr-before-merge.test.ts +1 -1
- package/src/cli/handlers/pr-deploy-inputs.test.ts +1 -1
- package/src/cli/handlers/pr-endpoint.test.ts +1 -1
- package/src/cli/handlers/pr-green.test.ts +1 -1
- package/src/cli/handlers/pr-plan-comment-targets.test.ts +166 -0
- package/src/cli/handlers/pr-plan-flags.test.ts +161 -0
- package/src/cli/handlers/pr-plan-targets.test.ts +1 -1
- package/src/cli/handlers/pr-record.test.ts +34 -2
- package/src/cli/handlers/pr-waves-blocked.test.ts +1 -1
- package/src/cli/handlers/pr-waves.test.ts +1 -1
- package/src/cli/handlers/pr.test.ts +1 -1
- package/src/cli/handlers/pr.ts +311 -32
- package/src/cli/handlers/run-wave.ts +79 -1
- package/src/cli/main.test.ts +1 -1
- package/src/cli/main.ts +56 -2
- package/src/cli/parse-args.ts +77 -0
- package/src/cli/registry.ts +38 -0
- package/src/components/adoption.ts +1 -2
- package/src/components/auto-release.test.ts +4 -2
- package/src/components/auto-release.ts +9 -5
- package/src/components/capability.ts +60 -0
- package/src/components/check-hooks.ts +4 -1
- package/src/components/check-steps.test.ts +70 -0
- package/src/components/check-steps.ts +158 -0
- package/src/components/ci-services.ts +1 -2
- package/src/components/deploy-units.test.ts +18 -1
- package/src/components/deploy-units.ts +26 -1
- package/src/components/driver.ts +35 -1
- package/src/components/groups.ts +4 -2
- package/src/components/plan-flags.test.ts +46 -0
- package/src/components/pr-comment-preview-targets.test.ts +34 -0
- package/src/components/pr-env-ledger.ts +1 -2
- package/src/components/pr-env-run-bundle.test.ts +0 -20
- package/src/components/pr-environment.ts +1 -1
- package/src/components/pr-pipeline-runners.test.ts +80 -0
- package/src/components/pr-pipeline.ts +244 -20
- package/src/components/pr-run.ts +17 -6
- package/src/components/pr-stale-job.test.ts +34 -0
- package/src/components/product-pipeline.ts +50 -8
- package/src/components/row-lease.test.ts +61 -1
- package/src/components/row-lease.ts +48 -7
- package/src/components/wave-plan.ts +18 -2
- package/src/e2e-harness/__project__/chant.config.ts +4 -0
- package/src/e2e-harness/__project__/src/compose.ts +33 -0
- package/src/e2e-harness/bucket.ts +69 -0
- package/src/e2e-harness/claim.test.ts +150 -0
- package/src/e2e-harness/claim.ts +140 -0
- package/src/e2e-harness/driver.test.ts +304 -0
- package/src/e2e-harness/driver.ts +294 -0
- package/src/e2e-harness/forgejo.ts +267 -0
- package/src/e2e-harness/git.ts +96 -0
- package/src/e2e-harness/index.ts +49 -0
- package/src/e2e-harness/jobs.ts +35 -0
- package/src/e2e-harness/pins.ts +52 -0
- package/src/e2e-harness/ports.ts +130 -0
- package/src/e2e-harness/reports.ts +79 -0
- package/src/e2e-harness/safe-run-cli.test.ts +102 -0
- package/src/e2e-harness/safe-run-cli.ts +54 -0
- package/src/e2e-harness/safe-run.ts +198 -0
- package/src/e2e-harness/scenario.ts +89 -0
- package/src/e2e-harness/schemas/README.md +62 -0
- package/src/e2e-harness/schemas/demo-cycle.schema.json +282 -0
- package/src/e2e-harness/schemas/demo-step.schema.json +245 -0
- package/src/e2e-harness/schemas/e2e-claim-row.schema.json +33 -0
- package/src/e2e-harness/schemas/e2e-claims.schema.json +18 -0
- package/src/e2e-harness/schemas/e2e-scenario.schema.json +150 -0
- package/src/e2e-harness/schemas/index.ts +220 -0
- package/src/e2e-harness/schemas.test.ts +145 -0
- package/src/e2e-harness/stack.test.ts +124 -0
- package/src/e2e-harness/stack.ts +306 -0
- package/src/e2e-harness/steps.ts +30 -0
- package/src/e2e-harness.ts +2 -0
- package/src/exit-codes.test.ts +3 -2
- package/src/exit-codes.ts +7 -1
- package/src/gate-decision-bundle.test.ts +0 -2
- package/src/lexicon.ts +57 -0
- package/src/lifecycle/control-entries-ledger.test.ts +2 -3
- package/src/lifecycle/gate-ledger.ts +2 -3
- package/src/lifecycle/gated-request.ts +1 -2
- package/src/lifecycle/git.test.ts +155 -0
- package/src/lifecycle/git.ts +213 -17
- package/src/lifecycle/lock-rows.test.ts +6 -1
- package/src/lifecycle/lock-rows.ts +58 -7
- package/src/lifecycle/query.ts +4 -5
- package/src/lifecycle/release-catalog.test.ts +3 -4
- package/src/lifecycle/release-catalog.ts +1 -1
- package/src/lifecycle/release-ledger.ts +1 -2
- package/src/lifecycle/release-status.test.ts +3 -4
- package/src/lifecycle/release-status.ts +1 -2
- package/src/lifecycle/resource-lock-wait.test.ts +292 -0
- package/src/lifecycle/resource-lock.ts +261 -7
- package/src/lifecycle/wave-plans.ts +33 -5
- package/src/op/approval-status.test.ts +134 -0
- package/src/op/approval-status.ts +235 -0
- package/src/op/gate-review.test.ts +2 -1
- package/src/op/gate.test.ts +7 -5
- package/src/op/gate.ts +20 -4
- package/src/op/index.ts +2 -0
- package/src/op/op-waves-after-plan.test.ts +11 -0
- package/src/op/op-waves-capability-spec.ts +20 -0
- package/src/op/op-waves-ledger-lock.test.ts +208 -0
- package/src/op/op-waves-parallelism.test.ts +89 -0
- package/src/op/op-waves-pull-request.test.ts +78 -1
- package/src/op/op-waves-release-port.ts +1 -1
- package/src/op/op-waves-release.ts +2 -3
- package/src/op/op-waves-run.ts +196 -31
- package/src/op/op-waves-stand-down.ts +1 -2
- package/src/op/op-waves.ts +81 -6
- package/src/op/runtime.ts +6 -3
- package/src/otlp.ts +1 -2
- package/src/parallelism.test.ts +38 -0
- package/src/parallelism.ts +33 -0
- package/src/policy-source.ts +1 -2
- package/src/pr-forge-bundle.test.ts +1 -1
- package/src/pr-forge.ts +54 -35
- package/src/pr-loop-bundle.test.ts +0 -2
- package/src/pr-loop-narrowed.test.ts +63 -0
- package/src/pr-loop.ts +30 -4
- package/src/pr-merge.test.ts +100 -0
- package/src/pr-merge.ts +105 -0
- package/src/pr-post-stale.test.ts +163 -0
- package/src/pr-post.ts +159 -5
- package/src/pr-report-url.ts +1 -2
- package/src/product-subpaths-plain-node.e2e.test.ts +1 -0
- package/src/release-floors.ts +1 -1
- package/src/run-event.ts +1 -2
- package/src/scheduled-op-cloud.ts +68 -0
- package/src/stage-hooks-bundle.test.ts +0 -2
- package/src/workspace/ci-lock-grain.ts +1 -2
- package/src/workspace/ci-run.ts +5 -1
- package/src/workspace/pr-report.schema.json +5 -0
package/src/cli/handlers/pr.ts
CHANGED
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
|
|
67
67
|
import { spawnSync } from "node:child_process";
|
|
68
68
|
import { CHANT_EXIT } from "../../exit-codes";
|
|
69
|
-
import { anyResourceGrain, leaseRowsOf as leaseRowsOfLocks, lockTargetsOf, type LockGrain } from "../../lifecycle/lock-rows";
|
|
69
|
+
import { anyResourceGrain, leaseRowsOf as leaseRowsOfLocks, lockTargetsOf, queueRowsOfLocks, type LockGrain } from "../../lifecycle/lock-rows";
|
|
70
70
|
import { existsSync, mkdirSync, readFileSync, realpathSync, writeFileSync } from "node:fs";
|
|
71
71
|
import { dirname, join, relative, resolve, sep } from "node:path";
|
|
72
72
|
import { loadChantConfig, resolveAutoReleaseDisabled, type ChantConfig } from "../../config";
|
|
@@ -122,7 +122,7 @@ import {
|
|
|
122
122
|
import { FORGE_KINDS, forgeFromEnv, forgePrincipalOf, type ForgeKind, type PrForge } from "../../pr-forge";
|
|
123
123
|
import { GITHUB_COMMENT_LIMIT, GITLAB_NOTE_LIMIT } from "../../plan-summary";
|
|
124
124
|
import { upsertPlanNote } from "../../pr-post";
|
|
125
|
-
import { activeProductWords, productContext } from "../../ci-product-words";
|
|
125
|
+
import { activeProductWords, commandWord, parseProductComment, productContext } from "../../ci-product-words";
|
|
126
126
|
import { resolveCliBuildParams, parseParamFlags } from "../build-params-cli";
|
|
127
127
|
import { formatError, formatInfo, formatSuccess, formatWarning } from "../format";
|
|
128
128
|
import { reportUninstalledDependencies } from "../dependencies";
|
|
@@ -135,9 +135,10 @@ import type { CommandContext } from "../registry";
|
|
|
135
135
|
import { parseArgs } from "../parse-args";
|
|
136
136
|
import { withComponentEndpoint } from "../component-endpoint";
|
|
137
137
|
import type { ComponentChangeSignal, FanOutPlan } from "../../components/fan-out";
|
|
138
|
-
import { assertTargetsAccepted, failedRunExitCode, type DriverComponent } from "../../components/driver";
|
|
139
|
-
import { TargetsRefusedError, type CapabilityRegistry } from "../../components/capability";
|
|
138
|
+
import { assertPlanFlagsAccepted, assertTargetsAccepted, failedRunExitCode, type DriverComponent } from "../../components/driver";
|
|
139
|
+
import { PLAN_FLAG_ARGS, PlanFlagRefusedError, TargetsRefusedError, type CapabilityRegistry } from "../../components/capability";
|
|
140
140
|
import { prPlanTargets } from "../../components/pr-targets";
|
|
141
|
+
import { PREVIEW_COMMENT_ENV } from "../../components/pr-pipeline";
|
|
141
142
|
import type { ComponentEnvironmentDeclaration } from "../../components/component";
|
|
142
143
|
import { prLoopHooksAt, runPrHooks, type PrHoldSettled, type PrHookPlace, type PrLoopHooks } from "../../components/pr-hooks";
|
|
143
144
|
import { decidePrPolicyOverride, policyReviewOf, prLoopPolicyAt, prPolicyReport, runPrPolicy, spendPrPolicyOverride, type PrLoopPolicy } from "../../components/pr-policy";
|
|
@@ -181,6 +182,11 @@ export interface Prepared {
|
|
|
181
182
|
hookPlace?: PrHookPlace;
|
|
182
183
|
/** `pr-plan --target` (#4620): the addresses each planned member's capability plan narrows to. */
|
|
183
184
|
targets?: Record<string, string[]>;
|
|
185
|
+
/** `pr-plan --parallelism <n>` (#4625): how many members of a wave plan at once. */
|
|
186
|
+
parallelism?: number;
|
|
187
|
+
/** `pr-plan --refresh` and `--target-dependents` (#4627). */
|
|
188
|
+
refresh?: boolean;
|
|
189
|
+
targetDependents?: boolean;
|
|
184
190
|
/**
|
|
185
191
|
* Set when `ci.branches` or `ci.labels` (#4292) leave the member out of this
|
|
186
192
|
* stage: why. The plan is then empty, so the stage reports `nothing`.
|
|
@@ -224,6 +230,10 @@ export async function prepare(ctx: CommandContext, stage: "plan" | "apply" | "re
|
|
|
224
230
|
if (stage !== "plan" && args.targets && args.targets.length > 0) {
|
|
225
231
|
return fail(`pr-${stage} applies or records what the pull request's approved plan covers, so it takes no --target`, "Narrow the plan with pr-plan --target, and approve that plan.");
|
|
226
232
|
}
|
|
233
|
+
// #4627: refresh and target dependents change what the preview plans, as a target does.
|
|
234
|
+
if (stage !== "plan" && (args.refresh || args.targetDependents)) {
|
|
235
|
+
return fail(`pr-${stage} applies or records what the pull request's approved plan covers, so it takes no ${args.refresh ? "--refresh" : "--target-dependents"}`, "Plan with pr-plan --refresh or --target-dependents, and approve that plan.");
|
|
236
|
+
}
|
|
227
237
|
let member: string | undefined;
|
|
228
238
|
if (args.members?.length) {
|
|
229
239
|
const checked = await checkMember(projectPath, args.members);
|
|
@@ -502,9 +512,58 @@ export async function planBare(p: Prepared, onRunEvent?: RunEventSink): Promise<
|
|
|
502
512
|
policyBase: p.base,
|
|
503
513
|
...(onRunEvent ? { onRunEvent } : {}),
|
|
504
514
|
...(p.targets ? { targets: p.targets } : {}),
|
|
515
|
+
...(p.parallelism !== undefined ? { parallelism: p.parallelism } : {}),
|
|
516
|
+
...(p.refresh ? { refresh: true } : {}),
|
|
517
|
+
...(p.targetDependents ? { targetDependents: true } : {}),
|
|
505
518
|
});
|
|
506
519
|
}
|
|
507
520
|
|
|
521
|
+
/**
|
|
522
|
+
* `pr-plan --refresh` and `--target-dependents` (#4627), from the line or
|
|
523
|
+
* the preview comment: set on `p`, or the exit code when a planned member's
|
|
524
|
+
* capability cannot honour one, named before anything plans, as
|
|
525
|
+
* {@link narrowToTargets} does for targets. `--target-dependents` needs a
|
|
526
|
+
* target.
|
|
527
|
+
*/
|
|
528
|
+
function planWithFlags(p: Prepared, flags: { refresh?: boolean; targetDependents?: boolean }): number | undefined {
|
|
529
|
+
if (!flags.refresh && !flags.targetDependents) return undefined;
|
|
530
|
+
if (flags.targetDependents && !p.targets) return fail("--target-dependents widens a --target to what depends on it, and nothing was narrowed", "Give --target <address> with it.");
|
|
531
|
+
const byName = new Map(p.components.map((c) => [c.name, c]));
|
|
532
|
+
for (const name of p.plan.order) {
|
|
533
|
+
const component = byName.get(name);
|
|
534
|
+
if (!component) continue;
|
|
535
|
+
try {
|
|
536
|
+
assertPlanFlagsAccepted(component, p.registry, { ...(flags.refresh ? { refresh: true } : {}), ...(flags.targetDependents && p.targets?.[name] ? { targetDependents: true } : {}) });
|
|
537
|
+
} catch (err) {
|
|
538
|
+
if (err instanceof PlanFlagRefusedError) return fail(`${err.message}, so nothing was planned`, `Drop ${PLAN_FLAG_ARGS[err.flag]}, or plan only members whose steps take it.`);
|
|
539
|
+
throw err;
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
if (flags.refresh) p.refresh = true;
|
|
543
|
+
if (flags.targetDependents) p.targetDependents = true;
|
|
544
|
+
console.error(formatInfo(`planning with ${[flags.refresh ? "--refresh" : "", flags.targetDependents ? "--target-dependents" : ""].filter(Boolean).join(" and ")}`));
|
|
545
|
+
return undefined;
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
/**
|
|
549
|
+
* `pr-plan --comment-targets` (#4626): the `--target` addresses of the
|
|
550
|
+
* preview comment in {@link PREVIEW_COMMENT_ENV}, read with the product's
|
|
551
|
+
* grammar, or the exit code when the comment is refused. No comment, or one
|
|
552
|
+
* with no target: none. The checks `--target` makes follow in
|
|
553
|
+
* {@link narrowToTargets}.
|
|
554
|
+
*/
|
|
555
|
+
function commentTargets(env: NodeJS.ProcessEnv = process.env): { targets: string[]; refresh?: true; targetDependents?: true } | number {
|
|
556
|
+
const body = env[PREVIEW_COMMENT_ENV];
|
|
557
|
+
if (body === undefined || body.trim() === "") return { targets: [] };
|
|
558
|
+
const words = activeProductWords();
|
|
559
|
+
const parsed = parseProductComment(words, body, env);
|
|
560
|
+
if (parsed === undefined) return { targets: [] };
|
|
561
|
+
if (parsed.kind === "refused") return fail(`the preview comment is refused: ${parsed.reason}, so nothing was planned`, `/${words.product} ${commandWord(words, "plan") ?? "plan"} --target <address> narrows the preview to the address.`);
|
|
562
|
+
if (parsed.kind !== "plan") return { targets: [] };
|
|
563
|
+
// #4627: the comment's --refresh and --target-dependents too.
|
|
564
|
+
return { targets: parsed.targets ?? [], ...(parsed.refresh ? { refresh: true as const } : {}), ...(parsed.targetDependents ? { targetDependents: true as const } : {}) };
|
|
565
|
+
}
|
|
566
|
+
|
|
508
567
|
/**
|
|
509
568
|
* `pr-plan --target` (#4620): the addresses by member, set on `p`, or the
|
|
510
569
|
* exit code when a value is refused or a targeted member has a capability
|
|
@@ -558,18 +617,42 @@ async function leaseSetRows(p: Prepared, set: Pick<PrPlanSet, "locks">): Promise
|
|
|
558
617
|
*/
|
|
559
618
|
export async function leaseRowsOf(p: Pick<Prepared, "gate">, set: Pick<PrPlanSet, "locks">, label = "this apply"): Promise<{ release(): Promise<boolean> } | { held: string } | { failed: string }> {
|
|
560
619
|
const rows = leaseRowsOfLocks(set.locks);
|
|
561
|
-
|
|
562
|
-
const
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
620
|
+
// The ruling for ci-products (2026-10-28): the target and repo grains wait for their rows first, oldest commit first.
|
|
621
|
+
const queue = queueRowsOfLocks(set.locks);
|
|
622
|
+
if (rows.length === 0 && queue.length === 0) return { release: () => Promise.resolve(true) };
|
|
623
|
+
const { commitTimeOf, leaseLockRows, lockPollMs, lockWaitSeconds } = await import("../../lifecycle/resource-lock");
|
|
624
|
+
const held: Array<{ release(): Promise<boolean> }> = [];
|
|
625
|
+
const releaseAll = async () => {
|
|
626
|
+
let ok = true;
|
|
627
|
+
for (const l of held.reverse()) ok = (await l.release()) && ok;
|
|
628
|
+
return ok;
|
|
629
|
+
};
|
|
630
|
+
for (const [wanted, wait] of [[queue, true], [rows, false]] as const) {
|
|
631
|
+
if (wanted.length === 0) continue;
|
|
632
|
+
let leased;
|
|
633
|
+
try {
|
|
634
|
+
const commitAt = wait ? await commitTimeOf(process.env.GITHUB_SHA || process.env.CI_COMMIT_SHA || "HEAD") : undefined;
|
|
635
|
+
leased = await leaseLockRows(
|
|
636
|
+
p.gate,
|
|
637
|
+
wanted,
|
|
638
|
+
wait
|
|
639
|
+
? { wait: { deadline: Date.now() + lockWaitSeconds(process.env) * 1000, pollMs: lockPollMs(process.env), log: (line) => console.error(formatInfo(`${label} ${line}`)), ...(commitAt ? { commitAt } : {}) } }
|
|
640
|
+
: {},
|
|
641
|
+
);
|
|
642
|
+
} catch (err) {
|
|
643
|
+
await releaseAll();
|
|
644
|
+
return { failed: `could not hold the rows ${label} changes in ${p.gate}, so nothing of it was applied: ${err instanceof Error ? err.message : String(err)}` };
|
|
645
|
+
}
|
|
646
|
+
if (!leased.ok) {
|
|
647
|
+
await releaseAll();
|
|
648
|
+
if (leased.timedOut) return { held: `LockWaitTimeoutError: ${leased.message}, so nothing of ${label} was applied.` };
|
|
649
|
+
return { held: `${leased.message}, so nothing of ${label} was applied. Apply again once that run ends; a run that is gone, or whose lease is older than CHANT_LOCK_STALE seconds, is taken over.` };
|
|
650
|
+
}
|
|
651
|
+
for (const h of leased.tookOver) console.error(formatInfo(`took over the rows of run ${h.run}, which is gone`));
|
|
652
|
+
console.error(formatInfo(`${label} holds ${leased.lease.keys.length} row${leased.lease.keys.length === 1 ? "" : "s"} of ${p.gate}${leased.waited ? ` after waiting ${leased.waitedSeconds ?? 0}s` : ""} while it applies`));
|
|
653
|
+
held.push(leased.lease);
|
|
568
654
|
}
|
|
569
|
-
|
|
570
|
-
for (const h of leased.tookOver) console.error(formatInfo(`took over the rows of run ${h.run}, which is gone`));
|
|
571
|
-
console.error(formatInfo(`${label} holds ${leased.lease.keys.length} row${leased.lease.keys.length === 1 ? "" : "s"} of ${p.gate} while it applies`));
|
|
572
|
-
return leased.lease;
|
|
655
|
+
return { release: releaseAll };
|
|
573
656
|
}
|
|
574
657
|
|
|
575
658
|
/** `applyPrSet`'s `leaseRound` (#4594): a round after the first leases the rows its own plan locks. */
|
|
@@ -813,8 +896,14 @@ async function prPlan(ctx: CommandContext, stage: StageEvents): Promise<number>
|
|
|
813
896
|
}
|
|
814
897
|
const p = await prepare(ctx, "plan");
|
|
815
898
|
if (typeof p === "number") return p;
|
|
816
|
-
|
|
899
|
+
// #4626: the preview comment's --target addresses, read from the comment the job carries in a variable.
|
|
900
|
+
const fromComment = ctx.args.commentTargets ? commentTargets() : { targets: [] };
|
|
901
|
+
if (typeof fromComment === "number") return fromComment;
|
|
902
|
+
const narrowed = narrowToTargets(p, [...(ctx.args.targets ?? []), ...fromComment.targets]);
|
|
817
903
|
if (narrowed !== undefined) return narrowed;
|
|
904
|
+
const flagged = planWithFlags(p, { refresh: ctx.args.refresh === true || fromComment.refresh === true, targetDependents: ctx.args.targetDependents === true || fromComment.targetDependents === true });
|
|
905
|
+
if (flagged !== undefined) return flagged;
|
|
906
|
+
if (ctx.args.parallelism !== undefined) p.parallelism = ctx.args.parallelism;
|
|
818
907
|
const op = prOp(ctx.args.pr, p.member);
|
|
819
908
|
placeHooks(ctx, p, "plan", op);
|
|
820
909
|
const upload = openUpload(stage, "plan", ctx.args.pr, p);
|
|
@@ -955,6 +1044,9 @@ export function runComponentsPrApply(ctx: CommandContext): Promise<number> {
|
|
|
955
1044
|
// #4301: an apply before merge asks the forge its requires checks before any of the head's code loads, the config included.
|
|
956
1045
|
let beforeMerge: PrBeforeMerge | undefined;
|
|
957
1046
|
if (ctx.args.requires && !ctx.args.beforeMerge) return fail("--requires names the checks of an apply before merge, so it needs --before-merge --pr <n>");
|
|
1047
|
+
// #4636: the merge after the update, checked before anything applies.
|
|
1048
|
+
const mergeProblem = await mergeArgsProblem(ctx.args);
|
|
1049
|
+
if (mergeProblem) return fail(mergeProblem);
|
|
958
1050
|
if (ctx.args.beforeMerge) {
|
|
959
1051
|
const checked = await beforeMergeChecks(ctx);
|
|
960
1052
|
if (typeof checked === "number") return checked;
|
|
@@ -1265,12 +1357,78 @@ async function prApply(ctx: CommandContext, stage: StageEvents, beforeMerge?: Pr
|
|
|
1265
1357
|
: applied.leaseFailed
|
|
1266
1358
|
? 1
|
|
1267
1359
|
: failedRunExitCode(applied.run.results);
|
|
1268
|
-
|
|
1269
|
-
const code = await stop(report, exit, applied.run.status === "gated" ? "gated" : undefined);
|
|
1360
|
+
const lost = green && applied.status === "applied" ? await recordGreenApplied(p, green, set.doc.digest, approval, via) : false;
|
|
1361
|
+
const code = await stop(report, lost && exit === 0 ? 1 : exit, applied.run.status === "gated" ? "gated" : undefined);
|
|
1270
1362
|
if (applied.status === "applied" && !afterFailed) console.error(formatSuccess(`applied the plan ${report.digest} approved by ${(approval.approvedBy ?? []).join(", ")}`));
|
|
1363
|
+
// #4636: an update before merge that applied every member merges the pull request, never the other way round.
|
|
1364
|
+
if (code === 0 && beforeMerge && pr !== null && args.merge === "auto" && applied.status === "applied" && !afterFailed) return mergeAfterUpdate(ctx, p, pr);
|
|
1271
1365
|
return code;
|
|
1272
1366
|
}
|
|
1273
1367
|
|
|
1368
|
+
/** `--merge`, `--merge-token-env` and `--merge-method` as one problem, or undefined when they hold together. */
|
|
1369
|
+
async function mergeArgsProblem(args: CommandContext["args"]): Promise<string | undefined> {
|
|
1370
|
+
const { PR_APPLY_MERGES, PR_MERGE_METHODS } = await import("../../pr-merge");
|
|
1371
|
+
if (args.merge === undefined) {
|
|
1372
|
+
if (args.mergeTokenEnv || args.mergeMethod) return "--merge-token-env and --merge-method go with --merge auto";
|
|
1373
|
+
return undefined;
|
|
1374
|
+
}
|
|
1375
|
+
if (!(PR_APPLY_MERGES as readonly string[]).includes(args.merge)) return `--merge takes ${PR_APPLY_MERGES.join(" or ")}, not ${args.merge}`;
|
|
1376
|
+
if (args.merge === "manual") return args.mergeTokenEnv || args.mergeMethod ? "--merge manual leaves the merge to a person, so it takes no --merge-token-env or --merge-method" : undefined;
|
|
1377
|
+
if (!args.beforeMerge) return "--merge auto merges a pull request once its update before merge applied, so it needs --before-merge --pr <n>";
|
|
1378
|
+
if (!args.mergeTokenEnv) return "--merge auto merges with a token of its own, never the job's: --merge-token-env <VAR> (on GitLab a protected variable)";
|
|
1379
|
+
if (args.mergeMethod && !(PR_MERGE_METHODS as readonly string[]).includes(args.mergeMethod)) return `--merge-method takes ${PR_MERGE_METHODS.join(", ")}, not ${args.mergeMethod}`;
|
|
1380
|
+
return undefined;
|
|
1381
|
+
}
|
|
1382
|
+
|
|
1383
|
+
/**
|
|
1384
|
+
* The merge after an update before merge applied (#4636): the apply's
|
|
1385
|
+
* records pushed to the ledger, the head checked again, then the forge's
|
|
1386
|
+
* merge with the token `--merge-token-env` names alone. A refusal is posted
|
|
1387
|
+
* on the pull request and exits as waiting (3); the update stays applied.
|
|
1388
|
+
*/
|
|
1389
|
+
async function mergeAfterUpdate(ctx: CommandContext, p: Prepared, pr: number): Promise<number> {
|
|
1390
|
+
const { mergeAfterApply, mergeTokenEnv } = await import("../../pr-merge");
|
|
1391
|
+
const { pushLifecycleRebasing, LifecyclePushLostError } = await import("../../lifecycle/git");
|
|
1392
|
+
const kind = p.forge?.kind ?? (ctx.args.forge as ForgeKind | undefined);
|
|
1393
|
+
if (!kind) return fail("--merge auto needs --forge <kind> to merge on");
|
|
1394
|
+
const env = mergeTokenEnv(ctx.args.mergeTokenEnv!);
|
|
1395
|
+
if ("error" in env) {
|
|
1396
|
+
console.error(formatWarning({ message: `the pull request was not merged: ${env.error}` }));
|
|
1397
|
+
return CHANT_EXIT.waiting;
|
|
1398
|
+
}
|
|
1399
|
+
let forge: PrForge;
|
|
1400
|
+
try {
|
|
1401
|
+
forge = forgeFromEnv(kind, env);
|
|
1402
|
+
} catch (err) {
|
|
1403
|
+
console.error(formatWarning({ message: `the pull request was not merged: ${err instanceof Error ? err.message : String(err)}` }));
|
|
1404
|
+
return CHANT_EXIT.waiting;
|
|
1405
|
+
}
|
|
1406
|
+
// A refused push fetches, replays the apply's records on the remote's tip and pushes again (#4551).
|
|
1407
|
+
let pushed: { pushed: boolean; pushWarning?: string };
|
|
1408
|
+
let lost = false;
|
|
1409
|
+
try {
|
|
1410
|
+
pushed = await pushLifecycleRebasing();
|
|
1411
|
+
} catch (err) {
|
|
1412
|
+
if (!(err instanceof LifecyclePushLostError)) throw err;
|
|
1413
|
+
console.error(formatError({ message: err.message }));
|
|
1414
|
+
pushed = { pushed: false, pushWarning: err.message };
|
|
1415
|
+
lost = true;
|
|
1416
|
+
}
|
|
1417
|
+
const merged = await mergeAfterApply({
|
|
1418
|
+
forge,
|
|
1419
|
+
pr,
|
|
1420
|
+
head: p.head,
|
|
1421
|
+
...(ctx.args.mergeMethod ? { method: ctx.args.mergeMethod as "merge" | "squash" | "rebase" } : {}),
|
|
1422
|
+
recorded: { pushed: pushed.pushed, ...(pushed.pushWarning ? { warning: pushed.pushWarning } : {}) },
|
|
1423
|
+
});
|
|
1424
|
+
if (merged.merged) {
|
|
1425
|
+
console.error(formatSuccess(`merged ${kind === "gitlab" ? `!${pr}` : `#${pr}`} at ${p.head.slice(0, 12)}${merged.sha ? ` as ${merged.sha.slice(0, 12)}` : ""}`));
|
|
1426
|
+
return 0;
|
|
1427
|
+
}
|
|
1428
|
+
console.error(formatWarning({ message: `the pull request was not merged: ${merged.reason}${merged.posted ? "; the reason is posted on it" : ""}` }));
|
|
1429
|
+
return lost ? 1 : CHANT_EXIT.waiting;
|
|
1430
|
+
}
|
|
1431
|
+
|
|
1274
1432
|
/**
|
|
1275
1433
|
* Under `ci.locks` (#4293): the refusal when another open pull request holds
|
|
1276
1434
|
* a lock on a component this apply reaches, else null. The targets are the
|
|
@@ -1477,7 +1635,10 @@ async function prRecord(ctx: CommandContext, stage: StageEvents): Promise<number
|
|
|
1477
1635
|
});
|
|
1478
1636
|
|
|
1479
1637
|
const { mergeSourceOf, writeMergeRecord, MERGE_RECORD_SCHEMA_ID, MERGE_RECORD_CONTRACT } = await import("../../lifecycle/merge-record");
|
|
1480
|
-
const {
|
|
1638
|
+
const { pushLifecycleRebasing, LifecyclePushLostError } = await import("../../lifecycle/git");
|
|
1639
|
+
// Set when the merge record never reached the remote: the job fails rather than warns, since a record kept only
|
|
1640
|
+
// in this job's checkout is lost with it (#4551).
|
|
1641
|
+
let lost = false;
|
|
1481
1642
|
// #4292: a member another branch applies has no merge on this one, so no record says it planned nothing here.
|
|
1482
1643
|
if (!p.routedAway) {
|
|
1483
1644
|
try {
|
|
@@ -1500,16 +1661,21 @@ async function prRecord(ctx: CommandContext, stage: StageEvents): Promise<number
|
|
|
1500
1661
|
recordedAt: new Date().toISOString(),
|
|
1501
1662
|
});
|
|
1502
1663
|
if (written.written) {
|
|
1503
|
-
const pushed = await
|
|
1664
|
+
const pushed = await pushLifecycleRebasing();
|
|
1504
1665
|
if (pushed.pushWarning) console.error(formatWarning({ message: pushed.pushWarning }));
|
|
1505
1666
|
}
|
|
1506
1667
|
} catch (err) {
|
|
1507
|
-
|
|
1668
|
+
if (err instanceof LifecyclePushLostError) {
|
|
1669
|
+
console.error(formatError({ message: `the merge record for ${p.head} was written but not pushed: ${err.message}` }));
|
|
1670
|
+
lost = true;
|
|
1671
|
+
} else {
|
|
1672
|
+
console.error(formatWarning({ message: `could not write the merge record for ${p.head}: ${err instanceof Error ? err.message : String(err)}` }));
|
|
1673
|
+
}
|
|
1508
1674
|
}
|
|
1509
1675
|
}
|
|
1510
1676
|
|
|
1511
1677
|
const stop = stopper(ctx, p, events, upload);
|
|
1512
|
-
return stop(report, status === "plan-failed" ? 1 : 0);
|
|
1678
|
+
return stop(report, status === "plan-failed" || lost ? 1 : 0);
|
|
1513
1679
|
}
|
|
1514
1680
|
|
|
1515
1681
|
/** What a gate's description and messages call the change: the pull request, or the green commit (#4168 step 9). */
|
|
@@ -1606,10 +1772,15 @@ function reviewFor(args: CommandContext["args"], p: Prepared, pr: number | null,
|
|
|
1606
1772
|
};
|
|
1607
1773
|
}
|
|
1608
1774
|
|
|
1609
|
-
/**
|
|
1610
|
-
|
|
1775
|
+
/**
|
|
1776
|
+
* Record the green commit as applied to the environment (#4168 step 9), and
|
|
1777
|
+
* push `chant/lifecycle`, fetching and replaying on a refused push. A record
|
|
1778
|
+
* that never reaches the remote is an error and returns true, so the stage
|
|
1779
|
+
* fails; any other failure warns.
|
|
1780
|
+
*/
|
|
1781
|
+
async function recordGreenApplied(p: Prepared, green: GreenTarget, digest: string, approval: PrApproval, via: "merges" | "gate"): Promise<boolean> {
|
|
1611
1782
|
const { writeGreenApply, GREEN_APPLY_CONTRACT } = await import("../../lifecycle/green-apply");
|
|
1612
|
-
const {
|
|
1783
|
+
const { pushLifecycleRebasing, LifecyclePushLostError } = await import("../../lifecycle/git");
|
|
1613
1784
|
try {
|
|
1614
1785
|
await writeGreenApply({
|
|
1615
1786
|
contract: GREEN_APPLY_CONTRACT,
|
|
@@ -1623,11 +1794,16 @@ async function recordGreenApplied(p: Prepared, green: GreenTarget, digest: strin
|
|
|
1623
1794
|
merges: green.merges,
|
|
1624
1795
|
appliedAt: new Date().toISOString(),
|
|
1625
1796
|
});
|
|
1626
|
-
const pushed = await
|
|
1797
|
+
const pushed = await pushLifecycleRebasing();
|
|
1627
1798
|
if (pushed.pushWarning) console.error(formatWarning({ message: pushed.pushWarning }));
|
|
1628
1799
|
} catch (err) {
|
|
1800
|
+
if (err instanceof LifecyclePushLostError) {
|
|
1801
|
+
console.error(formatError({ message: `the record of ${green.commit.slice(0, 12)} as applied to ${p.env} was written but not pushed: ${err.message}` }));
|
|
1802
|
+
return true;
|
|
1803
|
+
}
|
|
1629
1804
|
console.error(formatWarning({ message: `could not record ${green.commit.slice(0, 12)} as applied to ${p.env}: ${err instanceof Error ? err.message : String(err)}` }));
|
|
1630
1805
|
}
|
|
1806
|
+
return false;
|
|
1631
1807
|
}
|
|
1632
1808
|
|
|
1633
1809
|
/** How a stage stops: settle its events, write and publish the report, say how it ended, and return `code`. */
|
|
@@ -1635,6 +1811,8 @@ function stopper(ctx: CommandContext, p: Prepared, events: RunEventStream | unde
|
|
|
1635
1811
|
return async (report: PrReport, code: number, settle?: RunEventSettleStatus): Promise<number> => {
|
|
1636
1812
|
events?.settle(settle ?? settleOf(report.status), report.status === "plan-failed" || report.status === "failed" ? report.message ?? `pr-${report.stage} ${report.status}` : undefined);
|
|
1637
1813
|
await finish(ctx, p, report, upload);
|
|
1814
|
+
// #4629: a failed apply's triage and a refused apply's diff, on the pull request.
|
|
1815
|
+
if (report.stage === "apply" && (report.status === "failed" || report.status === "refused") && !ctx.args.noStatus) await respondApply(ctx, p, report);
|
|
1638
1816
|
console.error((code === 0 ? formatInfo : (m: string) => formatWarning({ message: m }))(`pr-${report.stage}: ${report.status}${report.refusal ? ` (${report.refusal})` : ""}`));
|
|
1639
1817
|
if (report.message) console.error(report.message);
|
|
1640
1818
|
printMembers(report);
|
|
@@ -1642,6 +1820,22 @@ function stopper(ctx: CommandContext, p: Prepared, events: RunEventStream | unde
|
|
|
1642
1820
|
};
|
|
1643
1821
|
}
|
|
1644
1822
|
|
|
1823
|
+
/** The responses an apply's report calls for (#4629), from `--respond` over `CHANT_RESPOND`. Never throws. */
|
|
1824
|
+
async function respondApply(ctx: CommandContext, p: Prepared, report: PrReport): Promise<void> {
|
|
1825
|
+
try {
|
|
1826
|
+
const { parseRespondList } = await import("../../ci-respond");
|
|
1827
|
+
const given = ctx.args.respond ? parseRespondList(ctx.args.respond) : {};
|
|
1828
|
+
if ("error" in given) {
|
|
1829
|
+
console.error(formatWarning({ message: `no response was posted: ${given.error}` }));
|
|
1830
|
+
return;
|
|
1831
|
+
}
|
|
1832
|
+
const { respondPrApply } = await import("../../ci-respond-run");
|
|
1833
|
+
await respondPrApply(p.forge, report, given);
|
|
1834
|
+
} catch (err) {
|
|
1835
|
+
console.error(formatWarning({ message: `the apply's responses were not posted: ${err instanceof Error ? err.message : String(err)}` }));
|
|
1836
|
+
}
|
|
1837
|
+
}
|
|
1838
|
+
|
|
1645
1839
|
/** Why `--require-review` does not count an approval, or why the reviews could not be read. */
|
|
1646
1840
|
type ReviewStop = { refusal: "author-approved" | "not-a-reviewer"; message: string } | { error: string } | undefined;
|
|
1647
1841
|
|
|
@@ -1761,12 +1955,14 @@ function emitReviewStop(events: RunEventStream | undefined, message: string): vo
|
|
|
1761
1955
|
|
|
1762
1956
|
/**
|
|
1763
1957
|
* Store `doc` under its digest with its entries mapped onto the member's
|
|
1764
|
-
* graph (`storeGateChangeSet`), and push
|
|
1765
|
-
* decides the same either
|
|
1958
|
+
* graph (`storeGateChangeSet`), and push, fetching and replaying on a refused
|
|
1959
|
+
* push. A failure to store is a warning: the gate decides the same either
|
|
1960
|
+
* way. A change set that never reaches the remote throws
|
|
1961
|
+
* `LifecyclePushLostError`, which stops the stage.
|
|
1766
1962
|
*/
|
|
1767
1963
|
async function storeChangeSetForGate(ctx: CommandContext, p: Prepared, doc: PrPlanSet["doc"]): Promise<void> {
|
|
1768
1964
|
const { storeGateChangeSet, gateGraphReader } = await import("../../lifecycle/gate-change-set");
|
|
1769
|
-
const {
|
|
1965
|
+
const { pushLifecycleRebasing, LifecyclePushLostError } = await import("../../lifecycle/git");
|
|
1770
1966
|
const graphArgs = [
|
|
1771
1967
|
...(ctx.args.param ?? []).flatMap((kv) => ["--param", kv]),
|
|
1772
1968
|
...(ctx.args.paramsFile ? ["--params-file", ctx.args.paramsFile] : []),
|
|
@@ -1776,8 +1972,9 @@ async function storeChangeSetForGate(ctx: CommandContext, p: Prepared, doc: PrPl
|
|
|
1776
1972
|
if (stored.warning) console.error(formatWarning({ message: stored.warning }));
|
|
1777
1973
|
// The push's own outcome is said by the gate's pending fact, or by the
|
|
1778
1974
|
// release records the apply writes, which push the same branch.
|
|
1779
|
-
if (stored.written) await
|
|
1975
|
+
if (stored.written) await pushLifecycleRebasing();
|
|
1780
1976
|
} catch (err) {
|
|
1977
|
+
if (err instanceof LifecyclePushLostError) throw err;
|
|
1781
1978
|
console.error(formatWarning({ message: `could not store the change set ${doc.digest}: ${err instanceof Error ? err.message : String(err)}` }));
|
|
1782
1979
|
}
|
|
1783
1980
|
}
|
|
@@ -2197,8 +2394,8 @@ async function prApplyWaves(
|
|
|
2197
2394
|
}
|
|
2198
2395
|
|
|
2199
2396
|
const done = p.plan.order.every((name) => completed.has(name));
|
|
2200
|
-
|
|
2201
|
-
return stop(report({ status: done ? "applied" : "wave-applied" }), 0);
|
|
2397
|
+
const lost = green && done ? await recordGreenApplied(p, green, approvedSet.doc.digest, approval, via) : false;
|
|
2398
|
+
return stop(report({ status: done ? "applied" : "wave-applied" }), lost ? 1 : 0);
|
|
2202
2399
|
}
|
|
2203
2400
|
|
|
2204
2401
|
// ── The component plan-wave and apply-wave steps (#4588) ─────────────────────
|
|
@@ -2574,6 +2771,7 @@ function writeWaveChangeSet(ctx: CommandContext, wave: number, doc: PrPlanSet["d
|
|
|
2574
2771
|
*/
|
|
2575
2772
|
export async function runComponentsPrPost(ctx: CommandContext): Promise<number> {
|
|
2576
2773
|
const { args } = ctx;
|
|
2774
|
+
if (args.stale) return runComponentsPrPostStale(ctx);
|
|
2577
2775
|
if (args.open) return runComponentsPrPostOpen(ctx);
|
|
2578
2776
|
if (args.pr === undefined) return fail("pr-post needs the pull or merge request: --pr <n>");
|
|
2579
2777
|
if (!args.head || !/^[0-9a-f]{40}$/.test(args.head)) return fail("pr-post needs the full commit the plan job checked out: --head <sha>");
|
|
@@ -2588,6 +2786,8 @@ export async function runComponentsPrPost(ctx: CommandContext): Promise<number>
|
|
|
2588
2786
|
}
|
|
2589
2787
|
const { postPlanReport } = await import("../../pr-post");
|
|
2590
2788
|
const member = args.members?.[0];
|
|
2789
|
+
const description = await descriptionCheckOf(ctx, forge);
|
|
2790
|
+
if (typeof description === "number") return description;
|
|
2591
2791
|
const posted = await postPlanReport({
|
|
2592
2792
|
forge,
|
|
2593
2793
|
dir: resolve(args.output ?? PR_REPORT_DIR),
|
|
@@ -2598,6 +2798,10 @@ export async function runComponentsPrPost(ctx: CommandContext): Promise<number>
|
|
|
2598
2798
|
...(args.planResult ? { result: args.planResult } : {}),
|
|
2599
2799
|
// #4289: the plan job could not ask the forge, so the note job does, from the Ops at the commit it checked out.
|
|
2600
2800
|
overdue: () => overdueOps(forge, member),
|
|
2801
|
+
...(description ? { description } : {}),
|
|
2802
|
+
// #4628: the target branch's commit for the note's tip line, and the job summary where the forge keeps one.
|
|
2803
|
+
...(args.tip ? { baseTip: args.tip } : {}),
|
|
2804
|
+
...(args.forge !== "gitlab" && process.env.GITHUB_STEP_SUMMARY ? { summaryFile: process.env.GITHUB_STEP_SUMMARY } : {}),
|
|
2601
2805
|
});
|
|
2602
2806
|
for (const message of posted.warnings) console.error(formatWarning({ message }));
|
|
2603
2807
|
if (posted.refused) console.error(formatWarning({ message: `the plan report was not used: ${posted.refused}` }));
|
|
@@ -2605,6 +2809,76 @@ export async function runComponentsPrPost(ctx: CommandContext): Promise<number>
|
|
|
2605
2809
|
return 0;
|
|
2606
2810
|
}
|
|
2607
2811
|
|
|
2812
|
+
/**
|
|
2813
|
+
* The description check pr-post runs after the note (#4629), when the
|
|
2814
|
+
* responses turn it on (`--respond description=check`, or `CHANT_RESPOND`):
|
|
2815
|
+
* the `decide.backends` entry `--decide-backend` names, from chant.config
|
|
2816
|
+
* at the commit this job checked out (the target branch's, never the pull
|
|
2817
|
+
* request's), and the model `--decide-model` pins. On with no backend is
|
|
2818
|
+
* refused, so a pipeline that asks for the check learns it never ran.
|
|
2819
|
+
*/
|
|
2820
|
+
async function descriptionCheckOf(ctx: CommandContext, forge: PrForge): Promise<((report: PrReport) => Promise<void>) | undefined | number> {
|
|
2821
|
+
const { parseRespondList, resolveResponses } = await import("../../ci-respond");
|
|
2822
|
+
const given = ctx.args.respond ? parseRespondList(ctx.args.respond) : {};
|
|
2823
|
+
if ("error" in given) return fail(given.error);
|
|
2824
|
+
if (resolveResponses(given, process.env, (m) => console.error(formatWarning({ message: m }))).description !== "check") return undefined;
|
|
2825
|
+
const name = ctx.args.decideBackend;
|
|
2826
|
+
if (!name || !ctx.args.decideModel) return fail("the description check asks a decide service, so it needs --decide-backend <name> and --decide-model <id>", "Name a decide.backends entry of chant.config, or turn the check off: --respond description=off");
|
|
2827
|
+
const { loadChantConfig } = await import("../../config");
|
|
2828
|
+
let backend;
|
|
2829
|
+
try {
|
|
2830
|
+
const loaded = await loadChantConfig(process.cwd());
|
|
2831
|
+
backend = loaded.config.decide?.backends?.[name];
|
|
2832
|
+
} catch (err) {
|
|
2833
|
+
return fail(`could not read decide.backends from chant.config: ${err instanceof Error ? err.message : String(err)}`);
|
|
2834
|
+
}
|
|
2835
|
+
if (!backend) return fail(`the description check names the backend ${name}, and chant.config has no decide.backends.${name}`);
|
|
2836
|
+
const { backendDescriptionAsk, respondDescription } = await import("../../ci-respond-run");
|
|
2837
|
+
const ask = backendDescriptionAsk(backend, { name, model: ctx.args.decideModel, cwd: process.cwd() });
|
|
2838
|
+
return async (report) => {
|
|
2839
|
+
await respondDescription(forge, report, { ask });
|
|
2840
|
+
};
|
|
2841
|
+
}
|
|
2842
|
+
|
|
2843
|
+
/**
|
|
2844
|
+
* `pr-post --stale --tip <sha> --env <env> --forge <kind> [--branch <branch>]
|
|
2845
|
+
* [--member <name>] [--preview-comment]` (#4628): after a push to the target
|
|
2846
|
+
* branch, mark each open pull request's note that was posted against
|
|
2847
|
+
* another commit stale, naming the comment that previews again with
|
|
2848
|
+
* `--preview-comment`, and set its plan status back to pending
|
|
2849
|
+
* (`markStaleNotes`, ../../pr-post.ts). The branch is `--branch`, else the
|
|
2850
|
+
* job's (`GITHUB_REF_NAME`, `CI_COMMIT_BRANCH`). It exits 0 once it has
|
|
2851
|
+
* marked, as `pr-post` does.
|
|
2852
|
+
*/
|
|
2853
|
+
async function runComponentsPrPostStale(ctx: CommandContext): Promise<number> {
|
|
2854
|
+
const { args } = ctx;
|
|
2855
|
+
if (args.pr !== undefined || args.head) return fail("pr-post --stale finds each open pull request and its head itself, so it takes no --pr or --head");
|
|
2856
|
+
if (!args.tip) return fail("pr-post --stale needs the target branch's commit now: --tip <sha>");
|
|
2857
|
+
if (!args.env) return fail("pr-post needs the environment the plan was for: --env <env>");
|
|
2858
|
+
if (!args.forge || !(FORGE_KINDS as readonly string[]).includes(args.forge)) return fail(`pr-post posts to a forge: --forge ${FORGE_KINDS.join("|")}`);
|
|
2859
|
+
if (args.members && args.members.length > 1) return fail(`pr-post takes one --member, not ${args.members.join(", ")}`);
|
|
2860
|
+
const branch = args.branch ?? process.env.CI_COMMIT_BRANCH ?? process.env.GITHUB_REF_NAME;
|
|
2861
|
+
if (!branch) return fail("pr-post --stale marks the notes of the pull requests into a branch: run it in a job of a push, or pass --branch <branch>");
|
|
2862
|
+
let forge: PrForge;
|
|
2863
|
+
try {
|
|
2864
|
+
forge = forgeFromEnv(args.forge as ForgeKind);
|
|
2865
|
+
} catch (err) {
|
|
2866
|
+
return fail(err instanceof Error ? err.message : String(err));
|
|
2867
|
+
}
|
|
2868
|
+
const member = args.members?.[0];
|
|
2869
|
+
const { markStaleNotes } = await import("../../pr-post");
|
|
2870
|
+
let done: Awaited<ReturnType<typeof markStaleNotes>>;
|
|
2871
|
+
try {
|
|
2872
|
+
done = await markStaleNotes({ forge, branch, tip: args.tip, env: args.env, ...(member ? { member } : {}), ...(args.previewComment ? { previewComment: true } : {}) });
|
|
2873
|
+
} catch (err) {
|
|
2874
|
+
return fail(err instanceof Error ? err.message : String(err));
|
|
2875
|
+
}
|
|
2876
|
+
for (const message of done.warnings) console.error(formatWarning({ message }));
|
|
2877
|
+
const marked = done.marks.filter((m) => m.marked).map((m) => `#${m.pr}`);
|
|
2878
|
+
console.error(formatInfo(`pr-post --stale: ${marked.length > 0 ? `marked ${marked.join(", ")} stale` : "no note to mark"} after ${branch} moved to ${args.tip.slice(0, 12)}`));
|
|
2879
|
+
return 0;
|
|
2880
|
+
}
|
|
2881
|
+
|
|
2608
2882
|
/**
|
|
2609
2883
|
* `pr-post --open` (#4328): in a pipeline of the target branch on GitLab,
|
|
2610
2884
|
* post the plan note and status of every open merge request into it whose
|
|
@@ -2632,6 +2906,8 @@ async function runComponentsPrPostOpen(ctx: CommandContext): Promise<number> {
|
|
|
2632
2906
|
const top = spawnSync("git", ["rev-parse", "--show-toplevel"], { encoding: "utf-8" });
|
|
2633
2907
|
if (top.status !== 0) return fail("pr-post --open reads the plan report's path from the repository root, and this directory is not in a git repository");
|
|
2634
2908
|
const member = args.members?.[0];
|
|
2909
|
+
const description = await descriptionCheckOf(ctx, forge);
|
|
2910
|
+
if (typeof description === "number") return description;
|
|
2635
2911
|
const artifactDir = relative(realpathSync(top.stdout.trim()), resolve(args.output ?? PR_REPORT_DIR)).split(sep).join("/");
|
|
2636
2912
|
const { postOpenPlanReports } = await import("../../pr-post");
|
|
2637
2913
|
const { gitlabPlanJobName } = await import("../../components/pr-pipeline");
|
|
@@ -2646,6 +2922,9 @@ async function runComponentsPrPostOpen(ctx: CommandContext): Promise<number> {
|
|
|
2646
2922
|
...(member ? { member } : {}),
|
|
2647
2923
|
// #4289: the Ops at the commit this pipeline checked out, the target branch's.
|
|
2648
2924
|
overdue: () => overdueOps(forge, member),
|
|
2925
|
+
...(description ? { description } : {}),
|
|
2926
|
+
// #4628: the target branch's commit this pipeline runs at, which each note's tip line names.
|
|
2927
|
+
...(args.tip ? { baseTip: args.tip } : {}),
|
|
2649
2928
|
});
|
|
2650
2929
|
} catch (err) {
|
|
2651
2930
|
return fail(err instanceof Error ? err.message : String(err));
|
|
@@ -56,6 +56,7 @@ async function runOpWaveJobCommand(ctx: CommandContext): Promise<number> {
|
|
|
56
56
|
return 1;
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
|
+
if (specFile && args.approvalStatus) return runApprovalStatus(ctx, specFile);
|
|
59
60
|
if (specFile && args.wavesOutcome) {
|
|
60
61
|
// #4617: the outcome the control job's dispatch carries, from every wave job's outcome file.
|
|
61
62
|
try {
|
|
@@ -118,11 +119,88 @@ async function runOpWaveJobCommand(ctx: CommandContext): Promise<number> {
|
|
|
118
119
|
if (args.json) console.log(JSON.stringify(result, null, 2));
|
|
119
120
|
// #3761: tell people, when the spec says where. Delivery never changes the exit code.
|
|
120
121
|
await notifyOpWave(spec, args.wave, { result }, job);
|
|
122
|
+
// #4629: a refused wave's diff and a failed apply's triage, on the pull request or a tracking issue.
|
|
123
|
+
await respondWave(spec, args.wave, { result });
|
|
121
124
|
return result.exitCode;
|
|
122
125
|
} catch (err) {
|
|
123
126
|
const message = err instanceof Error ? err.message : String(err);
|
|
124
127
|
console.error(formatError({ message }));
|
|
125
|
-
if (spec)
|
|
128
|
+
if (spec) {
|
|
129
|
+
await notifyOpWave(spec, args.wave, { error: message }, job);
|
|
130
|
+
await respondWave(spec, args.wave, { error: message });
|
|
131
|
+
}
|
|
132
|
+
return 1;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* The wave job's responses (#4629), through the forge the job's variables
|
|
138
|
+
* name. A job with no forge token posts nothing. Never throws.
|
|
139
|
+
*/
|
|
140
|
+
async function respondWave(spec: OpWavesSpec, k: number, outcome: import("../../op/op-waves-notify").OpWaveOutcome): Promise<void> {
|
|
141
|
+
try {
|
|
142
|
+
const { respondOpWave, triageOfOpWave } = await import("../../ci-respond-run");
|
|
143
|
+
const { resolveResponses } = await import("../../ci-respond");
|
|
144
|
+
const responses = resolveResponses(spec.respond);
|
|
145
|
+
if (responses["wave-refused"] === "off" && responses["apply-failed"] === "off") return;
|
|
146
|
+
if (outcome.result && outcome.result.exitCode === 0 && !triageOfOpWave(spec, k, outcome)) return;
|
|
147
|
+
const { detectForge, forgeFromEnv } = await import("../../pr-forge");
|
|
148
|
+
const kind = detectForge();
|
|
149
|
+
if (!kind) return;
|
|
150
|
+
let forge;
|
|
151
|
+
try {
|
|
152
|
+
forge = forgeFromEnv(kind);
|
|
153
|
+
} catch {
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
const head = process.env.GITHUB_SHA ?? process.env.CI_COMMIT_SHA;
|
|
157
|
+
await respondOpWave(spec, k, outcome, { forge, ...(head ? { head } : {}) });
|
|
158
|
+
} catch (err) {
|
|
159
|
+
console.error(formatWarning({ message: `the wave's responses were not posted: ${err instanceof Error ? err.message : String(err)}` }));
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* `chant run wave --spec <file> --approval-status` (#4630): post
|
|
165
|
+
* `<product>/approval` on an open pull request's head, from its recorded
|
|
166
|
+
* plans and its reviews, or for a `pull-request` wave the pull request's
|
|
167
|
+
* own approval on the ledger. `--pr`, `--head` and `--base` name one pull
|
|
168
|
+
* request (GitHub and Forgejo); `--open` posts on every open one into
|
|
169
|
+
* `--branch` (GitLab's scheduled pipeline, or any forge by hand). It exits 0 once it posted, and
|
|
170
|
+
* 1 when it could not.
|
|
171
|
+
*/
|
|
172
|
+
async function runApprovalStatus(ctx: CommandContext, specFile: string): Promise<number> {
|
|
173
|
+
const { args } = ctx;
|
|
174
|
+
const fail = (message: string): number => {
|
|
175
|
+
console.error(formatError({ message }));
|
|
126
176
|
return 1;
|
|
177
|
+
};
|
|
178
|
+
const { FORGE_KINDS, forgeFromEnv } = await import("../../pr-forge");
|
|
179
|
+
if (!args.forge || !(FORGE_KINDS as readonly string[]).includes(args.forge)) return fail(`--approval-status posts on a forge: --forge ${FORGE_KINDS.join("|")}`);
|
|
180
|
+
let spec: OpWavesSpec;
|
|
181
|
+
let forge;
|
|
182
|
+
try {
|
|
183
|
+
spec = parseOpWavesSpec(readFileSync(resolve(specFile), "utf-8"), `--spec ${specFile}`);
|
|
184
|
+
forge = forgeFromEnv(args.forge as (typeof FORGE_KINDS)[number]);
|
|
185
|
+
} catch (err) {
|
|
186
|
+
return fail(err instanceof Error ? err.message : String(err));
|
|
187
|
+
}
|
|
188
|
+
const { postApprovalStatus, postOpenApprovalStatuses } = await import("../../op/approval-status");
|
|
189
|
+
const file = relative(process.cwd(), resolve(specFile));
|
|
190
|
+
try {
|
|
191
|
+
if (args.open) {
|
|
192
|
+
const branch = args.branch ?? process.env.CI_COMMIT_BRANCH;
|
|
193
|
+
if (!branch) return fail("--approval-status --open posts for the pull requests into a branch: run it in a branch pipeline, or pass --branch <branch>");
|
|
194
|
+
const done = await postOpenApprovalStatuses({ spec, specFile: file, forge, branch });
|
|
195
|
+
for (const w of done.warnings) console.error(formatWarning({ message: w }));
|
|
196
|
+
for (const p of done.posted) console.error(`!${p.pr}: ${p.status.state}: ${p.status.description}`);
|
|
197
|
+
return done.warnings.length > 0 && done.posted.length === 0 ? 1 : 0;
|
|
198
|
+
}
|
|
199
|
+
if (args.pr === undefined || !args.head || !args.base) return fail("--approval-status needs the pull request, its head and its base: --pr <n> --head <sha> --base <sha>, or --open");
|
|
200
|
+
const status = await postApprovalStatus({ spec, specFile: file, forge, pr: args.pr, head: args.head, base: args.base });
|
|
201
|
+
console.error(`#${args.pr}: ${status.state}: ${status.description}`);
|
|
202
|
+
return 0;
|
|
203
|
+
} catch (err) {
|
|
204
|
+
return fail(`the approval status was not posted: ${err instanceof Error ? err.message : String(err)}`);
|
|
127
205
|
}
|
|
128
206
|
}
|
package/src/cli/main.test.ts
CHANGED
|
@@ -1078,7 +1078,7 @@ describe("chant --help", () => {
|
|
|
1078
1078
|
test("lists every top-level command in the registry", () => {
|
|
1079
1079
|
const source = readFileSync(join(import.meta.dirname, "main.ts"), "utf-8");
|
|
1080
1080
|
const help = source.slice(source.indexOf("function printHelp("), source.indexOf("Options:", source.indexOf("function printHelp(")));
|
|
1081
|
-
const listed = new Set([...help.matchAll(/^ {2}([a-z][a-
|
|
1081
|
+
const listed = new Set([...help.matchAll(/^ {2}([a-z][a-z0-9-]*)\b/gm)].map((m) => m[1]));
|
|
1082
1082
|
const commands = new Set(commandRegistry.map((def) => def.name.split(" ")[0]));
|
|
1083
1083
|
expect([...commands].filter((name) => !listed.has(name))).toEqual([]);
|
|
1084
1084
|
});
|