@intentius/chant 0.124.88 → 0.124.90
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/actor.d.ts +36 -1
- package/dist/actor.d.ts.map +1 -1
- package/dist/actor.js +39 -1
- package/dist/chant-install.d.ts.map +1 -1
- package/dist/chant-install.js +1 -2
- package/dist/ci-base.d.ts +30 -0
- package/dist/ci-base.d.ts.map +1 -0
- package/dist/ci-base.js +33 -0
- package/dist/ci-comment-commands.d.ts +193 -0
- package/dist/ci-comment-commands.d.ts.map +1 -0
- package/dist/ci-comment-commands.js +353 -0
- package/dist/ci-comment-replies.d.ts +40 -0
- package/dist/ci-comment-replies.d.ts.map +1 -0
- package/dist/ci-comment-replies.js +59 -0
- package/dist/ci-evidence-from-job.d.ts +25 -0
- package/dist/ci-evidence-from-job.d.ts.map +1 -1
- package/dist/ci-evidence-from-job.js +43 -2
- package/dist/ci-evidence-jobs.d.ts +30 -1
- package/dist/ci-evidence-jobs.d.ts.map +1 -1
- package/dist/ci-evidence-jobs.js +46 -3
- package/dist/ci-image.d.ts +21 -4
- package/dist/ci-image.d.ts.map +1 -1
- package/dist/ci-image.js +62 -10
- package/dist/ci-job-guard.d.ts +42 -45
- package/dist/ci-job-guard.d.ts.map +1 -1
- package/dist/ci-job-guard.js +206 -3
- package/dist/ci-note-commands.d.ts +104 -4
- package/dist/ci-note-commands.d.ts.map +1 -1
- package/dist/ci-note-commands.js +131 -38
- package/dist/ci-product-words.d.ts +42 -0
- package/dist/ci-product-words.d.ts.map +1 -1
- package/dist/ci-product-words.js +25 -0
- package/dist/ci-product.d.ts +72 -1
- package/dist/ci-product.d.ts.map +1 -1
- package/dist/ci-product.js +73 -6
- package/dist/cli/commands/build.d.ts.map +1 -1
- package/dist/cli/commands/build.js +29 -2
- package/dist/cli/handlers/approve.d.ts.map +1 -1
- package/dist/cli/handlers/approve.js +2 -1
- package/dist/cli/handlers/ci-check.d.ts +1 -1
- package/dist/cli/handlers/ci-check.d.ts.map +1 -1
- package/dist/cli/handlers/ci-check.js +17 -7
- package/dist/cli/handlers/ci-evidence.d.ts.map +1 -1
- package/dist/cli/handlers/ci-evidence.js +33 -7
- package/dist/cli/handlers/components.d.ts.map +1 -1
- package/dist/cli/handlers/components.js +3 -1
- package/dist/cli/handlers/generated-check.d.ts +8 -0
- package/dist/cli/handlers/generated-check.d.ts.map +1 -1
- package/dist/cli/handlers/generated-check.js +31 -1
- package/dist/cli/handlers/lock.d.ts.map +1 -1
- package/dist/cli/handlers/lock.js +121 -4
- package/dist/cli/handlers/pr-comment.d.ts +33 -0
- package/dist/cli/handlers/pr-comment.d.ts.map +1 -0
- package/dist/cli/handlers/pr-comment.js +201 -0
- package/dist/cli/handlers/pr-env.d.ts.map +1 -1
- package/dist/cli/handlers/pr-env.js +6 -3
- package/dist/cli/handlers/pr-notes.d.ts.map +1 -1
- package/dist/cli/handlers/pr-notes.js +23 -1
- package/dist/cli/handlers/pr.d.ts +23 -1
- package/dist/cli/handlers/pr.d.ts.map +1 -1
- package/dist/cli/handlers/pr.js +71 -23
- package/dist/cli/handlers/promote.d.ts.map +1 -1
- package/dist/cli/handlers/promote.js +2 -1
- package/dist/cli/handlers/release.d.ts.map +1 -1
- package/dist/cli/handlers/release.js +11 -2
- package/dist/cli/handlers/run-wave.d.ts.map +1 -1
- package/dist/cli/handlers/run-wave.js +180 -4
- package/dist/cli/handlers/run.d.ts.map +1 -1
- package/dist/cli/handlers/run.js +2 -1
- package/dist/cli/main.d.ts.map +1 -1
- package/dist/cli/main.js +41 -2
- package/dist/cli/parse-args.d.ts.map +1 -1
- package/dist/cli/parse-args.js +31 -0
- package/dist/cli/registry.d.ts +19 -1
- package/dist/cli/registry.d.ts.map +1 -1
- package/dist/components/auto-release.d.ts.map +1 -1
- package/dist/components/auto-release.js +2 -1
- package/dist/components/pr-checks.d.ts +97 -6
- package/dist/components/pr-checks.d.ts.map +1 -1
- package/dist/components/pr-checks.js +107 -13
- package/dist/components/pr-pipeline.d.ts +19 -14
- package/dist/components/pr-pipeline.d.ts.map +1 -1
- package/dist/components/pr-pipeline.js +7 -13
- package/dist/components/product-pipeline.d.ts +96 -3
- package/dist/components/product-pipeline.d.ts.map +1 -1
- package/dist/components/product-pipeline.js +120 -14
- package/dist/components/product-plan.d.ts +203 -6
- package/dist/components/product-plan.d.ts.map +1 -1
- package/dist/components/product-plan.js +250 -43
- package/dist/drift-record.d.ts +7 -0
- package/dist/drift-record.d.ts.map +1 -1
- package/dist/drift-record.js +19 -0
- package/dist/floor-table.data.d.ts.map +1 -1
- package/dist/floor-table.data.js +63 -31
- package/dist/forge-check/contract.d.ts +11 -1
- package/dist/forge-check/contract.d.ts.map +1 -1
- package/dist/forge-check/contract.js +4 -1
- package/dist/forge-check/index.d.ts +2 -0
- package/dist/forge-check/index.d.ts.map +1 -1
- package/dist/forge-check/index.js +2 -0
- package/dist/gate-resume-run.d.ts +9 -1
- package/dist/gate-resume-run.d.ts.map +1 -1
- package/dist/gate-resume-run.js +26 -3
- package/dist/generated-check.d.ts +18 -4
- package/dist/generated-check.d.ts.map +1 -1
- package/dist/generated-check.js +37 -5
- package/dist/image-pins.d.ts +26 -0
- package/dist/image-pins.d.ts.map +1 -0
- package/dist/image-pins.js +19 -0
- package/dist/lexicon.d.ts +93 -4
- package/dist/lexicon.d.ts.map +1 -1
- package/dist/lifecycle/gate-applied.d.ts +9 -0
- package/dist/lifecycle/gate-applied.d.ts.map +1 -1
- package/dist/lifecycle/git.d.ts +11 -0
- package/dist/lifecycle/git.d.ts.map +1 -1
- package/dist/lifecycle/git.js +30 -3
- package/dist/lifecycle/publish-npm.d.ts +11 -0
- package/dist/lifecycle/publish-npm.d.ts.map +1 -1
- package/dist/lifecycle/publish-npm.js +27 -1
- package/dist/lifecycle/reach-locks.d.ts +131 -0
- package/dist/lifecycle/reach-locks.d.ts.map +1 -0
- package/dist/lifecycle/reach-locks.js +118 -0
- package/dist/lifecycle/release-cut.d.ts +3 -1
- package/dist/lifecycle/release-cut.d.ts.map +1 -1
- package/dist/lifecycle/release-cut.js +15 -0
- package/dist/lifecycle/release-images.d.ts.map +1 -1
- package/dist/lifecycle/release-images.js +1 -2
- package/dist/notify-product.d.ts +12 -3
- package/dist/notify-product.d.ts.map +1 -1
- package/dist/notify-product.js +10 -6
- package/dist/op/activities/source-release.d.ts.map +1 -1
- package/dist/op/activities/source-release.js +2 -1
- package/dist/op/activities/source-rollback.d.ts.map +1 -1
- package/dist/op/activities/source-rollback.js +2 -1
- package/dist/op/apply-status.d.ts +84 -0
- package/dist/op/apply-status.d.ts.map +1 -0
- package/dist/op/apply-status.js +106 -0
- package/dist/op/before-merge-decide.d.ts +102 -0
- package/dist/op/before-merge-decide.d.ts.map +1 -0
- package/dist/op/before-merge-decide.js +142 -0
- package/dist/op/before-merge-done.d.ts +56 -0
- package/dist/op/before-merge-done.d.ts.map +1 -0
- package/dist/op/before-merge-done.js +69 -0
- package/dist/op/before-merge-store.d.ts +20 -0
- package/dist/op/before-merge-store.d.ts.map +1 -0
- package/dist/op/before-merge-store.js +48 -0
- package/dist/op/before-merge.d.ts +150 -0
- package/dist/op/before-merge.d.ts.map +1 -0
- package/dist/op/before-merge.js +207 -0
- package/dist/op/follow-on-run.d.ts +117 -0
- package/dist/op/follow-on-run.d.ts.map +1 -0
- package/dist/op/follow-on-run.js +154 -0
- package/dist/op/follow-on-store.d.ts +17 -0
- package/dist/op/follow-on-store.d.ts.map +1 -0
- package/dist/op/follow-on-store.js +54 -0
- package/dist/op/gate.d.ts +6 -0
- package/dist/op/gate.d.ts.map +1 -1
- package/dist/op/gate.js +10 -1
- package/dist/op/index.d.ts +5 -1
- package/dist/op/index.d.ts.map +1 -1
- package/dist/op/index.js +2 -0
- package/dist/op/op-waves-after-plan.d.ts +13 -0
- package/dist/op/op-waves-after-plan.d.ts.map +1 -1
- package/dist/op/op-waves-evidence-jobs.d.ts +10 -2
- package/dist/op/op-waves-evidence-jobs.d.ts.map +1 -1
- package/dist/op/op-waves-evidence-jobs.js +19 -5
- package/dist/op/op-waves-follow-on.d.ts +162 -0
- package/dist/op/op-waves-follow-on.d.ts.map +1 -0
- package/dist/op/op-waves-follow-on.js +355 -0
- package/dist/op/op-waves-render-spec.d.ts +100 -0
- package/dist/op/op-waves-render-spec.d.ts.map +1 -0
- package/dist/op/op-waves-render-spec.js +162 -0
- package/dist/op/op-waves-run.d.ts +148 -6
- package/dist/op/op-waves-run.d.ts.map +1 -1
- package/dist/op/op-waves-run.js +873 -100
- package/dist/op/op-waves-split.d.ts +122 -0
- package/dist/op/op-waves-split.d.ts.map +1 -0
- package/dist/op/op-waves-split.js +166 -0
- package/dist/op/op-waves.d.ts +24 -0
- package/dist/op/op-waves.d.ts.map +1 -1
- package/dist/op/op-waves.js +18 -1
- package/dist/op/schedule-overdue.d.ts +15 -1
- package/dist/op/schedule-overdue.d.ts.map +1 -1
- package/dist/op/schedule-overdue.js +77 -5
- package/dist/op/stage-hooks.d.ts +36 -1
- package/dist/op/stage-hooks.d.ts.map +1 -1
- package/dist/op/stage-hooks.js +17 -3
- package/dist/op/wave-stop.d.ts +67 -0
- package/dist/op/wave-stop.d.ts.map +1 -0
- package/dist/op/wave-stop.js +129 -0
- package/dist/planned-files.d.ts +76 -0
- package/dist/planned-files.d.ts.map +1 -0
- package/dist/planned-files.js +108 -0
- package/dist/pr-forge-job.d.ts +22 -0
- package/dist/pr-forge-job.d.ts.map +1 -0
- package/dist/pr-forge-job.js +46 -0
- package/dist/pr-loop.d.ts +3 -6
- package/dist/pr-loop.d.ts.map +1 -1
- package/dist/pr-loop.js +4 -81
- package/dist/pr-plan-note.d.ts +97 -0
- package/dist/pr-plan-note.d.ts.map +1 -1
- package/dist/pr-plan-note.js +94 -1
- package/dist/pr-post.d.ts +28 -3
- package/dist/pr-post.d.ts.map +1 -1
- package/dist/pr-post.js +146 -13
- package/dist/pr-status.d.ts +16 -0
- package/dist/pr-status.d.ts.map +1 -0
- package/dist/pr-status.js +90 -0
- package/dist/ref-gate-init.d.ts +16 -2
- package/dist/ref-gate-init.d.ts.map +1 -1
- package/dist/ref-gate-init.js +24 -13
- package/dist/release-floors.d.ts +39 -1
- package/dist/release-floors.d.ts.map +1 -1
- package/dist/release-floors.js +63 -25
- package/dist/render-module.d.ts +15 -0
- package/dist/render-module.d.ts.map +1 -0
- package/dist/render-module.js +73 -0
- package/dist/state-migration.d.ts.map +1 -1
- package/dist/state-migration.js +1 -2
- package/dist/wave-blocked.d.ts +7 -1
- package/dist/wave-blocked.d.ts.map +1 -1
- package/dist/wave-blocked.js +7 -2
- package/dist/wave-runtime.mjs +366 -350
- package/dist/workspace/ci-green-cli.d.ts.map +1 -1
- package/dist/workspace/ci-green-cli.js +3 -2
- package/dist/workspace/release-train.d.ts.map +1 -1
- package/dist/workspace/release-train.js +2 -1
- package/dist/workspace/release-workflow.d.ts +4 -3
- package/dist/workspace/release-workflow.d.ts.map +1 -1
- package/dist/workspace/release-workflow.js +10 -7
- package/dist/workspace/trust/check-evidence-report.d.ts +7 -2
- package/dist/workspace/trust/check-evidence-report.d.ts.map +1 -1
- package/dist/workspace/trust/check-evidence-report.js +15 -8
- package/dist/workspace/trust/ref-gate-cli.d.ts +10 -1
- package/dist/workspace/trust/ref-gate-cli.d.ts.map +1 -1
- package/dist/workspace/trust/ref-gate-cli.js +30 -10
- package/dist/workspace/workspace-run.d.ts.map +1 -1
- package/dist/workspace/workspace-run.js +2 -1
- package/package.json +1 -1
- package/src/actor.test.ts +68 -2
- package/src/actor.ts +61 -1
- package/src/chant-install.test.ts +2 -3
- package/src/chant-install.ts +1 -2
- package/src/ci-base.test.ts +41 -0
- package/src/ci-base.ts +43 -0
- package/src/ci-comment-commands.test.ts +439 -0
- package/src/ci-comment-commands.ts +428 -0
- package/src/ci-comment-replies.ts +78 -0
- package/src/ci-commit.test.ts +2 -3
- package/src/ci-evidence-from-job.test.ts +18 -0
- package/src/ci-evidence-from-job.ts +58 -2
- package/src/ci-evidence-jobs.ts +50 -5
- package/src/ci-image.test.ts +130 -10
- package/src/ci-image.ts +85 -12
- package/src/ci-job-guard.before-merge.test.ts +148 -0
- package/src/ci-job-guard.follow-on-record.test.ts +137 -0
- package/src/ci-job-guard.follow-on.test.ts +144 -0
- package/src/ci-job-guard.ts +221 -3
- package/src/ci-note-commands.test.ts +76 -1
- package/src/ci-note-commands.ts +198 -46
- package/src/ci-product-words.ts +59 -0
- package/src/ci-product.ts +90 -6
- package/src/cli/commands/build.test.ts +41 -0
- package/src/cli/commands/build.ts +27 -2
- package/src/cli/handlers/approve.ts +2 -1
- package/src/cli/handlers/ci-check.ts +19 -7
- package/src/cli/handlers/ci-evidence.ts +29 -8
- package/src/cli/handlers/components.ts +3 -1
- package/src/cli/handlers/generated-check.ts +31 -1
- package/src/cli/handlers/lock-reach.test.ts +103 -0
- package/src/cli/handlers/lock.ts +100 -4
- package/src/cli/handlers/pr-comment.ts +187 -0
- package/src/cli/handlers/pr-env.ts +6 -3
- package/src/cli/handlers/pr-notes.ts +30 -6
- package/src/cli/handlers/pr-record.test.ts +1 -1
- package/src/cli/handlers/pr.ts +64 -21
- package/src/cli/handlers/promote.ts +2 -1
- package/src/cli/handlers/release.e2e.test.ts +35 -0
- package/src/cli/handlers/release.ts +14 -2
- package/src/cli/handlers/run-wave.ts +170 -4
- package/src/cli/handlers/run.ts +2 -1
- package/src/cli/main.ts +41 -2
- package/src/cli/parse-args.ts +23 -0
- package/src/cli/registry.ts +19 -1
- package/src/components/auto-release.ts +2 -1
- package/src/components/pr-checks.ts +165 -17
- package/src/components/pr-pipeline.ts +22 -18
- package/src/components/product-pipeline.apply-status.test.ts +50 -0
- package/src/components/product-pipeline.ts +204 -17
- package/src/components/product-plan.test.ts +60 -4
- package/src/components/product-plan.ts +367 -50
- package/src/drift-record.test.ts +20 -0
- package/src/drift-record.ts +16 -0
- package/src/floor-table.data.ts +63 -31
- package/src/forge-check/contract.ts +12 -1
- package/src/forge-check/forge-check.test.ts +17 -0
- package/src/forge-check/index.ts +2 -0
- package/src/gate-resume-run.ts +27 -3
- package/src/generated-check.e2e.test.ts +21 -1
- package/src/generated-check.test.ts +66 -0
- package/src/generated-check.ts +51 -10
- package/src/image-pins.ts +31 -0
- package/src/lexicon.ts +89 -1
- package/src/lifecycle/gate-applied.ts +7 -0
- package/src/lifecycle/git.test.ts +48 -0
- package/src/lifecycle/git.ts +27 -4
- package/src/lifecycle/publish-npm.ts +31 -1
- package/src/lifecycle/reach-locks.test.ts +87 -0
- package/src/lifecycle/reach-locks.ts +169 -0
- package/src/lifecycle/release-cut.ts +17 -1
- package/src/lifecycle/release-images.test.ts +56 -0
- package/src/lifecycle/release-images.ts +1 -2
- package/src/notify-product.ts +19 -8
- package/src/op/activities/source-release.ts +2 -1
- package/src/op/activities/source-rollback.ts +2 -1
- package/src/op/apply-status.test.ts +83 -0
- package/src/op/apply-status.ts +132 -0
- package/src/op/before-merge-decide.ts +190 -0
- package/src/op/before-merge-done.ts +99 -0
- package/src/op/before-merge-store.ts +44 -0
- package/src/op/before-merge.test.ts +201 -0
- package/src/op/before-merge.ts +266 -0
- package/src/op/follow-on-run.ts +206 -0
- package/src/op/follow-on-store.ts +54 -0
- package/src/op/gate-resume.test.ts +27 -0
- package/src/op/gate.ts +16 -1
- package/src/op/index.ts +15 -0
- package/src/op/op-waves-after-plan.ts +13 -0
- package/src/op/op-waves-evidence-jobs.ts +21 -7
- package/src/op/op-waves-follow-on-record.test.ts +152 -0
- package/src/op/op-waves-follow-on.test.ts +247 -0
- package/src/op/op-waves-follow-on.ts +385 -0
- package/src/op/op-waves-notify-words.test.ts +18 -0
- package/src/op/op-waves-render-spec.test.ts +159 -0
- package/src/op/op-waves-render-spec.ts +171 -0
- package/src/op/op-waves-run.ts +973 -94
- package/src/op/op-waves-split-product.test.ts +288 -0
- package/src/op/op-waves-split-step.test.ts +298 -0
- package/src/op/op-waves-split.test.ts +196 -0
- package/src/op/op-waves-split.ts +189 -0
- package/src/op/op-waves.ts +31 -3
- package/src/op/schedule-overdue.test.ts +72 -1
- package/src/op/schedule-overdue.ts +84 -6
- package/src/op/stage-hooks.ts +52 -4
- package/src/op/wave-stop.test.ts +72 -0
- package/src/op/wave-stop.ts +139 -0
- package/src/planned-files.test.ts +80 -0
- package/src/planned-files.ts +134 -0
- package/src/pr-forge-job.test.ts +53 -0
- package/src/pr-forge-job.ts +46 -0
- package/src/pr-loop-narrowed.test.ts +2 -1
- package/src/pr-loop-words.test.ts +2 -1
- package/src/pr-loop.test.ts +1 -2
- package/src/pr-loop.ts +4 -80
- package/src/pr-plan-note.ts +155 -3
- package/src/pr-post-replan.test.ts +144 -0
- package/src/pr-post-subject.test.ts +230 -0
- package/src/pr-post.test.ts +2 -1
- package/src/pr-post.ts +151 -15
- package/src/pr-status.ts +91 -0
- package/src/ref-gate-init.ts +30 -11
- package/src/release-floors.ts +81 -25
- package/src/render-module.ts +73 -0
- package/src/state-migration-record.test.ts +2 -3
- package/src/state-migration.ts +1 -2
- package/src/wave-blocked.ts +9 -4
- package/src/workspace/ci-green-cli.ts +3 -2
- package/src/workspace/ci-green-workflow.test.ts +32 -1
- package/src/workspace/release-train.ts +2 -1
- package/src/workspace/release-workflow.test.ts +36 -5
- package/src/workspace/release-workflow.ts +10 -7
- package/src/workspace/trust/check-evidence-report.ts +15 -8
- package/src/workspace/trust/check-evidence.test.ts +5 -0
- package/src/workspace/trust/ref-gate-cli.ts +30 -8
- package/src/workspace/trust/ref-gate-pieces.test.ts +46 -1
- package/src/workspace/trust/ref-gate.test.ts +10 -0
- package/src/workspace/workspace-run.ts +2 -1
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `chant components pr-comment --forge github|forgejo` (#4946): the comment
|
|
3
|
+
* job of GitHub's and Forgejo's product pipeline.
|
|
4
|
+
*
|
|
5
|
+
* It reads the `issue_comment` event from `GITHUB_EVENT_PATH`, and the jobs
|
|
6
|
+
* the pipeline has from `CHANT_COMMENT_JOBS` (JSON, written by the
|
|
7
|
+
* generator), and answers the comment when no other job of the pipeline
|
|
8
|
+
* does (`../../ci-comment-commands.ts`): a refusal, a command no job runs,
|
|
9
|
+
* or the re-run of a merged pull request's apply. The words are the
|
|
10
|
+
* product's, as its bin set them.
|
|
11
|
+
*
|
|
12
|
+
* It runs at the target branch's commit with the job's token
|
|
13
|
+
* (`GITHUB_TOKEN`), so none of the change's code runs here, and it loads no
|
|
14
|
+
* plugins.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { readFileSync } from "node:fs";
|
|
18
|
+
import { activeProductWords } from "../../ci-product-words";
|
|
19
|
+
import { answerProductComment, COMMENT_JOBS_ENV, commentRuns, type CommentBeforeMerge, type CommentJobs } from "../../ci-comment-commands";
|
|
20
|
+
import type { WavesBeforeMergeJobs } from "../../op/before-merge-decide";
|
|
21
|
+
import { PR_APPLY_REQUIRES } from "../../pr-requires";
|
|
22
|
+
import { forgeFromEnv, forgeTargetFromEnv, type PrForge } from "../../pr-forge";
|
|
23
|
+
import { forgeReadsFor } from "../../pr-forge-reads";
|
|
24
|
+
import { formatError, formatInfo } from "../format";
|
|
25
|
+
import type { CommandContext } from "../registry";
|
|
26
|
+
|
|
27
|
+
const fail = (message: string): number => {
|
|
28
|
+
console.error(formatError({ message }));
|
|
29
|
+
return 1;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
/** The jobs named in {@link COMMENT_JOBS_ENV}: each a boolean, `targets` a list of names, and anything else is refused. */
|
|
33
|
+
export function commentJobsFromEnv(raw: string | undefined): CommentJobs {
|
|
34
|
+
if (raw === undefined || raw.trim() === "") return {};
|
|
35
|
+
const v: unknown = JSON.parse(raw);
|
|
36
|
+
if (typeof v !== "object" || v === null || Array.isArray(v)) throw new Error(`${COMMENT_JOBS_ENV} is a JSON object of the jobs the pipeline has`);
|
|
37
|
+
const known = new Set(["preview", "applyBeforeMerge", "applyOnMerge", "locks", "agent", "commits", "actions", "skipForks", "targets", "noPlanFlags", "waves", "wavesBeforeMerge"]);
|
|
38
|
+
const jobs: Record<string, unknown> = {};
|
|
39
|
+
for (const [k, x] of Object.entries(v)) {
|
|
40
|
+
if (!known.has(k)) throw new Error(`${COMMENT_JOBS_ENV} names ${JSON.stringify(k)}, which is not one of ${[...known].join(", ")}`);
|
|
41
|
+
// #4984: the waves before merge.
|
|
42
|
+
if (k === "wavesBeforeMerge") {
|
|
43
|
+
jobs.wavesBeforeMerge = wavesBeforeMergeOf(x);
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
// #4979: the waves' op and count, for a wave stop on a re-run.
|
|
47
|
+
if (k === "waves") {
|
|
48
|
+
const w = x as { op?: unknown; count?: unknown } | null;
|
|
49
|
+
if (!w || typeof w !== "object" || typeof w.op !== "string" || !/^[A-Za-z0-9][A-Za-z0-9_.-]{0,127}$/.test(w.op) || !Number.isInteger(w.count) || (w.count as number) < 1) throw new Error(`${COMMENT_JOBS_ENV}.waves is { op, count }: the waves' op name and how many waves there are`);
|
|
50
|
+
jobs.waves = { op: w.op, count: w.count };
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
if (k === "targets") {
|
|
54
|
+
if (!Array.isArray(x) || x.some((t) => typeof t !== "string" || !/^[A-Za-z0-9][A-Za-z0-9_-]*$/.test(t))) throw new Error(`${COMMENT_JOBS_ENV}.targets is a list of target names`);
|
|
55
|
+
if (x.length > 0) jobs.targets = x;
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
if (typeof x !== "boolean") throw new Error(`${COMMENT_JOBS_ENV}.${k} is true or false`);
|
|
59
|
+
if (x) jobs[k] = true;
|
|
60
|
+
}
|
|
61
|
+
if (jobs.wavesBeforeMerge && !jobs.waves) throw new Error(`${COMMENT_JOBS_ENV}.wavesBeforeMerge needs waves: { op, count }, the waves it starts`);
|
|
62
|
+
return jobs as CommentJobs;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** {@link COMMENT_JOBS_ENV}'s `wavesBeforeMerge` (#4984), each field checked, since the comment job pushes and dispatches with what it names. */
|
|
66
|
+
export function wavesBeforeMergeOf(x: unknown): WavesBeforeMergeJobs {
|
|
67
|
+
const what = `${COMMENT_JOBS_ENV}.wavesBeforeMerge`;
|
|
68
|
+
const o = x as Partial<WavesBeforeMergeJobs> | null;
|
|
69
|
+
if (!o || typeof o !== "object" || Array.isArray(o)) throw new Error(`${what} is { workflow?, requires?, plan, pipelineFiles, locks? }`);
|
|
70
|
+
const strings = (v: unknown): v is string[] => Array.isArray(v) && v.every((s) => typeof s === "string" && s.trim() !== "" && !/[\r\n]/.test(s));
|
|
71
|
+
if (o.workflow !== undefined && (typeof o.workflow !== "string" || !/^[A-Za-z0-9][A-Za-z0-9._-]*\.ya?ml$/.test(o.workflow))) throw new Error(`${what}.workflow is a workflow file name, like deploy.yml`);
|
|
72
|
+
if (o.requires !== undefined && (!Array.isArray(o.requires) || o.requires.some((r) => !(PR_APPLY_REQUIRES as readonly string[]).includes(r)))) throw new Error(`${what}.requires is a list of ${PR_APPLY_REQUIRES.join(", ")}`);
|
|
73
|
+
if (!strings(o.plan)) throw new Error(`${what}.plan is the list of plan statuses that must pass on the head`);
|
|
74
|
+
if (!strings(o.pipelineFiles)) throw new Error(`${what}.pipelineFiles is the list of paths a change may not touch`);
|
|
75
|
+
if (o.locks !== undefined && (typeof o.locks !== "object" || o.locks === null || (o.locks.gate !== undefined && (typeof o.locks.gate !== "string" || !/^[A-Za-z0-9][A-Za-z0-9_.-]{0,127}$/.test(o.locks.gate))))) throw new Error(`${what}.locks is { gate? }`);
|
|
76
|
+
return {
|
|
77
|
+
...(o.workflow ? { workflow: o.workflow } : {}),
|
|
78
|
+
...(o.requires ? { requires: [...o.requires] } : {}),
|
|
79
|
+
plan: [...o.plan],
|
|
80
|
+
pipelineFiles: [...o.pipelineFiles],
|
|
81
|
+
...(o.locks ? { locks: { ...(o.locks.gate ? { gate: o.locks.gate } : {}) } } : {}),
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* What the decision before merge reads and writes with (#4984), in the
|
|
87
|
+
* comment job (GitHub, Forgejo) and the note poll (GitLab): the requires
|
|
88
|
+
* and statuses through the job's client, git in the checkout of the
|
|
89
|
+
* default branch, the reach line's locks at stage apply, and the decision
|
|
90
|
+
* and the wave stop on this checkout's `chant/lifecycle`.
|
|
91
|
+
*/
|
|
92
|
+
export async function beforeMergeDeps(forge: PrForge, jobs: CommentJobs, env: NodeJS.ProcessEnv = process.env): Promise<CommentBeforeMerge> {
|
|
93
|
+
const bm = jobs.wavesBeforeMerge!;
|
|
94
|
+
const op = jobs.waves!.op;
|
|
95
|
+
const { spawnSync } = await import("node:child_process");
|
|
96
|
+
const { checkPrRequires, unmetRequires } = await import("../../pr-requires");
|
|
97
|
+
const { productStatusContext, activeProductWords } = await import("../../ci-product-words");
|
|
98
|
+
const { LOCK_REACH_ENV, reachedTargets } = await import("../../lifecycle/reach-locks");
|
|
99
|
+
const { takeTargetLocks, describeHeldTargetLocks } = await import("../../lifecycle/target-lock");
|
|
100
|
+
const { recordBeforeMerge } = await import("../../op/before-merge-store");
|
|
101
|
+
const { setWaveStop } = await import("../../op/wave-stop");
|
|
102
|
+
const { PR_APPLY_GATE } = await import("../../pr-loop");
|
|
103
|
+
const words = activeProductWords();
|
|
104
|
+
const line = env[LOCK_REACH_ENV];
|
|
105
|
+
const name = (n: number) => (forge.kind === "gitlab" ? `!${n}` : `pull request ${n}`);
|
|
106
|
+
return {
|
|
107
|
+
// The plan and apply statuses never hold the apply back: the plan status is asked for by name.
|
|
108
|
+
requires: async (pr, head) => unmetRequires(await checkPrRequires(forge, pr, head, { ignore: [productStatusContext(words, "apply"), productStatusContext(words, "plan"), `${productStatusContext(words, "plan")}/`], ...(bm.requires ? { only: bm.requires } : {}) })),
|
|
109
|
+
statuses: async (sha) => (await forge.commitStatuses?.(sha)) ?? [],
|
|
110
|
+
git: (argv, o) => {
|
|
111
|
+
const r = spawnSync(argv[0]!, argv.slice(1), { encoding: "utf8", ...(o.cwd ? { cwd: o.cwd } : {}) });
|
|
112
|
+
return { status: r.status, stdout: r.stdout ?? "", stderr: r.error ? r.error.message : (r.stderr ?? "") };
|
|
113
|
+
},
|
|
114
|
+
// #4979's reach line says what the change reaches; the locks go up at stage apply, refused while another holds one.
|
|
115
|
+
...(line && line.trim()
|
|
116
|
+
? {
|
|
117
|
+
lock: async (pr: number, head: string, base: string, by: string) => {
|
|
118
|
+
const reached = reachedTargets({ forge: forge.kind, pr, head, base, line });
|
|
119
|
+
if ("error" in reached) throw new Error(reached.error);
|
|
120
|
+
if ("moved" in reached) return { ok: false as const, text: `${name(pr)} moved while this comment was read, so nothing is ${words.verbs.apply[1]}; comment again once its checks pass` };
|
|
121
|
+
const isOpen = forge.pullRequestOpen?.bind(forge);
|
|
122
|
+
const r = await takeTargetLocks(bm.locks?.gate ?? PR_APPLY_GATE, reached.targets, { pr, by, at: new Date().toISOString(), stage: "apply", head }, { ...(isOpen ? { isOpen } : {}) });
|
|
123
|
+
if (!r.ok) {
|
|
124
|
+
const request = forge.kind === "gitlab" ? "merge request" : "pull request";
|
|
125
|
+
return { ok: false as const, text: `${describeHeldTargetLocks(r.held, name)}, so ${name(pr)} is not ${words.verbs.apply[1]}. It ${words.verbs.apply[0]}s once that ${request} merges or closes, or someone with write access unlocks it` };
|
|
126
|
+
}
|
|
127
|
+
return { ok: true as const, targets: r.taken };
|
|
128
|
+
},
|
|
129
|
+
}
|
|
130
|
+
: {}),
|
|
131
|
+
record: (d) => recordBeforeMerge(op, d),
|
|
132
|
+
stop: async (head, through) => {
|
|
133
|
+
await setWaveStop(op, head, through === null ? null : { through, at: new Date().toISOString() });
|
|
134
|
+
},
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export async function runComponentsPrComment(ctx: CommandContext): Promise<number> {
|
|
139
|
+
const { args } = ctx;
|
|
140
|
+
const kind = args.forge;
|
|
141
|
+
if (kind !== "github" && kind !== "forgejo") return fail("pr-comment answers a GitHub or Forgejo comment: --forge github|forgejo (GitLab's notes are polled by pr-notes)");
|
|
142
|
+
const env = process.env;
|
|
143
|
+
const eventPath = env.GITHUB_EVENT_PATH;
|
|
144
|
+
if (!eventPath) return fail("pr-comment reads the comment from the event file, and GITHUB_EVENT_PATH is not set");
|
|
145
|
+
let event: unknown;
|
|
146
|
+
let jobs: CommentJobs;
|
|
147
|
+
let poster: PrForge;
|
|
148
|
+
let target: ReturnType<typeof forgeTargetFromEnv>;
|
|
149
|
+
try {
|
|
150
|
+
event = JSON.parse(readFileSync(eventPath, "utf8"));
|
|
151
|
+
jobs = commentJobsFromEnv(env[COMMENT_JOBS_ENV]);
|
|
152
|
+
poster = forgeFromEnv(kind, env);
|
|
153
|
+
target = forgeTargetFromEnv(env, { kind });
|
|
154
|
+
} catch (err) {
|
|
155
|
+
return fail(err instanceof Error ? err.message : String(err));
|
|
156
|
+
}
|
|
157
|
+
const repository = (event as { repository?: { default_branch?: unknown } } | null)?.repository;
|
|
158
|
+
const base = args.branch ?? (typeof repository?.default_branch === "string" ? repository.default_branch : undefined);
|
|
159
|
+
if (!base) return fail("pr-comment needs the default branch: --branch <name>, or repository.default_branch in the event");
|
|
160
|
+
const outcome = await answerProductComment({
|
|
161
|
+
forge: kind,
|
|
162
|
+
event,
|
|
163
|
+
repo: target.repo,
|
|
164
|
+
reads: forgeReadsFor(target),
|
|
165
|
+
poster,
|
|
166
|
+
runs: commentRuns({ apiBase: target.apiBase, repo: target.repo, token: target.token }),
|
|
167
|
+
words: activeProductWords(),
|
|
168
|
+
base,
|
|
169
|
+
jobs,
|
|
170
|
+
env,
|
|
171
|
+
// #4984: the decision before merge, its record and its wave stop on this checkout's chant/lifecycle.
|
|
172
|
+
...(jobs.wavesBeforeMerge ? { beforeMerge: await beforeMergeDeps(poster, jobs, env) } : {}),
|
|
173
|
+
// #4979: the wave stop goes on this checkout's chant/lifecycle, which the job pushes with its token.
|
|
174
|
+
...(jobs.waves
|
|
175
|
+
? {
|
|
176
|
+
stops: async (op, sha, stop) => {
|
|
177
|
+
const { setWaveStop } = await import("../../op/wave-stop");
|
|
178
|
+
await setWaveStop(op, sha, stop);
|
|
179
|
+
},
|
|
180
|
+
}
|
|
181
|
+
: {}),
|
|
182
|
+
});
|
|
183
|
+
const line = `pr-comment: ${outcome.reason}`;
|
|
184
|
+
if (outcome.fail) return fail(line);
|
|
185
|
+
console.error(formatInfo(line));
|
|
186
|
+
return 0;
|
|
187
|
+
}
|
|
@@ -74,11 +74,14 @@ import {
|
|
|
74
74
|
import { forgePrEnvPublisher, lifecyclePrEnvPorts } from "../../components/pr-env-ports";
|
|
75
75
|
import { applyPrSet, type PrPlanSet } from "../../components/pr-run";
|
|
76
76
|
import { prOp } from "../../pr-loop";
|
|
77
|
-
import { FORGE_KINDS,
|
|
77
|
+
import { FORGE_KINDS, forgePrincipalOf, type ForgeKind, type PrForge } from "../../pr-forge";
|
|
78
|
+
// #4964: a status for a pull_request run's merge preview goes on the pull request's head.
|
|
79
|
+
import { forgeFromJobEnv } from "../../pr-forge-job";
|
|
78
80
|
import { formatError, formatInfo, formatWarning } from "../format";
|
|
79
81
|
import { withComponentEndpoint } from "../component-endpoint";
|
|
80
82
|
import type { CommandContext } from "../registry";
|
|
81
83
|
import type { Prepared } from "./pr";
|
|
84
|
+
import { actorFromEnv } from "../../actor";
|
|
82
85
|
|
|
83
86
|
const USAGE = "chant components pr-env up --base <ref> --pr <n> [--no-push] | post --pr <n> --head <sha> | down --pr <n> [--reason closed|expired] | sweep";
|
|
84
87
|
|
|
@@ -102,14 +105,14 @@ function forgeOf(ctx: CommandContext): PrForge | undefined | number {
|
|
|
102
105
|
if (kind === undefined || ctx.args.noStatus) return undefined;
|
|
103
106
|
if (!(FORGE_KINDS as readonly string[]).includes(kind)) return fail(`--forge ${kind} is not one of ${FORGE_KINDS.join(", ")}`);
|
|
104
107
|
try {
|
|
105
|
-
return
|
|
108
|
+
return forgeFromJobEnv(kind as ForgeKind);
|
|
106
109
|
} catch (err) {
|
|
107
110
|
return fail(err instanceof Error ? err.message : String(err));
|
|
108
111
|
}
|
|
109
112
|
}
|
|
110
113
|
|
|
111
114
|
function actor(): string {
|
|
112
|
-
return process.env
|
|
115
|
+
return actorFromEnv(process.env, "chant");
|
|
113
116
|
}
|
|
114
117
|
|
|
115
118
|
function memberOf(ctx: CommandContext): string | undefined {
|
|
@@ -12,6 +12,8 @@
|
|
|
12
12
|
import { resolve } from "node:path";
|
|
13
13
|
import { activeProductWords } from "../../ci-product-words";
|
|
14
14
|
import { chantNoteRuns, gitlabPipelines, ledgerNoteLog, pollNoteCommands } from "../../ci-note-commands";
|
|
15
|
+
import { COMMENT_JOBS_ENV, type CommentJobs } from "../../ci-comment-commands";
|
|
16
|
+
import { beforeMergeDeps, commentJobsFromEnv } from "./pr-comment";
|
|
15
17
|
import { forgeFromEnv, forgeTargetFromEnv, type PrForge } from "../../pr-forge";
|
|
16
18
|
import { forgeReadsFor } from "../../pr-forge-reads";
|
|
17
19
|
import { formatError, formatInfo, formatWarning } from "../format";
|
|
@@ -41,20 +43,42 @@ export async function runComponentsPrNotes(ctx: CommandContext): Promise<number>
|
|
|
41
43
|
// The ledger keeps the notes answered: read it as the remote has it.
|
|
42
44
|
await fetchLifecycle({ cwd });
|
|
43
45
|
const words = activeProductWords();
|
|
46
|
+
// #4984: the waves' op and count, and the waves before merge, as the pipeline wrote them in CHANT_COMMENT_JOBS.
|
|
47
|
+
let more: CommentJobs;
|
|
48
|
+
try {
|
|
49
|
+
more = commentJobsFromEnv(env[COMMENT_JOBS_ENV]);
|
|
50
|
+
} catch (err) {
|
|
51
|
+
return fail(err instanceof Error ? err.message : String(err));
|
|
52
|
+
}
|
|
53
|
+
const beforeMerge = more.wavesBeforeMerge && more.waves ? await beforeMergeDeps(forge, more, env) : undefined;
|
|
44
54
|
const polled = await pollNoteCommands({
|
|
45
55
|
reads: forgeReadsFor(target),
|
|
46
56
|
forge,
|
|
47
57
|
pipelines: gitlabPipelines({ apiBase: target.apiBase, project: target.repo, token: target.token, host: target.host, ...(target.tokenHeader ? { tokenHeader: target.tokenHeader } : {}) }),
|
|
48
58
|
words,
|
|
49
59
|
base,
|
|
50
|
-
runs: chantNoteRuns(
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
60
|
+
runs: chantNoteRuns(
|
|
61
|
+
{
|
|
62
|
+
...(args.previewComment ? { preview: true } : {}),
|
|
63
|
+
...(args.applyBeforeMerge ? { applyBeforeMerge: true } : {}),
|
|
64
|
+
...(args.applyOnMerge ? { applyOnMerge: true } : {}),
|
|
65
|
+
...(args.locks ? { locks: true } : {}),
|
|
66
|
+
...(more.waves ? { waves: more.waves } : {}),
|
|
67
|
+
...(more.wavesBeforeMerge ? { wavesBeforeMerge: more.wavesBeforeMerge } : {}),
|
|
68
|
+
},
|
|
69
|
+
beforeMerge ? { beforeMerge } : {},
|
|
70
|
+
),
|
|
56
71
|
log: ledgerNoteLog({ cwd }),
|
|
57
72
|
env,
|
|
73
|
+
// #4984: a merged merge request's wave-<n> stops the retried waves after it.
|
|
74
|
+
...(more.waves
|
|
75
|
+
? {
|
|
76
|
+
stops: async (op, sha, stop) => {
|
|
77
|
+
const { setWaveStop } = await import("../../op/wave-stop");
|
|
78
|
+
await setWaveStop(op, sha, stop, { cwd });
|
|
79
|
+
},
|
|
80
|
+
}
|
|
81
|
+
: {}),
|
|
58
82
|
});
|
|
59
83
|
let failed = polled.fail !== undefined;
|
|
60
84
|
for (const o of polled.outcomes) {
|
|
@@ -14,7 +14,7 @@ import { afterEach, beforeEach, describe, expect, test, vi } from "vitest";
|
|
|
14
14
|
import type { DriverComponent } from "../../components/driver";
|
|
15
15
|
import type { DeployContext } from "../../components/capability";
|
|
16
16
|
import type { ParsedArgs } from "../registry";
|
|
17
|
-
import { prStatusState } from "../../pr-
|
|
17
|
+
import { prStatusState } from "../../pr-status";
|
|
18
18
|
|
|
19
19
|
const HEAD = "a".repeat(40);
|
|
20
20
|
const BASE = "b".repeat(40);
|
package/src/cli/handlers/pr.ts
CHANGED
|
@@ -105,9 +105,7 @@ import {
|
|
|
105
105
|
prApproveCommands,
|
|
106
106
|
prNoteMarker,
|
|
107
107
|
prOp,
|
|
108
|
-
prStatusDescription,
|
|
109
108
|
prStatusContext,
|
|
110
|
-
prStatusState,
|
|
111
109
|
renderPrNote,
|
|
112
110
|
type PrApproval,
|
|
113
111
|
type PrBeforeMerge,
|
|
@@ -119,7 +117,10 @@ import {
|
|
|
119
117
|
type PrRound,
|
|
120
118
|
type PrOverdue,
|
|
121
119
|
} from "../../pr-loop";
|
|
120
|
+
import { prStatusDescription, prStatusState } from "../../pr-status";
|
|
122
121
|
import { FORGE_KINDS, forgeFromEnv, forgePrincipalOf, type ForgeKind, type PrForge } from "../../pr-forge";
|
|
122
|
+
// #4964: a status for a pull_request run's merge preview goes on the pull request's head.
|
|
123
|
+
import { forgeFromJobEnv } from "../../pr-forge-job";
|
|
123
124
|
import { GITHUB_COMMENT_LIMIT, GITLAB_NOTE_LIMIT } from "../../plan-summary";
|
|
124
125
|
import { upsertPlanNote } from "../../pr-post";
|
|
125
126
|
import { activeProductWords, commandWord, parseProductComment, productContext } from "../../ci-product-words";
|
|
@@ -146,6 +147,7 @@ import type { OpWaveHookMoment } from "../../op/op-waves";
|
|
|
146
147
|
import type { PrHookOutcome } from "../../pr-loop";
|
|
147
148
|
import type { PrMigrationFile } from "../../pr-migrations";
|
|
148
149
|
import { lexiconNames } from "../../lexicon-module";
|
|
150
|
+
import { actorFromEnv } from "../../actor";
|
|
149
151
|
|
|
150
152
|
|
|
151
153
|
/** Where the reports land unless `--output` says. */
|
|
@@ -247,7 +249,7 @@ export async function prepare(ctx: CommandContext, stage: "plan" | "apply" | "re
|
|
|
247
249
|
let forge: PrForge | undefined;
|
|
248
250
|
if (args.forge && !(stage === "plan" && args.noStatus)) {
|
|
249
251
|
try {
|
|
250
|
-
forge =
|
|
252
|
+
forge = forgeFromJobEnv(args.forge as ForgeKind);
|
|
251
253
|
} catch (err) {
|
|
252
254
|
return fail(err instanceof Error ? err.message : String(err));
|
|
253
255
|
}
|
|
@@ -1404,7 +1406,7 @@ async function mergeAfterUpdate(ctx: CommandContext, p: Prepared, pr: number): P
|
|
|
1404
1406
|
}
|
|
1405
1407
|
let forge: PrForge;
|
|
1406
1408
|
try {
|
|
1407
|
-
forge =
|
|
1409
|
+
forge = forgeFromJobEnv(kind, env);
|
|
1408
1410
|
} catch (err) {
|
|
1409
1411
|
console.error(formatWarning({ message: `the pull request was not merged: ${err instanceof Error ? err.message : String(err)}` }));
|
|
1410
1412
|
return CHANT_EXIT.waiting;
|
|
@@ -1481,7 +1483,7 @@ async function beforeMergeChecks(ctx: CommandContext): Promise<PrBeforeMerge | n
|
|
|
1481
1483
|
let head: string;
|
|
1482
1484
|
let base: string;
|
|
1483
1485
|
try {
|
|
1484
|
-
forge =
|
|
1486
|
+
forge = forgeFromJobEnv(args.forge as ForgeKind);
|
|
1485
1487
|
head = await resolveCommit(cwd, args.head ?? "HEAD");
|
|
1486
1488
|
base = await resolveMergeBase(cwd, args.base, head);
|
|
1487
1489
|
} catch (err) {
|
|
@@ -1507,8 +1509,12 @@ async function beforeMergeChecks(ctx: CommandContext): Promise<PrBeforeMerge | n
|
|
|
1507
1509
|
// plywood#66: the forge also reports the pull-request pipeline's plan job, `chant-pr.<member>.<env> / plan (<event>)`, which a denial fails too.
|
|
1508
1510
|
const planJob = [`chant-pr.${member ?? "*"}.${ctx.args.env ?? "*"} / plan*`];
|
|
1509
1511
|
const ignore = [...new Set([productContext(activeProductWords(), gate), productContext(activeProductWords(), PR_APPLY_GATE), `chant/${gate}`, `chant/${PR_APPLY_GATE}`, prStatusContext("apply", member), prStatusContext("plan"), `${prStatusContext("plan")}/`, ...planJob])];
|
|
1512
|
+
// #4966: the `checks` require waits for the ref gate's status too, when the policy at base has a rule for the target branch.
|
|
1513
|
+
const refGate = await beforeMergeRefGate(cwd, args.base, args.branch);
|
|
1514
|
+
if ("problem" in refGate) return fail(refGate.problem);
|
|
1515
|
+
if (refGate.note) console.error(formatInfo(refGate.note));
|
|
1510
1516
|
// ws-106 gives the declaration no way to leave a check out, so with no --requires all four are asked (#4336, #4607).
|
|
1511
|
-
const requires = await checkPrRequires(forge, args.pr, head, { ignore, ...(only ? { only: only.checks } : {}) });
|
|
1517
|
+
const requires = await checkPrRequires(forge, args.pr, head, { ignore, ...(only ? { only: only.checks } : {}), ...(refGate.require.length > 0 ? { require: refGate.require } : {}) });
|
|
1512
1518
|
for (const r of requires) console.error(formatInfo(`${r.name}: ${r.passed ? "passed" : r.pending ? "pending" : "unmet"}, ${r.reason}`));
|
|
1513
1519
|
const unmet = unmetRequires(requires);
|
|
1514
1520
|
if (unmet) {
|
|
@@ -1517,6 +1523,38 @@ async function beforeMergeChecks(ctx: CommandContext): Promise<PrBeforeMerge | n
|
|
|
1517
1523
|
return { requires };
|
|
1518
1524
|
}
|
|
1519
1525
|
|
|
1526
|
+
/**
|
|
1527
|
+
* The branch an apply before merge lands on (#4966): `--branch`, else the
|
|
1528
|
+
* pull request's target as its job names it, else the branch the job runs
|
|
1529
|
+
* on, which for the generated apply job is the target branch (an
|
|
1530
|
+
* `issue_comment` run on GitHub and Forgejo, a target-branch pipeline on
|
|
1531
|
+
* GitLab).
|
|
1532
|
+
*/
|
|
1533
|
+
export function beforeMergeBranch(explicit: string | undefined, env: Record<string, string | undefined> = process.env): string | undefined {
|
|
1534
|
+
for (const v of [explicit, env.GITHUB_BASE_REF, env.CI_MERGE_REQUEST_TARGET_BRANCH_NAME, env.CI_COMMIT_BRANCH, env.GITHUB_REF_NAME]) {
|
|
1535
|
+
if (v && v.trim()) return v.trim();
|
|
1536
|
+
}
|
|
1537
|
+
return undefined;
|
|
1538
|
+
}
|
|
1539
|
+
|
|
1540
|
+
/**
|
|
1541
|
+
* The statuses an apply before merge waits for beside the forge's own
|
|
1542
|
+
* (#4966): the ref gate's status for the target branch, as the policy at
|
|
1543
|
+
* `base` sets it (`refGateRulesAt`), passed as `require` to the `checks`
|
|
1544
|
+
* require, so `checks` does not pass before the `ref-gate` job posted it.
|
|
1545
|
+
* No rule for the branch requires nothing; a policy that can't be read is
|
|
1546
|
+
* a problem, and the apply stops.
|
|
1547
|
+
*/
|
|
1548
|
+
export async function beforeMergeRefGate(cwd: string, base: string, branch: string | undefined, env: Record<string, string | undefined> = process.env): Promise<{ require: string[]; note?: string } | { problem: string }> {
|
|
1549
|
+
const target = beforeMergeBranch(branch, env);
|
|
1550
|
+
if (!target) return { require: [], note: "the job names no target branch (--branch), so the ref gate's status is not waited for" };
|
|
1551
|
+
const { refGateRulesAt } = await import("../../ref-gate-rules");
|
|
1552
|
+
const rules = refGateRulesAt(cwd, { ref: `refs/heads/${target}`, base });
|
|
1553
|
+
if (rules.problems.length > 0) return { problem: `the trust policy at base can't be read, so the apply before merge can't tell which ref gate status to wait for: ${rules.problems.join("; ")}. Nothing was applied.` };
|
|
1554
|
+
if (!rules.matched || !rules.status) return { require: [] };
|
|
1555
|
+
return { require: [rules.status], note: `the checks require waits for ${rules.status}, the ref gate's status for refs/heads/${target}` };
|
|
1556
|
+
}
|
|
1557
|
+
|
|
1520
1558
|
/** The refusal report of an apply before merge stopped before it planned (#4301): nothing selected, nothing planned. */
|
|
1521
1559
|
function earlyStop(ctx: CommandContext, forge: PrForge, at: { pr: number; base: string; head: string; gate: string; member?: string }) {
|
|
1522
1560
|
return async (beforeMerge: PrBeforeMerge, refusal: "requires-unmet" | "before-merge-off", message: string, code: number): Promise<number> => {
|
|
@@ -1538,7 +1576,7 @@ function earlyStop(ctx: CommandContext, forge: PrForge, at: { pr: number; base:
|
|
|
1538
1576
|
async function takeApplyLocks(p: Prepared, pr: number, targets: readonly string[] = p.plan.order): Promise<string | null | number> {
|
|
1539
1577
|
const { takeTargetLocks, describeHeldTargetLocks } = await import("../../lifecycle/target-lock");
|
|
1540
1578
|
const isOpen = p.forge?.pullRequestOpen?.bind(p.forge);
|
|
1541
|
-
const by =
|
|
1579
|
+
const by = actorFromEnv();
|
|
1542
1580
|
let result;
|
|
1543
1581
|
try {
|
|
1544
1582
|
result = await takeTargetLocks(p.gate, targets, { pr, by, at: new Date().toISOString(), stage: "apply", head: p.head }, { ...(isOpen ? { isOpen } : {}) });
|
|
@@ -2778,7 +2816,7 @@ function writeWaveChangeSet(ctx: CommandContext, wave: number, doc: PrPlanSet["d
|
|
|
2778
2816
|
}
|
|
2779
2817
|
|
|
2780
2818
|
/**
|
|
2781
|
-
* chant components pr-post --pr <n> --head <sha> --env <env> --forge <kind> [--member <name>] [--output <dir>] [--result <result>] (#4295)
|
|
2819
|
+
* chant components pr-post --pr <n> --head <sha> --env <env> --forge <kind> [--member <name>] [--output <dir>] [--result <result>] [--not-affected <argument>] (#4295, #4963)
|
|
2782
2820
|
* chant components pr-post --open --env <env> --forge gitlab [--branch <branch>] [--member <name>] [--output <dir>] (#4328)
|
|
2783
2821
|
*
|
|
2784
2822
|
* Post the plan note and the `chant/plan` status from the report a plan job
|
|
@@ -2799,7 +2837,7 @@ export async function runComponentsPrPost(ctx: CommandContext): Promise<number>
|
|
|
2799
2837
|
if (args.members && args.members.length > 1) return fail(`pr-post takes one --member, not ${args.members.join(", ")}`);
|
|
2800
2838
|
let forge: PrForge;
|
|
2801
2839
|
try {
|
|
2802
|
-
forge =
|
|
2840
|
+
forge = forgeFromJobEnv(args.forge as ForgeKind);
|
|
2803
2841
|
} catch (err) {
|
|
2804
2842
|
return fail(err instanceof Error ? err.message : String(err));
|
|
2805
2843
|
}
|
|
@@ -2823,6 +2861,8 @@ export async function runComponentsPrPost(ctx: CommandContext): Promise<number>
|
|
|
2823
2861
|
...(args.forge !== "gitlab" && process.env.GITHUB_STEP_SUMMARY ? { summaryFile: process.env.GITHUB_STEP_SUMMARY } : {}),
|
|
2824
2862
|
// #4899: the product plan job's run record, kept on chant/lifecycle with the note.
|
|
2825
2863
|
...(args.recordRun ? { recordRun: await planRunRecorder(args.forge as ForgeKind, args.recordRun) } : {}),
|
|
2864
|
+
// #4963: a re-plan narrowed to an argument the change does not reach gets a reply in place of the note.
|
|
2865
|
+
...(args.notAffected ? { notAffected: args.notAffected } : {}),
|
|
2826
2866
|
});
|
|
2827
2867
|
for (const message of posted.warnings) console.error(formatWarning({ message }));
|
|
2828
2868
|
if (posted.refused) console.error(formatWarning({ message: `the plan report was not used: ${posted.refused}` }));
|
|
@@ -2895,7 +2935,8 @@ async function descriptionCheckOf(ctx: CommandContext, forge: PrForge): Promise<
|
|
|
2895
2935
|
* `--preview-comment`, and set its plan status back to pending
|
|
2896
2936
|
* (`markStaleNotes`, ../../pr-post.ts). The branch is `--branch`, else the
|
|
2897
2937
|
* job's (`GITHUB_REF_NAME`, `CI_COMMIT_BRANCH`). It exits 0 once it has
|
|
2898
|
-
* marked, as `pr-post` does.
|
|
2938
|
+
* marked, as `pr-post` does. `--member` given more than once (#4987, a
|
|
2939
|
+
* product plan's targets) marks each member's note in turn.
|
|
2899
2940
|
*/
|
|
2900
2941
|
async function runComponentsPrPostStale(ctx: CommandContext): Promise<number> {
|
|
2901
2942
|
const { args } = ctx;
|
|
@@ -2903,26 +2944,28 @@ async function runComponentsPrPostStale(ctx: CommandContext): Promise<number> {
|
|
|
2903
2944
|
if (!args.tip) return fail("pr-post --stale needs the target branch's commit now: --tip <sha>");
|
|
2904
2945
|
if (!args.env) return fail("pr-post needs the environment the plan was for: --env <env>");
|
|
2905
2946
|
if (!args.forge || !(FORGE_KINDS as readonly string[]).includes(args.forge)) return fail(`pr-post posts to a forge: --forge ${FORGE_KINDS.join("|")}`);
|
|
2906
|
-
if (args.members && args.members.length > 1) return fail(`pr-post takes one --member, not ${args.members.join(", ")}`);
|
|
2907
2947
|
const branch = args.branch ?? process.env.CI_COMMIT_BRANCH ?? process.env.GITHUB_REF_NAME;
|
|
2908
2948
|
if (!branch) return fail("pr-post --stale marks the notes of the pull requests into a branch: run it in a job of a push, or pass --branch <branch>");
|
|
2909
2949
|
let forge: PrForge;
|
|
2910
2950
|
try {
|
|
2911
|
-
forge =
|
|
2951
|
+
forge = forgeFromJobEnv(args.forge as ForgeKind);
|
|
2912
2952
|
} catch (err) {
|
|
2913
2953
|
return fail(err instanceof Error ? err.message : String(err));
|
|
2914
2954
|
}
|
|
2915
|
-
|
|
2955
|
+
// #4987: a product plan's targets each have their note, so --member may be given once per target.
|
|
2956
|
+
const members: Array<string | undefined> = args.members?.length ? [...new Set(args.members)] : [undefined];
|
|
2916
2957
|
const { markStaleNotes } = await import("../../pr-post");
|
|
2917
|
-
|
|
2918
|
-
|
|
2919
|
-
|
|
2920
|
-
|
|
2921
|
-
|
|
2958
|
+
for (const member of members) {
|
|
2959
|
+
let done: Awaited<ReturnType<typeof markStaleNotes>>;
|
|
2960
|
+
try {
|
|
2961
|
+
done = await markStaleNotes({ forge, branch, tip: args.tip, env: args.env, ...(member ? { member } : {}), ...(args.previewComment ? { previewComment: true } : {}) });
|
|
2962
|
+
} catch (err) {
|
|
2963
|
+
return fail(err instanceof Error ? err.message : String(err));
|
|
2964
|
+
}
|
|
2965
|
+
for (const message of done.warnings) console.error(formatWarning({ message }));
|
|
2966
|
+
const marked = done.marks.filter((m) => m.marked).map((m) => `#${m.pr}`);
|
|
2967
|
+
console.error(formatInfo(`pr-post --stale${member ? ` (${member})` : ""}: ${marked.length > 0 ? `marked ${marked.join(", ")} stale` : "no note to mark"} after ${branch} moved to ${args.tip.slice(0, 12)}`));
|
|
2922
2968
|
}
|
|
2923
|
-
for (const message of done.warnings) console.error(formatWarning({ message }));
|
|
2924
|
-
const marked = done.marks.filter((m) => m.marked).map((m) => `#${m.pr}`);
|
|
2925
|
-
console.error(formatInfo(`pr-post --stale: ${marked.length > 0 ? `marked ${marked.join(", ")} stale` : "no note to mark"} after ${branch} moved to ${args.tip.slice(0, 12)}`));
|
|
2926
2969
|
return 0;
|
|
2927
2970
|
}
|
|
2928
2971
|
|
|
@@ -72,6 +72,7 @@ import { GATED_EXIT_CODE } from "./run";
|
|
|
72
72
|
import type { CommandContext } from "../registry";
|
|
73
73
|
import { withComponentEndpoint } from "../component-endpoint";
|
|
74
74
|
import { redeployLine, releaseRollbackLine, rollbackTarget, unsettledComponents } from "../../lifecycle/mixed-environment";
|
|
75
|
+
import { actorFromEnv } from "../../actor";
|
|
75
76
|
|
|
76
77
|
const PROMOTE_USAGE =
|
|
77
78
|
"chant components promote --to <env> [--from <env>] [--allow-skip] [--release <label|digest>] [--component <name> [--digest <sha256:...>] | --digest <component>=<sha256:...> ...] [--wave-gate <gate>] [--resume <file>] [--dry-run] [--json]";
|
|
@@ -117,7 +118,7 @@ function planJson(plan: PromotionPlan, removed: Map<string, string[]>) {
|
|
|
117
118
|
}
|
|
118
119
|
|
|
119
120
|
function resolveActor(ctx: CommandContext): string | undefined {
|
|
120
|
-
return ctx.args.actor ?? process.env
|
|
121
|
+
return ctx.args.actor ?? (actorFromEnv(process.env, "") || undefined);
|
|
121
122
|
}
|
|
122
123
|
|
|
123
124
|
/**
|
|
@@ -187,4 +187,39 @@ describe("chant release cut, publish and list", () => {
|
|
|
187
187
|
},
|
|
188
188
|
240_000,
|
|
189
189
|
);
|
|
190
|
+
|
|
191
|
+
// #4965: plywood's 0.3.9 cut warned that the chant/lifecycle push was refused, tagged, and the publish found no release.
|
|
192
|
+
test(
|
|
193
|
+
"a chant/lifecycle push the remote refuses once is pushed again; one it always refuses stops the cut, untagged and non-zero",
|
|
194
|
+
() => {
|
|
195
|
+
const root = mkdtempSync(join(tmpdir(), "chant-release-cut-refused-"));
|
|
196
|
+
try {
|
|
197
|
+
const { dir, sha, remote } = project(root);
|
|
198
|
+
git(dir, "tag", `ci/green/${sha}`);
|
|
199
|
+
const hook = join(remote, "hooks", "update");
|
|
200
|
+
const cut = (label: string) => chant(dir, ["release", "cut", label, "--build", BUILD, "--yes", "--json"]);
|
|
201
|
+
|
|
202
|
+
// Always refused: no tag, exit 1, and the record stays in this checkout only.
|
|
203
|
+
writeFileSync(hook, `#!/bin/sh\necho 'fatal error in commit_refs_rules' >&2\nexit 1\n`, { mode: 0o755 });
|
|
204
|
+
const refused = cut("v1");
|
|
205
|
+
expect(refused.code, refused.stderr).toBe(1);
|
|
206
|
+
expect(refused.stderr).toContain("[release-record-not-pushed]");
|
|
207
|
+
expect(refused.stderr).toContain("chant/lifecycle was not pushed to \"origin\" after 3 tries: the remote refused each try");
|
|
208
|
+
expect(refused.stdout).toBe("");
|
|
209
|
+
expect(hasRef(dir, "refs/tags/release/v1")).toBe(false);
|
|
210
|
+
expect(hasRef(remote, "refs/heads/chant/lifecycle")).toBe(false);
|
|
211
|
+
|
|
212
|
+
// Refused once: the second push lands, and the cut tags as it always has.
|
|
213
|
+
writeFileSync(hook, `#!/bin/sh\nif [ ! -f '${remote}/refused' ]; then touch '${remote}/refused'; echo 'fatal error in commit_refs_rules' >&2; exit 1; fi\nexit 0\n`, { mode: 0o755 });
|
|
214
|
+
const landed = cut("v1");
|
|
215
|
+
expect(landed.code, landed.stderr).toBe(0);
|
|
216
|
+
expect(JSON.parse(landed.stdout)).toMatchObject({ label: "v1", tag: { name: "release/v1" } });
|
|
217
|
+
expect(git(dir, "rev-parse", "release/v1^{commit}")).toBe(sha);
|
|
218
|
+
expect(git(remote, "rev-parse", "refs/heads/chant/lifecycle")).toBe(git(dir, "rev-parse", "refs/heads/chant/lifecycle"));
|
|
219
|
+
} finally {
|
|
220
|
+
rmSync(root, { recursive: true, force: true });
|
|
221
|
+
}
|
|
222
|
+
},
|
|
223
|
+
240_000,
|
|
224
|
+
);
|
|
190
225
|
});
|
|
@@ -286,7 +286,7 @@ export async function runReleaseCut(ctx: CommandContext): Promise<number> {
|
|
|
286
286
|
const { spawnTargetCompiler, ReleaseCompileError } = await import("../../components/release-compile");
|
|
287
287
|
const { cutRelease, planRelease, ReleaseCutError } = await import("../../lifecycle/release-cut");
|
|
288
288
|
const { ReleaseLabelError } = await import("../../lifecycle/release-store");
|
|
289
|
-
const {
|
|
289
|
+
const { pushLifecycleRebasing, getHeadCommit } = await import("../../lifecycle/git");
|
|
290
290
|
const { resolveCiRun } = await import("../../lifecycle/release-ledger");
|
|
291
291
|
const ws = await import("../../lifecycle/release-workstation");
|
|
292
292
|
const { detectProvenance, releasePublishTargets } = await import("../../lifecycle/release-publish");
|
|
@@ -526,7 +526,19 @@ export async function runReleaseCut(ctx: CommandContext): Promise<number> {
|
|
|
526
526
|
// release records are put where release.images names them here, so the job's next step (the hand-off to the
|
|
527
527
|
// publish job) finds them.
|
|
528
528
|
if (checkout && declaredImages.length > 0) copyImageArchives((await import("../../lifecycle/release-images")).resolveReleaseImages(declaredImages), cutCwd, cwd);
|
|
529
|
-
|
|
529
|
+
// #4965: the record must be on the remote before the release is tagged. The release workflow pushes the tag
|
|
530
|
+
// right after the cut, and a tag whose record never landed spends the label: the publish job finds no release.
|
|
531
|
+
// A refused push is tried again; one that never lands stops the cut here, untagged and non-zero.
|
|
532
|
+
let push: { pushed: boolean; pushWarning?: string };
|
|
533
|
+
try {
|
|
534
|
+
push = await pushLifecycleRebasing({ cwd, requireLanded: true });
|
|
535
|
+
} catch (err) {
|
|
536
|
+
return fail(
|
|
537
|
+
"release-record-not-pushed",
|
|
538
|
+
`the release was cut and its record did not reach the remote, so the commit was not tagged: ${err instanceof Error ? err.message : String(err)}`,
|
|
539
|
+
"Nothing was tagged, so the label is not spent. Run the cut again (in CI, run the release workflow again) once the remote takes pushes to chant/lifecycle.",
|
|
540
|
+
);
|
|
541
|
+
}
|
|
530
542
|
// The tag names the release's label, which a re-cut with no label reads from the earlier cut.
|
|
531
543
|
let tagged: { name: string; created: boolean } | null = null;
|
|
532
544
|
let tagWarning: string | undefined;
|