@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
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@intentius/chant/e2e-harness` (chant#4587): the one e2e harness that
|
|
3
|
+
* terragucci, plywood and sql-yodeler run their scenarios on, and that the
|
|
4
|
+
* engines' claims cite (chant#4586 rulings B and D).
|
|
5
|
+
*
|
|
6
|
+
* - the stack: ./stack.ts's compose services and ./project/, the chant
|
|
7
|
+
* docker-lexicon project that wraps them, with every image in ./pins.ts
|
|
8
|
+
* - the driver: ./driver.ts over ./ports.ts, with the real Forgejo
|
|
9
|
+
* (./forgejo.ts), floci's S3 (./bucket.ts) and the runner's jobs (./jobs.ts)
|
|
10
|
+
* - the scenario format and its lint: ./scenario.ts, e2e-scenario/v1
|
|
11
|
+
* - the claim row protocol: ./claim.ts, e2e-claim-row/v1 as an e2e-claim
|
|
12
|
+
* run record on the ledger, rendered as e2e-claims/v1
|
|
13
|
+
* - the no-real-cloud wrapper: ./safe-run.ts
|
|
14
|
+
*
|
|
15
|
+
* A product on a published chant without this subpath feature-detects:
|
|
16
|
+
* import it lazily, and use it when `E2E_HARNESS_FLOOR` is there.
|
|
17
|
+
*/
|
|
18
|
+
import { existsSync } from "node:fs";
|
|
19
|
+
import { join } from "node:path";
|
|
20
|
+
|
|
21
|
+
/** The first chant with the e2e harness. */
|
|
22
|
+
export const E2E_HARNESS_FLOOR = "0.124.56";
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* The harness's chant docker-lexicon project, to `chant build <dir>/src
|
|
26
|
+
* --lexicon docker`. It ships as source in the package's src/.
|
|
27
|
+
*/
|
|
28
|
+
export function harnessProjectDir(): string {
|
|
29
|
+
const here = import.meta.dirname;
|
|
30
|
+
const candidates = [join(here, "__project__"), join(here, "..", "..", "src", "e2e-harness", "__project__")];
|
|
31
|
+
const found = candidates.find((d) => existsSync(join(d, "src", "compose.ts")));
|
|
32
|
+
if (!found) throw new Error(`the e2e harness's compose project is not next to ${here}`);
|
|
33
|
+
return found;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export * from "./pins";
|
|
37
|
+
export * from "./stack";
|
|
38
|
+
export * from "./ports";
|
|
39
|
+
export * from "./git";
|
|
40
|
+
export * from "./forgejo";
|
|
41
|
+
export * from "./bucket";
|
|
42
|
+
export * from "./jobs";
|
|
43
|
+
export * from "./reports";
|
|
44
|
+
export * from "./steps";
|
|
45
|
+
export * from "./scenario";
|
|
46
|
+
export * from "./driver";
|
|
47
|
+
export * from "./claim";
|
|
48
|
+
export * from "./safe-run";
|
|
49
|
+
export * from "./schemas/index";
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The kill-job step, for real (chant#4587): forgejo-runner's docker
|
|
3
|
+
* executor runs each job in a container on the project network, named
|
|
4
|
+
* `FORGEJO-ACTIONS-TASK-<id>_WORKFLOW-<name>_JOB-<name>`. Killing the newest
|
|
5
|
+
* one that matches is a job dying mid-run, the way a runner host does.
|
|
6
|
+
*/
|
|
7
|
+
import { run } from "./git";
|
|
8
|
+
import type { Jobs } from "./ports";
|
|
9
|
+
|
|
10
|
+
/** forgejo-runner's job containers carry this in their names. */
|
|
11
|
+
export const JOB_CONTAINER_MARK = "ACTIONS-TASK";
|
|
12
|
+
|
|
13
|
+
/** Pick the container to kill from `docker ps` lines (`<created>\t<name>`), newest first by docker's order. */
|
|
14
|
+
export function pickJobContainer(psLines: string[], match?: string): string | null {
|
|
15
|
+
for (const line of psLines) {
|
|
16
|
+
const name = line.split("\t").pop()?.trim() ?? "";
|
|
17
|
+
if (!name.includes(JOB_CONTAINER_MARK)) continue;
|
|
18
|
+
if (match && !name.includes(match)) continue;
|
|
19
|
+
return name;
|
|
20
|
+
}
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** Jobs on `network`, through the host's docker. */
|
|
25
|
+
export function dockerJobs(network: string): Jobs {
|
|
26
|
+
return {
|
|
27
|
+
async kill(match) {
|
|
28
|
+
const ps = await run("docker", ["ps", "--filter", `network=${network}`, "--format", "{{.CreatedAt}}\t{{.Names}}"]);
|
|
29
|
+
const name = pickJobContainer(ps.stdout.split("\n").filter(Boolean), match);
|
|
30
|
+
if (!name) return false;
|
|
31
|
+
await run("docker", ["kill", name]);
|
|
32
|
+
return true;
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The images the e2e harness runs (chant#4587), in the one file every
|
|
3
|
+
* harness compose reads. A product's compose project gets its images from
|
|
4
|
+
* here through `harnessStack` (./stack.ts), never by naming a digest itself,
|
|
5
|
+
* so a pin moves for every bench at once.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/** The floci build the harness pins, by its index digest (linux/amd64 and linux/arm64). */
|
|
9
|
+
export const FLOCI_DIGEST = "sha256:5ec92ae8046445d62c0009590dd09f04560886e5a5ef31248cb3fcc09b2961ec";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* floci from the lex00/floci fork at {@link FLOCI_DIGEST}: the build
|
|
13
|
+
* choudoufu pins in live/floci-image and plunge in
|
|
14
|
+
* tests/plunge-corpus/emulator-images, which serves Cloud Control
|
|
15
|
+
* ListResources for the types choudoufu's discovery and plunge's sweep read.
|
|
16
|
+
*
|
|
17
|
+
* The epic named 63d8f1ed (chant#4586 ruling D). On 2026-10-27 the
|
|
18
|
+
* maintainer ruled to hold this pin at 5ec92ae8 and file upstream instead,
|
|
19
|
+
* because 63d8f1ed answers ListResources with UnsupportedActionException for
|
|
20
|
+
* 619 of 628 Cloud Control types. lex00/floci#265 asks for one image with
|
|
21
|
+
* both lines' fixes; the pin moves when that image exists.
|
|
22
|
+
*/
|
|
23
|
+
export const FLOCI_IMAGE = `ghcr.io/lex00/floci@${FLOCI_DIGEST}`;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* The other floci line, 63d8f1ed (ghcr.io/lex00/floci:b491869, branch
|
|
27
|
+
* fix/cfn-change-set-changes): it describes a CloudFormation change set's
|
|
28
|
+
* changes, which chant's plan counts read, and keeps SNS tags and IAM
|
|
29
|
+
* permission boundaries. The fan-out demo plans CloudFormation stacks and
|
|
30
|
+
* needs that, so it names this line until lex00/floci#265's image carries
|
|
31
|
+
* both. No claim row is recorded on it: rows name {@link FLOCI_DIGEST}.
|
|
32
|
+
*/
|
|
33
|
+
export const FLOCI_CHANGE_SET_DIGEST = "sha256:63d8f1ed5ef595d7356c6f76318f3d76bc31ce3250cdf2dd8d14bd4d59604b8d";
|
|
34
|
+
export const FLOCI_CHANGE_SET_IMAGE = `ghcr.io/lex00/floci@${FLOCI_CHANGE_SET_DIGEST}`;
|
|
35
|
+
|
|
36
|
+
/** Forgejo, as terragucci's stack and the fan-out demo run it. */
|
|
37
|
+
export const FORGEJO_IMAGE = "codeberg.org/forgejo/forgejo:16.0.5";
|
|
38
|
+
|
|
39
|
+
/** forgejo-runner, with the docker executor (terragucci stack/docker-compose.yml). */
|
|
40
|
+
export const FORGEJO_RUNNER_IMAGE = "data.forgejo.org/forgejo/runner:13.2.0";
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* The sql emulator's servers, the ones `chant emulator up sql` starts. The
|
|
44
|
+
* sql lexicon owns these pins (lexicons/sql/src/spec/pin.ts and
|
|
45
|
+
* postgres-pin.ts); stack.test.ts fails when the two disagree.
|
|
46
|
+
*/
|
|
47
|
+
export const CLICKHOUSE_IMAGE =
|
|
48
|
+
"clickhouse/clickhouse-server:26.8.15.10@sha256:9716a352d25f538bd19d868b001141e7a60e4d035bc9b823658c6a071660aa61";
|
|
49
|
+
export const POSTGRES_IMAGE = "postgres:18.6@sha256:5a5a84b19854a9ffaa54082c166ff4ec27473a361e496e5ea167f298f2da9722";
|
|
50
|
+
|
|
51
|
+
/** The Postgres emulator's password, as `chant emulator` sets it. */
|
|
52
|
+
export const POSTGRES_PASSWORD = "chant";
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the e2e harness's driver talks to, as small interfaces (chant#4587),
|
|
3
|
+
* factored from the fan-out demo's lib/ports.ts: the forge, the bucket where
|
|
4
|
+
* chant's reports land, chant run outside the pipeline, the ledger, and time.
|
|
5
|
+
* The real ones are ./forgejo.ts and ./bucket.ts; tests pass fakes.
|
|
6
|
+
*/
|
|
7
|
+
import type { OpRunRecord } from "../op/runtime";
|
|
8
|
+
|
|
9
|
+
/** A forge repository as the author, the reviewer and the admin: the pull request loop. */
|
|
10
|
+
export interface PullForge {
|
|
11
|
+
/**
|
|
12
|
+
* As the author: clone main, write `files` over it (paths relative to the
|
|
13
|
+
* repo root), commit and push to `branch`. Returns the pushed head sha.
|
|
14
|
+
*/
|
|
15
|
+
pushBranch(branch: string, files: Record<string, string>, message: string): Promise<string>;
|
|
16
|
+
/** As the author: open a pull request from `branch` into main. Returns its number. */
|
|
17
|
+
openPull(branch: string, title: string, body: string): Promise<number>;
|
|
18
|
+
/** As the reviewer: an APPROVED review of the pull request. */
|
|
19
|
+
approvePull(pull: number, body: string): Promise<void>;
|
|
20
|
+
/** As the author: merge the pull request. Returns the merge commit's sha. */
|
|
21
|
+
mergePull(pull: number): Promise<string>;
|
|
22
|
+
/** The numbers of the repo's open pull requests. */
|
|
23
|
+
openPulls(): Promise<number[]>;
|
|
24
|
+
closePull(pull: number): Promise<void>;
|
|
25
|
+
/** As the admin: force main to `sha`. */
|
|
26
|
+
forceMain(sha: string): Promise<void>;
|
|
27
|
+
/** The repo's branches, by name. */
|
|
28
|
+
branches(): Promise<string[]>;
|
|
29
|
+
/** Delete a branch. A branch that is gone already is not an error. */
|
|
30
|
+
deleteBranch(name: string): Promise<void>;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** A finished workflow run on the forge. */
|
|
34
|
+
export interface ForgeRun {
|
|
35
|
+
ok: boolean;
|
|
36
|
+
/** The forge's word for how it ended (success, failure, cancelled, ...). */
|
|
37
|
+
status: string;
|
|
38
|
+
/** The forge's id of the run. */
|
|
39
|
+
id?: number;
|
|
40
|
+
/** The names of the jobs that did not succeed, where the forge says. */
|
|
41
|
+
failed?: string[];
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export interface ForgeIssue {
|
|
45
|
+
number: number;
|
|
46
|
+
title: string;
|
|
47
|
+
body: string;
|
|
48
|
+
open: boolean;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* sql-yodeler's Forge verbs (scenarios/forges/forge.ts:26-61) that the pull
|
|
53
|
+
* request loop lacks. `openPr` and `merge` there are `openPull` and
|
|
54
|
+
* `mergePull` here. A run's outcome is read from chant's reports and ledger,
|
|
55
|
+
* so a run carries its status and no log.
|
|
56
|
+
*/
|
|
57
|
+
export interface ForgeReads {
|
|
58
|
+
/** The bodies of a pull request's comments, oldest first. */
|
|
59
|
+
comments(pull: number): Promise<string[]>;
|
|
60
|
+
/** The repository's issues, open and closed, without pull requests. */
|
|
61
|
+
issues(): Promise<ForgeIssue[]>;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export interface ForgeRuns {
|
|
65
|
+
/** The apply again, started by hand on main at `sha` (workflow dispatch of `workflow`). */
|
|
66
|
+
applyAgain(sha: string, workflow: string): Promise<ForgeRun>;
|
|
67
|
+
/** A scheduled workflow (the drift watch) run by hand on main at `sha`, waited for. */
|
|
68
|
+
watch(sha: string, workflow: string): Promise<ForgeRun>;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** The jobs the forge's runner is running, for the kill-job step. */
|
|
72
|
+
export interface Jobs {
|
|
73
|
+
/** Kill the newest running job whose name holds `match` (any job when absent). Resolves with whether one was running. */
|
|
74
|
+
kill(match?: string): Promise<boolean>;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** Everything the harness asks of a forge. */
|
|
78
|
+
export type HarnessForge = PullForge & ForgeReads & ForgeRuns;
|
|
79
|
+
|
|
80
|
+
/** A bucket, keys below its root. */
|
|
81
|
+
export interface Bucket {
|
|
82
|
+
/** The object's text, or null when there is none. */
|
|
83
|
+
get(key: string): Promise<string | null>;
|
|
84
|
+
put(key: string, body: string, contentType: string): Promise<void>;
|
|
85
|
+
/** Every key that starts with `prefix`. */
|
|
86
|
+
list(prefix: string): Promise<string[]>;
|
|
87
|
+
delete(key: string): Promise<void>;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/** The plan a reviewer approves, as pr-plan.json names it. */
|
|
91
|
+
export interface ApproveInput {
|
|
92
|
+
pull: number;
|
|
93
|
+
op: string;
|
|
94
|
+
gate: string;
|
|
95
|
+
digest: string;
|
|
96
|
+
approver: string;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/** chant, run by the driver outside the pipeline. */
|
|
100
|
+
export interface Chant {
|
|
101
|
+
/** `chant approve <op> <gate> --plan <digest> --approver <approver> --sign <key>` from the reviewer's clone. */
|
|
102
|
+
approve(input: ApproveInput): Promise<void>;
|
|
103
|
+
/** The base's templates built and applied outside the pipeline. */
|
|
104
|
+
applyBase(): Promise<void>;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/** The run ledger of the scenario's repo (`chant/lifecycle`), read. */
|
|
108
|
+
export interface Ledger {
|
|
109
|
+
runs(env: string, op: string): Promise<OpRunRecord[]>;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/** Work outside the forge and chant: a change made out of band. */
|
|
113
|
+
export interface OutOfBand {
|
|
114
|
+
/** Run `command` with the no-real-cloud environment. Resolves with its exit code. */
|
|
115
|
+
run(command: string[]): Promise<number>;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/** Time, so a test runs a scenario without waiting. */
|
|
119
|
+
export interface Clock {
|
|
120
|
+
now(): number;
|
|
121
|
+
sleep(ms: number): Promise<void>;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export const realClock: Clock = {
|
|
125
|
+
now: () => Date.now(),
|
|
126
|
+
sleep: (ms) => new Promise((resolve) => setTimeout(resolve, ms)),
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
/** A log line for the person running the driver. */
|
|
130
|
+
export type Log = (line: string) => void;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* chant's pull request reports as the harness reads them (chant#4587). A
|
|
3
|
+
* scenario's outcomes come from these and from the run ledger, never from a
|
|
4
|
+
* runner's status or its logs. The jobs write them under `--report-url`, at
|
|
5
|
+
* `<pr>/<commit>/pr-plan.json` and `pr-apply.json` (reportKey).
|
|
6
|
+
*/
|
|
7
|
+
import { reportKey } from "../pr-report-url";
|
|
8
|
+
import type { Bucket, Clock } from "./ports";
|
|
9
|
+
|
|
10
|
+
export type ReportStage = "plan" | "apply";
|
|
11
|
+
|
|
12
|
+
/** pr-report/v1, the fields the harness reads. */
|
|
13
|
+
export interface PrReportView {
|
|
14
|
+
stage: ReportStage;
|
|
15
|
+
pr: number | null;
|
|
16
|
+
head: string;
|
|
17
|
+
op: string;
|
|
18
|
+
gate: string;
|
|
19
|
+
digest: string;
|
|
20
|
+
status: string;
|
|
21
|
+
refusal?: string;
|
|
22
|
+
message?: string;
|
|
23
|
+
approval?: { status?: string };
|
|
24
|
+
selection: { waves: string[][] };
|
|
25
|
+
members: Array<{ member: string; component: string; status: string; error?: string }>;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** The report file of a stage. */
|
|
29
|
+
export const reportFile = (stage: ReportStage): string => `pr-${stage}.json`;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* The bucket key of a report: `prefix` is the report URL's path below the
|
|
33
|
+
* bucket (`s3://<bucket>/<prefix>`), as the bucket names keys.
|
|
34
|
+
*/
|
|
35
|
+
export function reportObjectKey(prefix: string, pr: number | null, commit: string, stage: ReportStage): string {
|
|
36
|
+
return `${prefix.replace(/\/+$/, "")}/${reportKey(pr, commit)}/${reportFile(stage)}`;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** The path of an s3:// report URL below its bucket, and the bucket. */
|
|
40
|
+
export function splitReportUrl(url: string): { bucket: string; prefix: string } {
|
|
41
|
+
const m = /^s3:\/\/([^/]+)\/?(.*)$/.exec(url);
|
|
42
|
+
if (!m) throw new Error(`${url} is not an s3:// report URL`);
|
|
43
|
+
return { bucket: m[1]!, prefix: m[2]!.replace(/\/+$/, "") };
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** A report, or null while there is none. */
|
|
47
|
+
export async function readReport(bucket: Bucket, key: string): Promise<PrReportView | null> {
|
|
48
|
+
const text = await bucket.get(key);
|
|
49
|
+
return text === null ? null : (JSON.parse(text) as PrReportView);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** Wait for a report until `deadline` (clock ms). Resolves with it, or null past the deadline. */
|
|
53
|
+
export async function waitForReport(bucket: Bucket, key: string, clock: Clock, deadline: number, pollMs = 2000): Promise<PrReportView | null> {
|
|
54
|
+
for (;;) {
|
|
55
|
+
const r = await readReport(bucket, key);
|
|
56
|
+
if (r) return r;
|
|
57
|
+
if (clock.now() >= deadline) return null;
|
|
58
|
+
await clock.sleep(pollMs);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** Each component's status in a report: failed if a member failed, else the members' one status, else them joined with +. */
|
|
63
|
+
export function componentStatuses(report: Pick<PrReportView, "members">): Map<string, string> {
|
|
64
|
+
const byComponent = new Map<string, string[]>();
|
|
65
|
+
for (const m of report.members) {
|
|
66
|
+
const name = m.component || m.member;
|
|
67
|
+
byComponent.set(name, [...(byComponent.get(name) ?? []), m.status]);
|
|
68
|
+
}
|
|
69
|
+
const out = new Map<string, string>();
|
|
70
|
+
for (const [name, statuses] of byComponent) {
|
|
71
|
+
const one = statuses.includes("failed")
|
|
72
|
+
? "failed"
|
|
73
|
+
: statuses.every((s) => s === statuses[0])
|
|
74
|
+
? statuses[0]!
|
|
75
|
+
: statuses.join("+");
|
|
76
|
+
out.set(name, one);
|
|
77
|
+
}
|
|
78
|
+
return out;
|
|
79
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { afterEach, beforeEach, describe, expect, test, vi } from "vitest";
|
|
2
|
+
import { existsSync, mkdirSync, mkdtempSync, readFileSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { tmpdir } from "node:os";
|
|
4
|
+
import { join } from "node:path";
|
|
5
|
+
import { EXIT_REAL_CLOUD, EXIT_REFUSED, runSafeRunCommand } from "./safe-run-cli";
|
|
6
|
+
import { parseArgs } from "../cli/parse-args";
|
|
7
|
+
|
|
8
|
+
const node = (script: string): string[] => [process.execPath, "-e", script];
|
|
9
|
+
|
|
10
|
+
describe("chant e2e safe-run", () => {
|
|
11
|
+
let scratch: string;
|
|
12
|
+
let out: string[];
|
|
13
|
+
let err: string[];
|
|
14
|
+
beforeEach(() => {
|
|
15
|
+
scratch = mkdtempSync(join(tmpdir(), "safe-run-cli-test-"));
|
|
16
|
+
out = [];
|
|
17
|
+
err = [];
|
|
18
|
+
vi.spyOn(console, "log").mockImplementation((...a) => void out.push(a.join(" ")));
|
|
19
|
+
vi.spyOn(console, "error").mockImplementation((...a) => void err.push(a.join(" ")));
|
|
20
|
+
});
|
|
21
|
+
afterEach(() => vi.restoreAllMocks());
|
|
22
|
+
|
|
23
|
+
const base = { PATH: process.env.PATH, HOME: "/nonexistent" };
|
|
24
|
+
|
|
25
|
+
test("runs the command with the scrubbed environment and prints CLEAN", async () => {
|
|
26
|
+
const dump = join(scratch, "env.json");
|
|
27
|
+
const code = await runSafeRunCommand({
|
|
28
|
+
command: node(`require("fs").writeFileSync(${JSON.stringify(dump)}, JSON.stringify(process.env))`),
|
|
29
|
+
scratch,
|
|
30
|
+
echo: false,
|
|
31
|
+
base: { ...base, GOOGLE_APPLICATION_CREDENTIALS: "/real/key.json", AWS_PROFILE: "prod", GOOGLE_CLOUD_PROJECT: "p", CLOUDSDK_CONFIG: "/home/me/.config/gcloud", PULUMI_ACCESS_TOKEN: "pul-x" },
|
|
32
|
+
});
|
|
33
|
+
expect(code).toBe(0);
|
|
34
|
+
expect(out).toEqual(["CLEAN"]);
|
|
35
|
+
const env = JSON.parse(readFileSync(dump, "utf8")) as Record<string, string>;
|
|
36
|
+
expect(env.GOOGLE_APPLICATION_CREDENTIALS).toBeUndefined();
|
|
37
|
+
expect(env.AWS_PROFILE).toBeUndefined();
|
|
38
|
+
expect(env.GOOGLE_CLOUD_PROJECT).toBeUndefined();
|
|
39
|
+
expect(env.PULUMI_ACCESS_TOKEN).toBeUndefined();
|
|
40
|
+
expect(env.CLOUDSDK_CONFIG).not.toBe("/home/me/.config/gcloud");
|
|
41
|
+
expect(existsSync(env.CLOUDSDK_CONFIG)).toBe(true);
|
|
42
|
+
expect(env.PULUMI_BACKEND_URL).toMatch(/^file:\/\//);
|
|
43
|
+
expect(env.PULUMI_SKIP_UPDATE_CHECK).toBe("true");
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
test("keeps a local PULUMI_BACKEND_URL and refuses a remote one", async () => {
|
|
47
|
+
const dump = join(scratch, "backend.txt");
|
|
48
|
+
const script = `require("fs").writeFileSync(${JSON.stringify(dump)}, process.env.PULUMI_BACKEND_URL)`;
|
|
49
|
+
expect(await runSafeRunCommand({ command: node(script), scratch, echo: false, base: { ...base, PULUMI_BACKEND_URL: "file:///tmp/mine" } })).toBe(0);
|
|
50
|
+
expect(readFileSync(dump, "utf8")).toBe("file:///tmp/mine");
|
|
51
|
+
expect(await runSafeRunCommand({ command: node(script), scratch, echo: false, base: { ...base, PULUMI_BACKEND_URL: "https://api.pulumi.com" } })).toBe(EXIT_REFUSED);
|
|
52
|
+
expect(err.join("\n")).toContain("not a local backend");
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
test("passes the command's own exit code through after a CLEAN scan", async () => {
|
|
56
|
+
expect(await runSafeRunCommand({ command: node("process.exit(7)"), scratch, echo: false, base })).toBe(7);
|
|
57
|
+
expect(out).toEqual(["CLEAN"]);
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
test("rejects output where a real cloud refused a credential, and exits non-zero even when the command exits 0", async () => {
|
|
61
|
+
const code = await runSafeRunCommand({
|
|
62
|
+
command: node(`console.log("An error occurred (UnrecognizedClientException) when calling the ListBuckets operation")`),
|
|
63
|
+
scratch,
|
|
64
|
+
echo: false,
|
|
65
|
+
base,
|
|
66
|
+
});
|
|
67
|
+
expect(code).toBe(EXIT_REAL_CLOUD);
|
|
68
|
+
expect(out).not.toContain("CLEAN");
|
|
69
|
+
expect(err.join("\n")).toContain("UnrecognizedClientException");
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
test("rejects a 401 from a cloud host in a --scan directory, and a missing --scan directory", async () => {
|
|
73
|
+
const dir = join(scratch, "logs");
|
|
74
|
+
mkdirSync(dir);
|
|
75
|
+
writeFileSync(join(dir, "a.log"), "GET https://storage.googleapis.com/b 401 Unauthorized\n");
|
|
76
|
+
expect(await runSafeRunCommand({ command: node("0"), scratch, scan: [dir], echo: false, base })).toBe(EXIT_REAL_CLOUD);
|
|
77
|
+
expect(err.join("\n")).toContain("a.log:1:");
|
|
78
|
+
err.length = 0;
|
|
79
|
+
expect(await runSafeRunCommand({ command: node("0"), scratch, scan: [join(scratch, "nope")], echo: false, base })).toBe(EXIT_REAL_CLOUD);
|
|
80
|
+
expect(err.join("\n")).toContain("could not be checked");
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
test("a clean --scan directory passes", async () => {
|
|
84
|
+
const dir = join(scratch, "clean");
|
|
85
|
+
mkdirSync(dir);
|
|
86
|
+
writeFileSync(join(dir, "a.log"), "all good\n");
|
|
87
|
+
expect(await runSafeRunCommand({ command: node("0"), scratch, scan: [dir], echo: false, base })).toBe(0);
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
test("a command that cannot start is a refusal, not a pass", async () => {
|
|
91
|
+
expect(await runSafeRunCommand({ command: ["/nonexistent/fake-cmd"], scratch, echo: false, base })).toBe(EXIT_REFUSED);
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
test("parseArgs keeps the command after -- and collects each --scan", () => {
|
|
95
|
+
const a = parseArgs(["e2e", "safe-run", "--scan", "a", "--scan", "b", "--", "bash", "-c", "echo hi", "--flag"]);
|
|
96
|
+
expect(a.command).toBe("e2e");
|
|
97
|
+
expect(a.path).toBe("safe-run");
|
|
98
|
+
expect(a.scanDirs).toEqual(["a", "b"]);
|
|
99
|
+
expect(a.positionals?.slice(1)).toEqual(["bash", "-c", "echo hi", "--flag"]);
|
|
100
|
+
expect(() => parseArgs(["e2e", "safe-run", "--scan"])).toThrow(/--scan needs a directory/);
|
|
101
|
+
});
|
|
102
|
+
});
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The body of `chant e2e safe-run` (chant#4587, C1): run one command through
|
|
3
|
+
* {@link SafeRun}, so a bash driver gets the same environment and the same
|
|
4
|
+
* scan the TypeScript harness uses.
|
|
5
|
+
*/
|
|
6
|
+
import { mkdtempSync } from "node:fs";
|
|
7
|
+
import { tmpdir } from "node:os";
|
|
8
|
+
import { join, resolve } from "node:path";
|
|
9
|
+
import { SafeRun } from "./safe-run";
|
|
10
|
+
|
|
11
|
+
/** Exit code when the scan finds a real cloud answering: nothing may be recorded. */
|
|
12
|
+
export const EXIT_REAL_CLOUD = 3;
|
|
13
|
+
/** Exit code for a usage error or an environment the wrapper refuses. */
|
|
14
|
+
export const EXIT_REFUSED = 2;
|
|
15
|
+
|
|
16
|
+
export interface SafeRunCommandInput {
|
|
17
|
+
command: string[];
|
|
18
|
+
/** Directories scanned after the run, beside the command's output. */
|
|
19
|
+
scan?: string[];
|
|
20
|
+
/** Where the log and the empty config dirs go; a fresh temp dir by default. */
|
|
21
|
+
scratch?: string;
|
|
22
|
+
/** The environment the wrapper scrubs; process.env by default. */
|
|
23
|
+
base?: Record<string, string | undefined>;
|
|
24
|
+
/** Pass the command's output through to this process's stdout and stderr (default true). */
|
|
25
|
+
echo?: boolean;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export async function runSafeRunCommand(i: SafeRunCommandInput): Promise<number> {
|
|
29
|
+
const scratch = i.scratch ?? mkdtempSync(join(tmpdir(), "chant-e2e-safe-run-"));
|
|
30
|
+
let safe: SafeRun;
|
|
31
|
+
try {
|
|
32
|
+
safe = new SafeRun({ scratch, scan: (i.scan ?? []).map((d) => resolve(d)), echo: i.echo ?? true }, i.base);
|
|
33
|
+
} catch (err) {
|
|
34
|
+
console.error(`e2e-safe-run: refused: ${err instanceof Error ? err.message : String(err)}`);
|
|
35
|
+
return EXIT_REFUSED;
|
|
36
|
+
}
|
|
37
|
+
let code: number;
|
|
38
|
+
try {
|
|
39
|
+
code = await safe.run(i.command);
|
|
40
|
+
} catch (err) {
|
|
41
|
+
console.error(`e2e-safe-run: could not run ${i.command[0]}: ${err instanceof Error ? err.message : String(err)}`);
|
|
42
|
+
return EXIT_REFUSED;
|
|
43
|
+
}
|
|
44
|
+
const verdict = safe.scan();
|
|
45
|
+
if (verdict.verdict === "CLEAN") {
|
|
46
|
+
console.log("CLEAN");
|
|
47
|
+
console.error(`e2e-safe-run: log ${safe.logFile}`);
|
|
48
|
+
return code;
|
|
49
|
+
}
|
|
50
|
+
console.error("REAL-CLOUD CALL: the output shows a public cloud rejecting a credential, so a call left this machine. This run is not recorded.");
|
|
51
|
+
for (const h of verdict.hits) console.error(` ${h}`);
|
|
52
|
+
console.error(`e2e-safe-run: log ${safe.logFile}`);
|
|
53
|
+
return EXIT_REAL_CLOUD;
|
|
54
|
+
}
|