@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/pr-loop.ts
CHANGED
|
@@ -47,7 +47,6 @@
|
|
|
47
47
|
* `identity.gates` entry covers every member.
|
|
48
48
|
*/
|
|
49
49
|
|
|
50
|
-
import { NEXT_RELEASE } from "./release-floors";
|
|
51
50
|
import type { ChangeSetAction, ChangeSetDocument, ChangeSetEntry } from "./change-set";
|
|
52
51
|
import { parsePulumiUrn, pulumiMayAppearParent } from "./pulumi-urn";
|
|
53
52
|
import type { PrRequireOutcome } from "./pr-requires";
|
|
@@ -102,10 +101,13 @@ export const PR_REPORT_NOT_STARTED_FLOOR = "0.124.54";
|
|
|
102
101
|
export const PR_REPORT_GROUPS_FLOOR = "0.124.54";
|
|
103
102
|
|
|
104
103
|
/** The first chant whose report can carry `lockTargets` (#4552). */
|
|
105
|
-
export const PR_REPORT_LOCK_TARGETS_FLOOR =
|
|
104
|
+
export const PR_REPORT_LOCK_TARGETS_FLOOR = "0.124.55";
|
|
105
|
+
|
|
106
|
+
/** The first chant whose report carries {@link PrReport.narrowed} (#4626). */
|
|
107
|
+
export const PR_REPORT_NARROWED_FLOOR = "0.124.56";
|
|
106
108
|
|
|
107
109
|
/** The first chant whose report carries {@link PrReport.crossStackEdges} (#4617). */
|
|
108
|
-
export const PR_REPORT_CROSS_STACK_FLOOR =
|
|
110
|
+
export const PR_REPORT_CROSS_STACK_FLOOR = "0.124.55";
|
|
109
111
|
|
|
110
112
|
/** The gate a pull request's apply waits on, unless the pipeline names another. */
|
|
111
113
|
export const PR_APPLY_GATE = "pr-apply";
|
|
@@ -593,6 +595,13 @@ export interface PrReport {
|
|
|
593
595
|
* {@link PR_REPORT_LOCK_TARGETS_FLOOR}.
|
|
594
596
|
*/
|
|
595
597
|
lockTargets?: string[];
|
|
598
|
+
/**
|
|
599
|
+
* Plan stage (#4626): the addresses each component's plan was narrowed to
|
|
600
|
+
* with `pr-plan --target`, from the command line or the comment, by
|
|
601
|
+
* component. The note and the status say so. Absent when nothing was
|
|
602
|
+
* narrowed. Added within contract 1 by chant {@link PR_REPORT_NARROWED_FLOOR}.
|
|
603
|
+
*/
|
|
604
|
+
narrowed?: Record<string, string[]>;
|
|
596
605
|
/**
|
|
597
606
|
* The stacks outside the workspace a member reads (#4617, a Pulumi
|
|
598
607
|
* `StackReference` no step here applies, #4547), each marked stale,
|
|
@@ -1109,6 +1118,8 @@ export function renderPrNote(report: PrReport, options: { limit?: number; approv
|
|
|
1109
1118
|
(m.groupOutcome === "partial" ? ", applied in part" : m.groupOutcome === "no-changes" ? ", no changes" : "") +
|
|
1110
1119
|
(m.inputsMoved?.length ? `, inputs from ${m.inputsMoved.join(", ")} moved` : "") +
|
|
1111
1120
|
(placeholders.length > 0 ? `, previewed with placeholders for ${placeholders.map(code).join(", ")}` : "") +
|
|
1121
|
+
// #4626: a member whose plan was narrowed says to what.
|
|
1122
|
+
(report.narrowed?.[m.component] ? `, narrowed to ${report.narrowed[m.component]!.map(code).join(", ")}` : "") +
|
|
1112
1123
|
(holes.length > 0 ? `; ${holes.length > 2 ? `${holes[0]}; and ${holes.length - 1} more, listed under Holes` : holes.join("; ")}` : "");
|
|
1113
1124
|
// A member whose plan has holes and no entries says nothing about what
|
|
1114
1125
|
// it changes, so its counts are unknown, not zero (#4084).
|
|
@@ -1120,6 +1131,7 @@ export function renderPrNote(report: PrReport, options: { limit?: number; approv
|
|
|
1120
1131
|
out.push("", `A ${noun} whose inputs moved ${words.verbs.apply[1]} the plan it was approved with. The next run plans it against the new values.`);
|
|
1121
1132
|
}
|
|
1122
1133
|
}
|
|
1134
|
+
out.push(...narrowedLines(report, words));
|
|
1123
1135
|
out.push(...mayAppearLines(report, options.applyWord ?? words.stages.apply));
|
|
1124
1136
|
const blocked = blockedLine(report.members);
|
|
1125
1137
|
if (blocked) out.push("", blocked);
|
|
@@ -1220,6 +1232,18 @@ function memberDetailSections(report: PrReport, room: number, noun: string): str
|
|
|
1220
1232
|
return out.length > 0 ? out.join("\n") + "\n" : "";
|
|
1221
1233
|
}
|
|
1222
1234
|
|
|
1235
|
+
/**
|
|
1236
|
+
* The note's line for a narrowed plan (#4626): which of the plan's
|
|
1237
|
+
* components were narrowed and to how many addresses, and that the plan on
|
|
1238
|
+
* merge is of each whole, in the product's words.
|
|
1239
|
+
*/
|
|
1240
|
+
function narrowedLines(report: PrReport, words: CiProductWords): string[] {
|
|
1241
|
+
const narrowed = Object.entries(report.narrowed ?? {}).filter(([, a]) => a.length > 0);
|
|
1242
|
+
if (narrowed.length === 0) return [];
|
|
1243
|
+
const each = narrowed.map(([c, a]) => `${code(c)} to ${a.map(code).join(", ")}`).join("; ");
|
|
1244
|
+
return ["", `This ${words.verbs.plan[0]} was narrowed with \`--target\`: ${each}. The approval binds the narrowed plan. On merge each ${words.noun[0]} is ${words.verbs.plan[1]} whole.`];
|
|
1245
|
+
}
|
|
1246
|
+
|
|
1223
1247
|
/** A commit status's description, at most 140 characters (GitHub's limit). */
|
|
1224
1248
|
export function prStatusDescription(report: PrReport, words: CiProductWords = activeProductWords()): string {
|
|
1225
1249
|
const n = report.members.length;
|
|
@@ -1236,7 +1260,9 @@ export function prStatusDescription(report: PrReport, words: CiProductWords = ac
|
|
|
1236
1260
|
break;
|
|
1237
1261
|
case "planned": {
|
|
1238
1262
|
const unknown = report.members.filter((m) => memberHoleReasons(report, m.member).length > 0).length;
|
|
1239
|
-
|
|
1263
|
+
// #4626: a narrowed plan says so in its status.
|
|
1264
|
+
const narrowed = Object.values(report.narrowed ?? {}).filter((a) => a.length > 0).length;
|
|
1265
|
+
text = `${many(n)}${narrowed > 0 ? ` (${narrowed} narrowed with --target)` : ""}: ${sum.change} to change, ${sum.destroy} to destroy or replace${unknown > 0 ? `, ${unknown} with holes` : ""}${digest}`;
|
|
1240
1266
|
break;
|
|
1241
1267
|
}
|
|
1242
1268
|
case "plan-failed":
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* #4636: `pr-apply --before-merge --merge auto` merges the pull request once
|
|
3
|
+
* its update applied and the records are pushed, with the head checked
|
|
4
|
+
* again, on fake GitHub, GitLab and Forgejo forges. A refusal is posted and
|
|
5
|
+
* never applies again.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { describe, expect, test } from "vitest";
|
|
9
|
+
import { parseArgs } from "./cli/parse-args";
|
|
10
|
+
import { prLoopJobs } from "./components/pr-pipeline";
|
|
11
|
+
import { ciLoopOptions } from "./workspace/ci-run";
|
|
12
|
+
import { mergeAfterApply, mergeTokenEnv, prMergeMarker } from "./pr-merge";
|
|
13
|
+
import type { MergeOptions, MergeResult, PullRequestHead } from "./pr-forge";
|
|
14
|
+
|
|
15
|
+
const HEAD = "a".repeat(40);
|
|
16
|
+
|
|
17
|
+
function fakeForge(kind: "github" | "gitlab" | "forgejo", o: { head?: PullRequestHead; merge?: MergeResult | Error } = {}) {
|
|
18
|
+
const merges: Array<{ pr: number; opts: MergeOptions }> = [];
|
|
19
|
+
const comments: Array<{ pr: number; marker: string; body: string }> = [];
|
|
20
|
+
const forge = {
|
|
21
|
+
kind,
|
|
22
|
+
async pullRequestHead() {
|
|
23
|
+
return o.head ?? { sha: HEAD, branch: "feature", open: true, sameRepo: true };
|
|
24
|
+
},
|
|
25
|
+
async mergePullRequest(pr: number, opts: MergeOptions) {
|
|
26
|
+
merges.push({ pr, opts });
|
|
27
|
+
if (o.merge instanceof Error) throw o.merge;
|
|
28
|
+
return o.merge ?? { merged: true, sha: "b".repeat(40) };
|
|
29
|
+
},
|
|
30
|
+
async upsertComment(pr: number, marker: string, body: string) {
|
|
31
|
+
comments.push({ pr, marker, body });
|
|
32
|
+
return { action: "created" as const, id: 1 };
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
return { forge, merges, comments };
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const pushed = { pushed: true };
|
|
39
|
+
|
|
40
|
+
describe("the merge after an update before merge (#4636)", () => {
|
|
41
|
+
for (const kind of ["github", "gitlab", "forgejo"] as const) {
|
|
42
|
+
test(`merges only the head that applied, once the records are pushed (${kind})`, async () => {
|
|
43
|
+
const { forge, merges, comments } = fakeForge(kind);
|
|
44
|
+
expect(await mergeAfterApply({ forge, pr: 7, head: HEAD, method: "squash", recorded: pushed })).toEqual({ merged: true, sha: "b".repeat(40) });
|
|
45
|
+
expect(merges).toEqual([{ pr: 7, opts: { sha: HEAD, method: "squash" } }]);
|
|
46
|
+
expect(comments).toEqual([]);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
test(`a refused merge posts the reason and is never retried (${kind})`, async () => {
|
|
50
|
+
const { forge, merges, comments } = fakeForge(kind, { merge: { merged: false, reason: 'Required status check "ci" is expected' } });
|
|
51
|
+
const r = await mergeAfterApply({ forge, pr: 7, head: HEAD, recorded: pushed });
|
|
52
|
+
expect(r).toMatchObject({ merged: false, posted: true, reason: expect.stringContaining("Required status check") });
|
|
53
|
+
expect(merges).toHaveLength(1);
|
|
54
|
+
expect(comments[0]).toMatchObject({ pr: 7, marker: prMergeMarker(7) });
|
|
55
|
+
expect(comments[0]!.body).toContain("stays applied and recorded; it is never applied again to merge");
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
test("a new push since the apply, a closed pull request, or records that did not land stop the merge before it is asked", async () => {
|
|
60
|
+
const moved = fakeForge("github", { head: { sha: "c".repeat(40), branch: "feature", open: true, sameRepo: true } });
|
|
61
|
+
expect(await mergeAfterApply({ forge: moved.forge, pr: 7, head: HEAD, recorded: pushed })).toMatchObject({ merged: false, reason: expect.stringContaining("not aaaaaaaaaaaa, the commit that applied") });
|
|
62
|
+
expect(moved.merges).toEqual([]);
|
|
63
|
+
const closed = fakeForge("forgejo", { head: { sha: HEAD, branch: "feature", open: false, sameRepo: true } });
|
|
64
|
+
expect((await mergeAfterApply({ forge: closed.forge, pr: 7, head: HEAD, recorded: pushed })).reason).toBe("it is no longer open");
|
|
65
|
+
const unpushed = fakeForge("gitlab");
|
|
66
|
+
const r = await mergeAfterApply({ forge: unpushed.forge, pr: 7, head: HEAD, recorded: { pushed: false, warning: "chant/lifecycle has no remote" } });
|
|
67
|
+
expect(r.reason).toContain("records are not on the ledger's remote (chant/lifecycle has no remote)");
|
|
68
|
+
expect(unpushed.merges).toEqual([]);
|
|
69
|
+
expect(unpushed.comments[0]!.body).toContain("Merge request !7 was not merged");
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
test("a forge error is a refusal, posted", async () => {
|
|
73
|
+
const { forge, comments } = fakeForge("github", { merge: new Error("500 Internal Server Error") });
|
|
74
|
+
expect(await mergeAfterApply({ forge, pr: 7, head: HEAD, recorded: pushed })).toMatchObject({ merged: false, posted: true });
|
|
75
|
+
expect(comments).toHaveLength(1);
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
test("the merge client holds the named token and no other", () => {
|
|
79
|
+
const env = mergeTokenEnv("PLYWOOD_MERGE_TOKEN", { GITHUB_TOKEN: "job", CHANT_FORGE_TOKEN: "plan", PLYWOOD_MERGE_TOKEN: "merge", GITHUB_REPOSITORY: "acme/infra" });
|
|
80
|
+
expect(env).toEqual({ CHANT_FORGE_TOKEN: "merge", PLYWOOD_MERGE_TOKEN: "merge", GITHUB_REPOSITORY: "acme/infra" });
|
|
81
|
+
expect(mergeTokenEnv("PLYWOOD_MERGE_TOKEN", {})).toEqual({ error: expect.stringContaining("not set") });
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
describe("the pipeline carries --merge auto (#4636)", () => {
|
|
86
|
+
test("the apply before merge job runs with the merge flags and maps the secret on GitHub", () => {
|
|
87
|
+
const [, apply] = prLoopJobs("github", "prod", { applyBeforeMerge: true, applyMerge: { tokenEnv: "PLYWOOD_MERGE_TOKEN", method: "squash" } });
|
|
88
|
+
expect(apply!.command).toContain("pr-apply --before-merge --merge auto --merge-token-env PLYWOOD_MERGE_TOKEN --merge-method squash");
|
|
89
|
+
expect(apply!.run.command).toContain("--apply-before-merge --merge auto --merge-token-env PLYWOOD_MERGE_TOKEN --merge-method squash");
|
|
90
|
+
expect(apply!.env.PLYWOOD_MERGE_TOKEN).toBe("${{ secrets.PLYWOOD_MERGE_TOKEN }}");
|
|
91
|
+
const [, gitlab] = prLoopJobs("gitlab", "prod", { applyBeforeMerge: true, applyMerge: { tokenEnv: "PLYWOOD_MERGE_TOKEN" } });
|
|
92
|
+
expect(gitlab!.env.PLYWOOD_MERGE_TOKEN).toBeUndefined();
|
|
93
|
+
expect(() => prLoopJobs("github", "prod", { applyMerge: { tokenEnv: "X" } })).toThrow(/apply-before-merge/);
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
test("chant ci run apply passes the flags on to pr-apply", () => {
|
|
97
|
+
const args = parseArgs(["ci", "run", "apply", "--apply-before-merge", "--merge", "auto", "--merge-token-env", "PLYWOOD_MERGE_TOKEN"]);
|
|
98
|
+
expect(ciLoopOptions(args).applyMerge).toEqual({ tokenEnv: "PLYWOOD_MERGE_TOKEN" });
|
|
99
|
+
});
|
|
100
|
+
});
|
package/src/pr-merge.ts
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Auto merge after an update before merge (#4636): `pr-apply --before-merge
|
|
3
|
+
* --merge auto --merge-token-env <VAR>` merges the pull request once every
|
|
4
|
+
* member applied and the apply's records are on the ledger's remote.
|
|
5
|
+
*
|
|
6
|
+
* The merge is a second step after the apply, and never a reason to apply
|
|
7
|
+
* again:
|
|
8
|
+
*
|
|
9
|
+
* - The records come first. The apply's release records and gate facts are
|
|
10
|
+
* pushed to `chant/lifecycle`; a push that did not land leaves the pull
|
|
11
|
+
* request open with the reason posted.
|
|
12
|
+
* - The head is checked again. The pull request must still be open at the
|
|
13
|
+
* commit that applied, and the forge's merge is asked to merge only that
|
|
14
|
+
* commit, so a push after the apply is never merged unapplied.
|
|
15
|
+
* - A refusal (branch protection, a new push, a conflict, a closed pull
|
|
16
|
+
* request) is posted on the pull request in one comment the next attempt
|
|
17
|
+
* edits, and the apply stays as it was recorded.
|
|
18
|
+
* - The merge's forge client holds the token `--merge-token-env` names and
|
|
19
|
+
* no other: never the plan job's token, nor the apply job's own. On GitLab
|
|
20
|
+
* the variable is a protected one.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
import { activeProductWords, type CiProductWords } from "./ci-product-words";
|
|
24
|
+
import type { MergeOptions, PrForge } from "./pr-forge";
|
|
25
|
+
|
|
26
|
+
/** How a pull request applied before merge gets merged. */
|
|
27
|
+
export type PrApplyMerge = "manual" | "auto";
|
|
28
|
+
|
|
29
|
+
export const PR_APPLY_MERGES: readonly PrApplyMerge[] = ["manual", "auto"];
|
|
30
|
+
|
|
31
|
+
export type PrMergeMethod = NonNullable<MergeOptions["method"]>;
|
|
32
|
+
|
|
33
|
+
export const PR_MERGE_METHODS: readonly PrMergeMethod[] = ["merge", "squash", "rebase"];
|
|
34
|
+
|
|
35
|
+
/** The marker of the comment a refused merge posts. */
|
|
36
|
+
export function prMergeMarker(pr: number): string {
|
|
37
|
+
return `<!-- chant:merge:${pr} -->`;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** What {@link mergeAfterApply} did. */
|
|
41
|
+
export interface MergeAfterApply {
|
|
42
|
+
merged: boolean;
|
|
43
|
+
/** The merge commit, when the forge says. */
|
|
44
|
+
sha?: string;
|
|
45
|
+
/** Why it was not merged. */
|
|
46
|
+
reason?: string;
|
|
47
|
+
/** The refusal was posted on the pull request. */
|
|
48
|
+
posted?: boolean;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export interface MergeAfterApplyInput {
|
|
52
|
+
/** The client built from the merge token alone. */
|
|
53
|
+
forge: Pick<PrForge, "kind" | "mergePullRequest" | "pullRequestHead" | "upsertComment">;
|
|
54
|
+
pr: number;
|
|
55
|
+
/** The commit that applied. */
|
|
56
|
+
head: string;
|
|
57
|
+
method?: PrMergeMethod;
|
|
58
|
+
/** Whether the apply's records reached the ledger's remote, and why not. */
|
|
59
|
+
recorded: { pushed: boolean; warning?: string };
|
|
60
|
+
words?: CiProductWords;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const short = (sha: string): string => sha.slice(0, 12);
|
|
64
|
+
|
|
65
|
+
/** Merge the pull request after its update applied. Never throws; a refusal is posted and returned. */
|
|
66
|
+
export async function mergeAfterApply(i: MergeAfterApplyInput): Promise<MergeAfterApply> {
|
|
67
|
+
const words = i.words ?? activeProductWords();
|
|
68
|
+
const what = i.forge.kind === "gitlab" ? `Merge request !${i.pr}` : `Pull request ${i.pr}`;
|
|
69
|
+
const refuse = async (reason: string): Promise<MergeAfterApply> => {
|
|
70
|
+
const body = `${prMergeMarker(i.pr)}\n${what} was not merged: ${reason}. The ${words.verbs.apply[0]} of ${short(i.head)} stays applied and recorded; it is never applied again to merge. Merge it by hand once the reason is gone, or ${words.verbs.apply[0]} again after a new push.\n`;
|
|
71
|
+
try {
|
|
72
|
+
await i.forge.upsertComment(i.pr, prMergeMarker(i.pr), body);
|
|
73
|
+
return { merged: false, reason, posted: true };
|
|
74
|
+
} catch {
|
|
75
|
+
return { merged: false, reason, posted: false };
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
if (!i.recorded.pushed) return refuse(`the ${words.verbs.apply[0]}'s records are not on the ledger's remote${i.recorded.warning ? ` (${i.recorded.warning})` : ""}`);
|
|
79
|
+
try {
|
|
80
|
+
if (i.forge.pullRequestHead) {
|
|
81
|
+
const now = await i.forge.pullRequestHead(i.pr);
|
|
82
|
+
if (!now) return refuse("the forge could not say its head");
|
|
83
|
+
if (!now.open) return refuse("it is no longer open");
|
|
84
|
+
if (now.sha !== i.head) return refuse(`its head is ${short(now.sha)} now, not ${short(i.head)}, the commit that applied`);
|
|
85
|
+
}
|
|
86
|
+
const merged = await i.forge.mergePullRequest(i.pr, { sha: i.head, ...(i.method ? { method: i.method } : {}) });
|
|
87
|
+
if (!merged.merged) return refuse(merged.reason ?? "the forge refused the merge");
|
|
88
|
+
return { merged: true, ...(merged.sha ? { sha: merged.sha } : {}) };
|
|
89
|
+
} catch (err) {
|
|
90
|
+
return refuse(`the forge answered ${err instanceof Error ? err.message : String(err)}`);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* The environment a merge client reads its token from: the job's, with the
|
|
96
|
+
* named variable as the only token and every other forge token left out.
|
|
97
|
+
*/
|
|
98
|
+
export function mergeTokenEnv(tokenEnv: string, env: Record<string, string | undefined> = process.env): Record<string, string | undefined> | { error: string } {
|
|
99
|
+
const token = env[tokenEnv]?.trim();
|
|
100
|
+
if (!token) return { error: `--merge-token-env names ${tokenEnv}, which is not set in this job` };
|
|
101
|
+
const out: Record<string, string | undefined> = { ...env };
|
|
102
|
+
for (const name of ["CHANT_FORGE_TOKEN", "GITHUB_TOKEN", "GH_TOKEN", "GITLAB_TOKEN", "CI_JOB_TOKEN", "FORGEJO_TOKEN", "CHANT_GITHUB_TOKEN", "CHANT_GITLAB_TOKEN", "CHANT_FORGEJO_TOKEN"]) delete out[name];
|
|
103
|
+
out.CHANT_FORGE_TOKEN = token;
|
|
104
|
+
return out;
|
|
105
|
+
}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The job summary and stale marking (#4628), with fake forges: the note job
|
|
3
|
+
* adds the note to GITHUB_STEP_SUMMARY without its hidden lines, the note
|
|
4
|
+
* carries the target branch's commit it was posted against, and after a
|
|
5
|
+
* push `markStaleNotes` marks each open pull request's note posted against
|
|
6
|
+
* another commit stale, names the comment that previews again and sets the
|
|
7
|
+
* plan status back to pending, on GitHub, GitLab and Forgejo. Written for
|
|
8
|
+
* the ci-products post-merge pass.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
12
|
+
import { tmpdir } from "node:os";
|
|
13
|
+
import { join } from "node:path";
|
|
14
|
+
import { afterAll, describe, expect, test } from "vitest";
|
|
15
|
+
import { markStaleNotes, planNoteSummary, postPlanReport, prNoteStaleMarker, prNoteTipMarker } from "./pr-post";
|
|
16
|
+
import { prNoteMarker, type PrReport } from "./pr-loop";
|
|
17
|
+
import { assertProductWords } from "./ci-product-words";
|
|
18
|
+
import { PLYWOOD } from "./__fixtures__/product-words";
|
|
19
|
+
import type { ForgeKind, ForgeStatus, OpenPullRequest, PrForge } from "./pr-forge";
|
|
20
|
+
|
|
21
|
+
const REPORT = JSON.parse(readFileSync(join(import.meta.dirname, "__fixtures__", "pr-loop", "pr-plan.golden.json"), "utf-8")) as PrReport;
|
|
22
|
+
const OLD = "a".repeat(40);
|
|
23
|
+
const NEW = "b".repeat(40);
|
|
24
|
+
const dirs: string[] = [];
|
|
25
|
+
afterAll(() => {
|
|
26
|
+
for (const d of dirs) rmSync(d, { recursive: true, force: true });
|
|
27
|
+
});
|
|
28
|
+
const scratch = (): string => {
|
|
29
|
+
const d = mkdtempSync(join(tmpdir(), "chant-pr-stale-"));
|
|
30
|
+
dirs.push(d);
|
|
31
|
+
return d;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
/** A forge that keeps notes by marker, lists open pull requests and records statuses. */
|
|
35
|
+
function fakeForge(kind: ForgeKind, open: OpenPullRequest[] = []) {
|
|
36
|
+
const notes = new Map<string, string>();
|
|
37
|
+
const statuses: Array<{ sha: string; status: ForgeStatus }> = [];
|
|
38
|
+
const key = (pr: number, marker: string) => `${pr}\u0000${marker}`;
|
|
39
|
+
const forge = {
|
|
40
|
+
kind,
|
|
41
|
+
host: kind === "gitlab" ? "gitlab.com" : kind === "forgejo" ? "codeberg.org" : "github.com",
|
|
42
|
+
async setStatus(sha: string, status: ForgeStatus) {
|
|
43
|
+
statuses.push({ sha, status });
|
|
44
|
+
},
|
|
45
|
+
async upsertNote(pr: number, marker: string, body: string) {
|
|
46
|
+
notes.set(key(pr, marker), body);
|
|
47
|
+
return "1";
|
|
48
|
+
},
|
|
49
|
+
async findComment(pr: number, marker: string) {
|
|
50
|
+
const body = notes.get(key(pr, marker));
|
|
51
|
+
return body === undefined ? undefined : { id: 1, body };
|
|
52
|
+
},
|
|
53
|
+
async openPullRequests(base: string) {
|
|
54
|
+
return open.filter((p) => p.base === base);
|
|
55
|
+
},
|
|
56
|
+
} as unknown as PrForge;
|
|
57
|
+
return { forge, notes, statuses, key };
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const pr = (number: number, headSha = "c".repeat(40)): OpenPullRequest => ({ number, head: `feature-${number}`, headSha, base: "main", fork: false });
|
|
61
|
+
|
|
62
|
+
describe("the job summary (#4628)", () => {
|
|
63
|
+
test("the note job adds the note, without its hidden lines, to the summary file", async () => {
|
|
64
|
+
const dir = scratch();
|
|
65
|
+
writeFileSync(join(dir, "pr-plan.json"), JSON.stringify(REPORT));
|
|
66
|
+
const summary = join(dir, "summary.md");
|
|
67
|
+
writeFileSync(summary, "earlier\n");
|
|
68
|
+
const { forge } = fakeForge("github");
|
|
69
|
+
const r = await postPlanReport({ forge, dir, pr: REPORT.pr!, head: REPORT.head, env: REPORT.env, baseTip: OLD, summaryFile: summary });
|
|
70
|
+
expect(r.warnings).toEqual([]);
|
|
71
|
+
const text = readFileSync(summary, "utf-8");
|
|
72
|
+
expect(text.startsWith("earlier\n")).toBe(true);
|
|
73
|
+
expect(text).toContain("### chant plan for `prod`");
|
|
74
|
+
expect(text).not.toContain("<!-- chant-pr");
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
test("planNoteSummary drops the marker, tip and stale lines", () => {
|
|
78
|
+
expect(planNoteSummary([prNoteMarker("prod"), "### heading", prNoteTipMarker(OLD), prNoteStaleMarker(NEW)].join("\n"))).toBe("### heading");
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
describe("the tip line (#4628)", () => {
|
|
83
|
+
test("the note carries the target branch's commit it was posted against, after the defusing", async () => {
|
|
84
|
+
const dir = scratch();
|
|
85
|
+
writeFileSync(join(dir, "pr-plan.json"), JSON.stringify({ ...REPORT, message: `x ${prNoteTipMarker(NEW)}` }));
|
|
86
|
+
const { forge, notes, key } = fakeForge("github");
|
|
87
|
+
await postPlanReport({ forge, dir, pr: REPORT.pr!, head: REPORT.head, env: REPORT.env, baseTip: OLD });
|
|
88
|
+
const body = notes.get(key(REPORT.pr!, prNoteMarker(REPORT.env)))!;
|
|
89
|
+
expect(body).toContain(prNoteTipMarker(OLD));
|
|
90
|
+
// The report's own copy is defused, so a change cannot name another tip.
|
|
91
|
+
expect(body).not.toContain(prNoteTipMarker(NEW));
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
test("no tip, no line", async () => {
|
|
95
|
+
const dir = scratch();
|
|
96
|
+
writeFileSync(join(dir, "pr-plan.json"), JSON.stringify(REPORT));
|
|
97
|
+
const { forge, notes, key } = fakeForge("github");
|
|
98
|
+
await postPlanReport({ forge, dir, pr: REPORT.pr!, head: REPORT.head, env: REPORT.env });
|
|
99
|
+
expect(notes.get(key(REPORT.pr!, prNoteMarker(REPORT.env)))).not.toContain("chant-pr-tip");
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
describe("markStaleNotes (#4628)", () => {
|
|
104
|
+
const marker = prNoteMarker("prod");
|
|
105
|
+
const noteAt = (tip: string) => [marker, "### plywood preview for `prod`", "", "body", prNoteTipMarker(tip), ""].join("\n");
|
|
106
|
+
|
|
107
|
+
for (const kind of ["github", "gitlab", "forgejo"] as const) {
|
|
108
|
+
test(`${kind}: a note posted against another commit is marked stale and its status goes back to pending`, async () => {
|
|
109
|
+
const { forge, notes, statuses, key } = fakeForge(kind, [pr(7, "d".repeat(40))]);
|
|
110
|
+
notes.set(key(7, marker), noteAt(OLD));
|
|
111
|
+
const words = assertProductWords(PLYWOOD);
|
|
112
|
+
const done = await markStaleNotes({ forge, branch: "main", tip: NEW, env: "prod", previewComment: true, words });
|
|
113
|
+
expect(done).toEqual({ marks: [{ pr: 7, marked: true }], warnings: [] });
|
|
114
|
+
const body = notes.get(key(7, marker))!;
|
|
115
|
+
const lines = body.split("\n");
|
|
116
|
+
expect(lines[0]).toBe(marker);
|
|
117
|
+
expect(lines[1]).toBe(`> Stale: main moved to \`${NEW.slice(0, 12)}\` since this preview was posted against \`${OLD.slice(0, 12)}\`, so it may no longer show what the merge does; comment \`/plywood preview\` to preview again.`);
|
|
118
|
+
expect(lines[2]).toBe(prNoteStaleMarker(NEW));
|
|
119
|
+
expect(body).toContain("body");
|
|
120
|
+
expect(statuses).toEqual([{ sha: "d".repeat(40), status: expect.objectContaining({ context: "plywood/preview", state: "pending" }) }]);
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
test("without the preview comment the line asks for a push", async () => {
|
|
125
|
+
const { forge, notes, key } = fakeForge("github", [pr(7)]);
|
|
126
|
+
notes.set(key(7, marker), noteAt(OLD));
|
|
127
|
+
await markStaleNotes({ forge, branch: "main", tip: NEW, env: "prod" });
|
|
128
|
+
expect(notes.get(key(7, marker))).toContain("push a commit to plan again");
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
test("a current note, one already marked, one with no tip line and a pull request with no note are left alone", async () => {
|
|
132
|
+
const { forge, notes, statuses, key } = fakeForge("github", [pr(1), pr(2), pr(3), pr(4)]);
|
|
133
|
+
notes.set(key(1, marker), noteAt(NEW));
|
|
134
|
+
notes.set(key(2, marker), [marker, "> Stale: x", prNoteStaleMarker(NEW), "", "body", prNoteTipMarker(OLD)].join("\n"));
|
|
135
|
+
notes.set(key(3, marker), [marker, "an old note"].join("\n"));
|
|
136
|
+
const done = await markStaleNotes({ forge, branch: "main", tip: NEW, env: "prod" });
|
|
137
|
+
expect(done.marks).toEqual([
|
|
138
|
+
{ pr: 1, skipped: "the note is current" },
|
|
139
|
+
{ pr: 2, skipped: "already marked" },
|
|
140
|
+
{ pr: 3, skipped: "the note names no target branch commit" },
|
|
141
|
+
{ pr: 4, skipped: "no note" },
|
|
142
|
+
]);
|
|
143
|
+
expect(statuses).toEqual([]);
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
test("marking again after another push replaces the stale line", async () => {
|
|
147
|
+
const third = "e".repeat(40);
|
|
148
|
+
const { forge, notes, key } = fakeForge("github", [pr(7)]);
|
|
149
|
+
notes.set(key(7, marker), noteAt(OLD));
|
|
150
|
+
await markStaleNotes({ forge, branch: "main", tip: NEW, env: "prod" });
|
|
151
|
+
await markStaleNotes({ forge, branch: "main", tip: third, env: "prod" });
|
|
152
|
+
const body = notes.get(key(7, marker))!;
|
|
153
|
+
expect(body.split("\n").filter((l) => l.startsWith("> Stale: "))).toHaveLength(1);
|
|
154
|
+
expect(body).toContain(prNoteStaleMarker(third));
|
|
155
|
+
expect(body).not.toContain(prNoteStaleMarker(NEW));
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
test("a forge that cannot list open pull requests is refused", async () => {
|
|
159
|
+
const { forge } = fakeForge("github");
|
|
160
|
+
delete (forge as { openPullRequests?: unknown }).openPullRequests;
|
|
161
|
+
await expect(markStaleNotes({ forge, branch: "main", tip: NEW, env: "prod" })).rejects.toThrow(/lists the open pull requests/);
|
|
162
|
+
});
|
|
163
|
+
});
|