@intentius/chant 0.124.89 → 0.124.91
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 +5 -3
- package/dist/actor.d.ts.map +1 -1
- package/dist/actor.js +7 -5
- package/dist/audit/core.d.ts.map +1 -1
- package/dist/audit/core.js +11 -1
- package/dist/ci-comment-commands.d.ts +18 -2
- package/dist/ci-comment-commands.d.ts.map +1 -1
- package/dist/ci-comment-commands.js +30 -2
- 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 +41 -1
- package/dist/ci-note-commands.d.ts.map +1 -1
- package/dist/ci-note-commands.js +64 -5
- package/dist/ci-product.d.ts +50 -1
- package/dist/ci-product.d.ts.map +1 -1
- package/dist/ci-product.js +52 -6
- package/dist/cli/handlers/pr-comment.d.ts +13 -1
- package/dist/cli/handlers/pr-comment.d.ts.map +1 -1
- package/dist/cli/handlers/pr-comment.js +90 -1
- 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 +2 -2
- package/dist/cli/handlers/pr.d.ts.map +1 -1
- package/dist/cli/handlers/pr.js +41 -20
- package/dist/cli/handlers/run-wave.d.ts.map +1 -1
- package/dist/cli/handlers/run-wave.js +154 -4
- package/dist/cli/main.d.ts.map +1 -1
- package/dist/cli/main.js +17 -0
- package/dist/cli/parse-args.d.ts.map +1 -1
- package/dist/cli/parse-args.js +28 -0
- package/dist/cli/registry.d.ts +12 -1
- package/dist/cli/registry.d.ts.map +1 -1
- package/dist/components/pr-checks.d.ts +39 -1
- package/dist/components/pr-checks.d.ts.map +1 -1
- package/dist/components/pr-checks.js +45 -2
- package/dist/components/pr-pipeline.d.ts +11 -3
- package/dist/components/pr-pipeline.d.ts.map +1 -1
- package/dist/components/pr-pipeline.js +20 -7
- package/dist/components/product-pipeline.d.ts +54 -2
- package/dist/components/product-pipeline.d.ts.map +1 -1
- package/dist/components/product-pipeline.js +63 -6
- package/dist/components/product-plan.d.ts +92 -2
- package/dist/components/product-plan.d.ts.map +1 -1
- package/dist/components/product-plan.js +172 -22
- package/dist/floor-table.data.d.ts.map +1 -1
- package/dist/floor-table.data.js +37 -23
- package/dist/lexicon-module.d.ts +2 -0
- package/dist/lexicon-module.d.ts.map +1 -1
- package/dist/lexicon-module.js +6 -2
- package/dist/lexicon.d.ts +82 -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/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 +3 -1
- package/dist/op/index.d.ts.map +1 -1
- package/dist/op/index.js +1 -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 +4 -1
- package/dist/op/op-waves-evidence-jobs.d.ts.map +1 -1
- package/dist/op/op-waves-evidence-jobs.js +10 -2
- 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-run.d.ts +146 -6
- package/dist/op/op-waves-run.d.ts.map +1 -1
- package/dist/op/op-waves-run.js +871 -99
- 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 +20 -0
- package/dist/op/op-waves.d.ts.map +1 -1
- package/dist/op/op-waves.js +15 -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 +18 -2
- 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 +4 -1
- package/dist/op/wave-stop.d.ts.map +1 -1
- package/dist/op/wave-stop.js +4 -2
- package/dist/planned-files.d.ts +16 -8
- package/dist/planned-files.d.ts.map +1 -1
- package/dist/planned-files.js +12 -8
- package/dist/pr-post.d.ts +6 -0
- package/dist/pr-post.d.ts.map +1 -1
- package/dist/pr-post.js +7 -5
- package/dist/release-floors.d.ts +9 -1
- package/dist/release-floors.d.ts.map +1 -1
- package/dist/release-floors.js +27 -19
- 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 +364 -351
- package/package.json +1 -1
- package/src/actor.test.ts +14 -1
- package/src/actor.ts +8 -6
- package/src/audit/core.ts +13 -1
- package/src/audit/first-load.test.ts +101 -0
- package/src/ci-comment-commands.test.ts +63 -0
- package/src/ci-comment-commands.ts +43 -4
- package/src/ci-image.test.ts +1 -2
- 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 +96 -7
- package/src/ci-product.ts +65 -6
- package/src/cli/handlers/pr-comment.ts +85 -2
- package/src/cli/handlers/pr-notes.ts +30 -6
- package/src/cli/handlers/pr.ts +34 -17
- package/src/cli/handlers/run-wave.ts +144 -4
- package/src/cli/main.ts +17 -0
- package/src/cli/parse-args.ts +20 -0
- package/src/cli/registry.ts +12 -1
- package/src/components/pr-checks.ts +66 -2
- package/src/components/pr-pipeline.ts +21 -9
- package/src/components/product-pipeline.apply-status.test.ts +50 -0
- package/src/components/product-pipeline.ts +117 -9
- package/src/components/product-plan-names.test.ts +135 -0
- package/src/components/product-plan.test.ts +23 -5
- package/src/components/product-plan.ts +248 -25
- package/src/floor-table.data.ts +37 -23
- package/src/lexicon-module.ts +6 -2
- package/src/lexicon.ts +78 -1
- package/src/lifecycle/gate-applied.ts +7 -0
- 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.ts +16 -1
- package/src/op/index.ts +5 -0
- package/src/op/op-waves-after-plan.ts +13 -0
- package/src/op/op-waves-evidence-jobs.ts +11 -3
- 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-render-spec.test.ts +1 -2
- package/src/op/op-waves-run.ts +971 -93
- 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 +28 -3
- package/src/op/schedule-overdue.test.ts +29 -1
- package/src/op/schedule-overdue.ts +27 -3
- package/src/op/stage-hooks.ts +52 -4
- package/src/op/wave-stop.ts +5 -3
- package/src/planned-files.test.ts +33 -0
- package/src/planned-files.ts +26 -10
- package/src/pr-post.ts +13 -5
- package/src/release-floors.ts +31 -19
- package/src/wave-blocked.ts +9 -4
|
@@ -51,6 +51,7 @@ import { PLAN_RUN_OP, PLAN_RUN_RECORD_FILE } from "../pr-plan-record";
|
|
|
51
51
|
import { idTokenVar, tradedClouds, type CloudTradeSpec } from "../ci-identity";
|
|
52
52
|
import { prNoteMarker } from "../pr-loop";
|
|
53
53
|
import { PRODUCT_MARKER_NAME } from "../pr-plan-note";
|
|
54
|
+
import { gitlabJobArtifacts, type PrCheckArtifacts } from "./pr-checks";
|
|
54
55
|
|
|
55
56
|
/** The variable the plan-note job reads the product's note words from (#4799), as JSON. Set from the pipeline, never from the report. */
|
|
56
57
|
export const PR_PLAN_NOTE_WORDS_ENV = "CHANT_PLAN_NOTE_WORDS";
|
|
@@ -163,6 +164,22 @@ export interface ProductPlanReplanJob {
|
|
|
163
164
|
notAffected?: true;
|
|
164
165
|
}
|
|
165
166
|
|
|
167
|
+
/**
|
|
168
|
+
* The one word a comment re-plan takes after the command (#4899): letters,
|
|
169
|
+
* digits and `_./@+=,:-`, and (#4984) never starting with `-`, so a flag
|
|
170
|
+
* such as `--target=x` is refused rather than read as a root. The source
|
|
171
|
+
* of a regular expression, without anchors.
|
|
172
|
+
*/
|
|
173
|
+
export const REPLAN_WORD_SOURCE = "[A-Za-z0-9_.\\/@+=,:][A-Za-z0-9_.\\/@+=,:-]*";
|
|
174
|
+
|
|
175
|
+
/** {@link REPLAN_WORD_SOURCE} anchored, as the re-plan's `node -e` program writes it between slashes. */
|
|
176
|
+
const REPLAN_WORD_JS = `^${REPLAN_WORD_SOURCE}$`;
|
|
177
|
+
|
|
178
|
+
/** Whether `word` is one a re-plan takes (#4984). */
|
|
179
|
+
export function isReplanWord(word: string): boolean {
|
|
180
|
+
return new RegExp(`^${REPLAN_WORD_SOURCE}$`).test(word);
|
|
181
|
+
}
|
|
182
|
+
|
|
166
183
|
/** The variable a comment re-plan's one argument reaches the plan verb in (#4899). Empty on a pull request's own plan. */
|
|
167
184
|
export const PLAN_ARGUMENT_ENV = "CHANT_PLAN_ARGUMENT";
|
|
168
185
|
|
|
@@ -313,7 +330,10 @@ export interface ProductPlanOptions {
|
|
|
313
330
|
* so `pr-post` asks the forge when each last ran, in its checkout of the
|
|
314
331
|
* target branch's commit, and adds the line for one that is overdue under
|
|
315
332
|
* the note's counts. They reach it as `CHANT_PLAN_WATCHES`, from the
|
|
316
|
-
* pipeline, never from the plan job's report.
|
|
333
|
+
* pipeline, never from the plan job's report. #4988: a watch's `targets`
|
|
334
|
+
* scope it to those targets' notes, such as an environment's drift
|
|
335
|
+
* watch to that environment's note; left out, every target's note checks
|
|
336
|
+
* it.
|
|
317
337
|
*/
|
|
318
338
|
watches?: ScheduledWatch[];
|
|
319
339
|
/**
|
|
@@ -352,6 +372,60 @@ export interface ProductPlanOptions {
|
|
|
352
372
|
* answer `/<product> lock` and `/<product> unlock` there too.
|
|
353
373
|
*/
|
|
354
374
|
reach?: { command: string; gate?: string };
|
|
375
|
+
/**
|
|
376
|
+
* The file the product writes the workflow to (#5003), from the
|
|
377
|
+
* repository root: on GitHub a file directly under `.github/workflows/`,
|
|
378
|
+
* on Forgejo under `.forgejo/workflows/`, on GitLab a `.yml` file, such
|
|
379
|
+
* as one the project's `.gitlab-ci.yml` includes. The generators return it as
|
|
380
|
+
* `path`. Default `<forge's workflow directory>/<workflow>.yml`, and on
|
|
381
|
+
* GitLab `.gitlab/<workflow>.gitlab-ci.yml`, with `workflow` the
|
|
382
|
+
* workflow's name.
|
|
383
|
+
*/
|
|
384
|
+
workflowFile?: string;
|
|
385
|
+
/**
|
|
386
|
+
* The plan jobs' names (#5003), so a product's required checks keep
|
|
387
|
+
* matching: `plan`, the plan job; `note`, its note job; `replan` and
|
|
388
|
+
* `replanNote`, the comment re-plan's. With `targets` each name holds
|
|
389
|
+
* `{target}`, filled with the target's name. Left out, a name is chant's:
|
|
390
|
+
* `plan`, `plan-note`, `replan`, `replan-note`, with targets
|
|
391
|
+
* `plan-{target}`, `plan-note-{target}`, `replan-{target}` and
|
|
392
|
+
* `replan-note-{target}` on GitHub and Forgejo and `{target}-plan`,
|
|
393
|
+
* `{target}-plan-note`, `{target}-replan` and `{target}-replan-note` on
|
|
394
|
+
* GitLab. A name is letters, digits, `_` and `-`, starting with a letter
|
|
395
|
+
* or `_` (on GitLab a digit too, and no top-level keyword such as
|
|
396
|
+
* `stages`), and no two jobs share one.
|
|
397
|
+
*/
|
|
398
|
+
jobNames?: { plan?: string; note?: string; replan?: string; replanNote?: string };
|
|
399
|
+
/**
|
|
400
|
+
* The plan status's context (#5003), which the note job posts
|
|
401
|
+
* (`pr-post --context`), the pending step says is pending, the stale job
|
|
402
|
+
* sets back to pending, and the apply before merge asks has passed. With
|
|
403
|
+
* `targets` it holds `{target}`. Default the words' `<product>/<plan
|
|
404
|
+
* stage>`, with targets `<product>/<plan stage>/<target>`. Letters,
|
|
405
|
+
* digits and `_./:-`.
|
|
406
|
+
*/
|
|
407
|
+
statusContext?: string;
|
|
408
|
+
/**
|
|
409
|
+
* The directory the plan verb writes into and the jobs hand on, keep as
|
|
410
|
+
* the artifact's path and post from (#5003): `{output}` in `command`
|
|
411
|
+
* and `report`, and `pr-post --output`. A path from the checkout's root
|
|
412
|
+
* that stays inside it, such as terragucci's `terragucci-report`.
|
|
413
|
+
* Default {@link PR_LOOP_REPORT_DIR}.
|
|
414
|
+
*/
|
|
415
|
+
reportDir?: string;
|
|
416
|
+
/**
|
|
417
|
+
* GitLab only (#5004): what each plan job keeps beside the report
|
|
418
|
+
* directory, as the check job's `artifacts` (#4988, {@link PrCheckArtifacts}):
|
|
419
|
+
* `paths` after it in `artifacts:paths`, and `reports` as
|
|
420
|
+
* `artifacts:reports`, such as terragucci's `{ terraform:
|
|
421
|
+
* "{output}/gitlab-terraform.json" }` for the merge request's widget.
|
|
422
|
+
* `{target}` and `{output}` are filled as in `command`. Kept when the plan
|
|
423
|
+
* fails too, as the report is. The re-plan jobs keep only the report
|
|
424
|
+
* directory: they run in a pipeline of the target branch, whose reports
|
|
425
|
+
* GitLab would read as the target branch's own. GitHub and Forgejo refuse
|
|
426
|
+
* it, since the plan verb is the job's last step there.
|
|
427
|
+
*/
|
|
428
|
+
artifacts?: PrCheckArtifacts;
|
|
355
429
|
}
|
|
356
430
|
|
|
357
431
|
/** The lock job a product plan with {@link ProductPlanOptions.reach} writes (#4979): its command and the values the command reads. */
|
|
@@ -456,17 +530,56 @@ export interface ProductPlanJob {
|
|
|
456
530
|
previous?: { marker: string; name: string };
|
|
457
531
|
/** With `record` (#4899): the plan step writes the run record, `env` its op, environment and labels as {@link PLAN_RUN_RECORD_ENV}; the note job's command records it. */
|
|
458
532
|
record?: { env: Record<string, string> };
|
|
533
|
+
/** With `statusContext` (#5003): the plan status's context, filled for the target. Absent: the words' {@link productStatusContext}. */
|
|
534
|
+
context?: string;
|
|
535
|
+
/** With `reportDir` (#5003): the directory the plan verb writes into and the jobs hand on. Absent: {@link PR_LOOP_REPORT_DIR}. */
|
|
536
|
+
reportDir?: string;
|
|
537
|
+
/** With `artifacts` (#5004), GitLab: the plan job's own paths and reports beside the report directory, `{target}` and `{output}` filled. */
|
|
538
|
+
artifacts?: PrCheckArtifacts;
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
/** The plan status's context of one plan job (#5003): its own, else the words'. */
|
|
542
|
+
export function productPlanContext(p: Pick<ProductPlanJob, "context" | "target">, words: CiProductWords): string {
|
|
543
|
+
return p.context ?? productStatusContext(words, "plan", p.target);
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
/** The directory one plan job hands on (#5003): its own, else {@link PR_LOOP_REPORT_DIR}. */
|
|
547
|
+
export function productPlanReportDir(p: Pick<ProductPlanJob, "reportDir">): string {
|
|
548
|
+
return p.reportDir ?? PR_LOOP_REPORT_DIR;
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
/** The workflow's default name (#4799): `chant-pr-<env>`. */
|
|
552
|
+
function defaultWorkflowName(env: string): string {
|
|
553
|
+
return `chant-pr-${env}`;
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
/**
|
|
557
|
+
* The file a product plan's workflow is written to (#5003),
|
|
558
|
+
* {@link ProductPlanOptions.workflowFile}: the product's, checked for the
|
|
559
|
+
* forge, else the workflow's name in the forge's workflow directory
|
|
560
|
+
* (`.gitlab/<name>.gitlab-ci.yml` on GitLab).
|
|
561
|
+
*/
|
|
562
|
+
export function productPlanWorkflowFile(forge: ForgeKind, env: string, plan: Pick<ProductPlanOptions, "workflow" | "workflowFile">): string {
|
|
563
|
+
const name = plan.workflow ?? defaultWorkflowName(env);
|
|
564
|
+
const dir = forge === "github" ? ".github/workflows" : forge === "forgejo" ? ".forgejo/workflows" : ".gitlab";
|
|
565
|
+
const file = plan.workflowFile;
|
|
566
|
+
if (file === undefined) return forge === "gitlab" ? `${dir}/${name}.gitlab-ci.yml` : `${dir}/${name}.yml`;
|
|
567
|
+
if (!/\.ya?ml$/.test(file)) throw new Error(`the product plan's workflowFile ${JSON.stringify(file)} is not a .yml or .yaml file`);
|
|
568
|
+
if (file.startsWith("/") || file.split("/").some((part) => part === "" || part === "." || part === "..") || !/^[A-Za-z0-9_.\/-]+$/.test(file)) {
|
|
569
|
+
throw new Error(`the product plan's workflowFile ${JSON.stringify(file)} is not a path from the repository root of letters, digits and _.-, inside it`);
|
|
570
|
+
}
|
|
571
|
+
if (forge !== "gitlab" && (!file.startsWith(`${dir}/`) || file.slice(dir.length + 1).includes("/"))) throw new Error(`the product plan's workflowFile ${JSON.stringify(file)} is not directly under ${dir}/, where ${forge === "github" ? "GitHub" : "Forgejo"} reads workflows`);
|
|
572
|
+
return file;
|
|
459
573
|
}
|
|
460
574
|
|
|
461
575
|
const TARGET_NAME = /^[A-Za-z0-9][A-Za-z0-9_-]*$/;
|
|
462
576
|
|
|
463
577
|
/** The pull request loop's options the product plan's jobs do not carry, and what each needs. Each is refused with `plan` (#4799). */
|
|
464
578
|
const NOT_WITH_PLAN: ReadonlyArray<[keyof PrLoopPipelineOptions, string]> = [
|
|
465
|
-
["applyBeforeMerge", "the apply before merge runs pr-apply on pr-plan's report"],
|
|
579
|
+
["applyBeforeMerge", "the apply before merge runs pr-apply on pr-plan's report; give wavesBeforeMerge to run the waves on an open pull request's head (#4984)"],
|
|
466
580
|
["applyOnMerge", "the apply on merge runs on op waves, from the waves spec"],
|
|
467
581
|
["waveGate", "the apply on merge runs on op waves, from the waves spec"],
|
|
468
582
|
["previewComment", "the comment preview re-runs pr-plan"],
|
|
469
|
-
["staleNotes", "the stale marking names one note per pipeline"],
|
|
470
583
|
["identity", "the identity trade runs before pr-plan's checkout; give the product plan's trade or login (or a target's) instead"],
|
|
471
584
|
["build", "the plan verb builds what it plans"],
|
|
472
585
|
["buildCommand", "the plan verb builds what it plans"],
|
|
@@ -508,6 +621,17 @@ export function productPlanJobs(forge: ForgeKind, env: string, loop: PrLoopPipel
|
|
|
508
621
|
seen.add(t.name);
|
|
509
622
|
}
|
|
510
623
|
const github = forge !== "gitlab";
|
|
624
|
+
// #5003: the product's own names, checked before any job is written.
|
|
625
|
+
if (plan.workflowFile !== undefined) productPlanWorkflowFile(forge, env, plan);
|
|
626
|
+
const reportDir = plan.reportDir;
|
|
627
|
+
if (reportDir !== undefined && !isReportDir(reportDir)) throw new Error(`the product plan's reportDir ${JSON.stringify(reportDir)} is not a directory from the checkout's root that stays inside it: letters, digits and _.-, parts joined by /, with no . or .. part and no / at either end`);
|
|
628
|
+
const outputDir = reportDir ?? PR_LOOP_REPORT_DIR;
|
|
629
|
+
const statusContext = plan.statusContext;
|
|
630
|
+
if (statusContext !== undefined) {
|
|
631
|
+
if (!/^[A-Za-z0-9][A-Za-z0-9_.\/:{}-]*$/.test(statusContext) || /[{}]/.test(statusContext.replaceAll("{target}", ""))) throw new Error(`the product plan's statusContext ${JSON.stringify(statusContext)} is not a status context of letters, digits and _./:-${targets ? ", with {target}" : ""}`);
|
|
632
|
+
if (Boolean(targets) !== statusContext.includes("{target}")) throw new Error(targets ? `the product plan's statusContext ${JSON.stringify(statusContext)} is every target's, so it holds {target}` : `the product plan's statusContext ${JSON.stringify(statusContext)} holds {target}, and the plan has no targets`);
|
|
633
|
+
}
|
|
634
|
+
const namesOf = productPlanJobNames(forge, plan, targets?.map((t) => t.name));
|
|
511
635
|
const shared = prLoopPassedEnv(forge, loop);
|
|
512
636
|
const jobEnv = plan.env ? prLoopPassedEnv(forge, { variables: plan.env }) : {};
|
|
513
637
|
for (const key of Object.keys(jobEnv)) {
|
|
@@ -542,6 +666,10 @@ export function productPlanJobs(forge: ForgeKind, env: string, loop: PrLoopPipel
|
|
|
542
666
|
for (const w of plan.watches ?? []) {
|
|
543
667
|
const problem = scheduledWatchProblem(w);
|
|
544
668
|
if (problem) throw new Error(`the product plan's watches: ${problem}`);
|
|
669
|
+
// #4988: a watch scoped to targets names the plan's own.
|
|
670
|
+
for (const t of w.targets ?? []) {
|
|
671
|
+
if (!seen.has(t)) throw new Error(`the product plan's watch ${w.op} names target ${t}, which the plan ${targets?.length ? "does not have" : "cannot scope to: it has no targets"}`);
|
|
672
|
+
}
|
|
545
673
|
}
|
|
546
674
|
if (new Set((plan.watches ?? []).map((w) => w.op)).size !== (plan.watches ?? []).length) throw new Error("the product plan's watches name an Op twice");
|
|
547
675
|
// The note job's variables from the pipeline: the note words, and the product's watches (#4888).
|
|
@@ -549,18 +677,24 @@ export function productPlanJobs(forge: ForgeKind, env: string, loop: PrLoopPipel
|
|
|
549
677
|
...(plan.noteWords ? { [PR_PLAN_NOTE_WORDS_ENV]: JSON.stringify(plan.noteWords) } : {}),
|
|
550
678
|
...(plan.watches?.length ? { [PLAN_WATCHES_ENV]: JSON.stringify(plan.watches) } : {}),
|
|
551
679
|
};
|
|
552
|
-
const fill = (line: string, name: string | undefined): string => line.replaceAll("{target}", name ?? env).replaceAll("{output}",
|
|
680
|
+
const fill = (line: string, name: string | undefined): string => line.replaceAll("{target}", name ?? env).replaceAll("{output}", outputDir);
|
|
553
681
|
const control = plan.controlRead ? controlNoteCheckout(forge, plan.controlRead, words) : undefined;
|
|
554
682
|
const one = (target?: ProductPlanTarget): ProductPlanJob => {
|
|
555
683
|
const name = target?.name;
|
|
556
|
-
const
|
|
557
|
-
const
|
|
684
|
+
const names = namesOf(name);
|
|
685
|
+
const jobName = names.plan;
|
|
686
|
+
const noteJobName = names.note;
|
|
687
|
+
// #5003: the product's status context, and on GitLab its plan job's name for `pr-post --open` to find.
|
|
688
|
+
const context = statusContext?.replaceAll("{target}", name ?? "");
|
|
689
|
+
const named = [...(context !== undefined ? ["--context", context] : []), ...(!github && jobName !== gitlabPlanJobName(name) ? ["--plan-job", jobName] : [])];
|
|
690
|
+
const withNames = <T extends { command: string }>(p: T): T => (named.length > 0 ? { ...p, command: `${p.command} ${named.join(" ")}` } : p);
|
|
558
691
|
const own = target ? prLoopPassedEnv(forge, { ...(target.variables ? { variables: target.variables } : {}), ...(target.secrets ? { secrets: target.secrets } : {}) }) : {};
|
|
559
692
|
for (const key of Object.keys(own)) {
|
|
560
693
|
if (key in shared) throw new Error(`target ${name}'s ${key} is the pipeline's too; give it on the target or on the pipeline`);
|
|
561
694
|
if (key in jobEnv) throw new Error(`target ${name}'s ${key} is the product plan's env too; give it once`);
|
|
562
695
|
}
|
|
563
|
-
|
|
696
|
+
// #4987: with staleNotes each target's note carries the target branch's commit, so the waves' push can mark it stale.
|
|
697
|
+
const post0 = withNames(prLoopPostJob(forge, env, name, words, { ...(loop.staleNotes ? { staleNotes: true } : {}), ...(reportDir !== undefined ? { output: reportDir } : {}) }));
|
|
564
698
|
// #4899: the note job records the plan job's run, named by that job.
|
|
565
699
|
const post1 = plan.record ? { ...post0, command: `${post0.command} --record-run ${jobName}` } : post0;
|
|
566
700
|
// #4914: on GitLab the signing job of the same pipeline keeps each merge request's evidence, which the note's checks line reads.
|
|
@@ -585,11 +719,30 @@ export function productPlanJobs(forge: ForgeKind, env: string, loop: PrLoopPipel
|
|
|
585
719
|
}
|
|
586
720
|
const idTokens = { ...(login?.idTokens ?? {}), ...tradeTokens, ...(ownTokens ?? {}) };
|
|
587
721
|
const artifact = plan.artifact ? (name ? `${plan.artifact}-${name}` : plan.artifact) : name ? `chant-pr-plan-${name}` : "chant-pr-plan";
|
|
722
|
+
// #5004: on GitLab the plan job's own paths and reports beside the report directory, such as terragucci's terraform report.
|
|
723
|
+
const given = plan.artifacts;
|
|
724
|
+
const artifacts = given
|
|
725
|
+
? gitlabJobArtifacts(
|
|
726
|
+
forge,
|
|
727
|
+
{
|
|
728
|
+
...(given.paths ? { paths: given.paths.map((p) => fill(p, name)) } : {}),
|
|
729
|
+
...(given.reports ? { reports: Object.fromEntries(Object.entries(given.reports).map(([type, p]) => [type, Array.isArray(p) ? p.map((q) => fill(q, name)) : fill(p, name)])) } : {}),
|
|
730
|
+
},
|
|
731
|
+
{ job: "the product plan", last: "the plan verb is the plan job's last step" },
|
|
732
|
+
)
|
|
733
|
+
: undefined;
|
|
588
734
|
// #4963: on GitHub and Forgejo the first re-plan job replies to the comments no other job takes.
|
|
589
735
|
const replies = github && Boolean(replanOpts.reply) && (targets === undefined || target === targets[0]);
|
|
590
736
|
const replan0 = replanComments
|
|
591
737
|
? {
|
|
592
|
-
...replanJobOf(forge, env, words, name, artifact, noteWords, {
|
|
738
|
+
...replanJobOf(forge, env, words, name, artifact, noteWords, {
|
|
739
|
+
notAffected: replanOpts.notAffected === true,
|
|
740
|
+
...(loop.staleNotes ? { staleNotes: true } : {}),
|
|
741
|
+
jobName: names.replan,
|
|
742
|
+
noteJobName: names.replanNote,
|
|
743
|
+
...(reportDir !== undefined ? { output: reportDir } : {}),
|
|
744
|
+
...(context !== undefined ? { context } : {}),
|
|
745
|
+
}),
|
|
593
746
|
...replanComments,
|
|
594
747
|
...(github && dispatchArg !== undefined ? { dispatch: { argument: dispatchArg } } : {}),
|
|
595
748
|
...(replies ? { reply: { prefix: `/${words.product}`, others } } : {}),
|
|
@@ -612,11 +765,11 @@ export function productPlanJobs(forge: ForgeKind, env: string, loop: PrLoopPipel
|
|
|
612
765
|
...(planRunner !== undefined ? { runner: planRunner } : {}),
|
|
613
766
|
...(noteRunner !== undefined ? { noteRunner } : {}),
|
|
614
767
|
// #4978: a target's plan job plans that target alone, so its checks are `plan:<target>` and `policy:<target>`.
|
|
615
|
-
...(evidence ? { evidence: planEvidenceOf(forge, evidence, words, jobName, { ...(plan.forks === "skip" ? { noForks: true } : {}), ...(name ? { member: { name, reportPath:
|
|
768
|
+
...(evidence ? { evidence: planEvidenceOf(forge, evidence, words, jobName, { ...(plan.forks === "skip" ? { noForks: true } : {}), ...(name ? { member: { name, reportPath: outputDir } } : {}), ...(reportDir !== undefined ? { dir: reportDir } : {}) }) } : {}),
|
|
616
769
|
...(Object.keys(jobEnv).length > 0 ? { jobEnv } : {}),
|
|
617
770
|
...(login && login.steps.length > 0 ? { login: login.steps } : {}),
|
|
618
771
|
...(Object.keys(idTokens).length > 0 ? { idTokens } : {}),
|
|
619
|
-
...(plan.pending && github ? { pending: { context: productStatusContext(words, "plan", name), description: "planning" } } : {}),
|
|
772
|
+
...(plan.pending && github ? { pending: { context: context ?? productStatusContext(words, "plan", name), description: "planning" } } : {}),
|
|
620
773
|
...(control ? { control } : {}),
|
|
621
774
|
...(plan.setup?.length ? { setup: plan.setup } : {}),
|
|
622
775
|
...(plan.report ? { report: fill(plan.report, name) } : {}),
|
|
@@ -625,11 +778,62 @@ export function productPlanJobs(forge: ForgeKind, env: string, loop: PrLoopPipel
|
|
|
625
778
|
...(record ? { record } : {}),
|
|
626
779
|
...(tradeSpec ? { trade: tradeSpec } : {}),
|
|
627
780
|
...(plan.previousMarker && productMarker ? { previous: { marker: prNoteMarker(env, name), name: productMarker } } : {}),
|
|
781
|
+
...(context !== undefined ? { context } : {}),
|
|
782
|
+
...(reportDir !== undefined ? { reportDir } : {}),
|
|
783
|
+
...(artifacts ? { artifacts } : {}),
|
|
628
784
|
};
|
|
629
785
|
};
|
|
630
786
|
return targets ? targets.map(one) : [one()];
|
|
631
787
|
}
|
|
632
788
|
|
|
789
|
+
/** Whether `dir` is a report directory a product plan takes (#5003): a relative path that stays in the checkout. */
|
|
790
|
+
function isReportDir(dir: string): boolean {
|
|
791
|
+
return /^[A-Za-z0-9_.\/-]+$/.test(dir) && !dir.startsWith("-") && dir.split("/").every((part) => part !== "" && part !== "." && part !== "..");
|
|
792
|
+
}
|
|
793
|
+
|
|
794
|
+
/** GitLab's top-level keywords, which no job may be named (#5003). */
|
|
795
|
+
const GITLAB_KEYWORDS = new Set(["default", "include", "stages", "variables", "workflow", "image", "services", "cache", "before_script", "after_script", "spec", "pages"]);
|
|
796
|
+
|
|
797
|
+
/**
|
|
798
|
+
* The plan jobs' names for each target (#5003), from
|
|
799
|
+
* {@link ProductPlanOptions.jobNames}, else chant's. Throws on a name that
|
|
800
|
+
* is not one, a `{target}` given without targets or left out with them, and
|
|
801
|
+
* two jobs of the plan that share a name.
|
|
802
|
+
*/
|
|
803
|
+
function productPlanJobNames(forge: ForgeKind, plan: Pick<ProductPlanOptions, "jobNames" | "replan">, targets: string[] | undefined): (target?: string) => { plan: string; note: string; replan: string; replanNote: string } {
|
|
804
|
+
const github = forge !== "gitlab";
|
|
805
|
+
const given = plan.jobNames ?? {};
|
|
806
|
+
const chant = { plan: "plan", note: PR_PLAN_NOTE_JOB, replan: REPLAN_JOB, replanNote: REPLAN_NOTE_JOB };
|
|
807
|
+
const keys = ["plan", "note", "replan", "replanNote"] as const;
|
|
808
|
+
for (const key of keys) {
|
|
809
|
+
const t = given[key];
|
|
810
|
+
if (t === undefined) continue;
|
|
811
|
+
if (Boolean(targets) !== t.includes("{target}")) throw new Error(targets ? `the product plan's jobNames.${key} ${JSON.stringify(t)} names every target's job, so it holds {target}` : `the product plan's jobNames.${key} ${JSON.stringify(t)} holds {target}, and the plan has no targets`);
|
|
812
|
+
}
|
|
813
|
+
const namesOf = (target?: string) => {
|
|
814
|
+
const out = {} as Record<(typeof keys)[number], string>;
|
|
815
|
+
for (const key of keys) {
|
|
816
|
+
const t = given[key];
|
|
817
|
+
// chant's: `plan-<target>` on GitHub and Forgejo, `<target>-plan` on GitLab.
|
|
818
|
+
out[key] = t !== undefined ? t.replaceAll("{target}", target ?? "") : target ? (github ? `${chant[key]}-${target}` : `${target}-${chant[key]}`) : chant[key];
|
|
819
|
+
}
|
|
820
|
+
return out;
|
|
821
|
+
};
|
|
822
|
+
const seen = new Map<string, string>();
|
|
823
|
+
for (const target of targets ?? [undefined]) {
|
|
824
|
+
const names = namesOf(target);
|
|
825
|
+
for (const key of plan.replan ? keys : (["plan", "note"] as const)) {
|
|
826
|
+
const n = names[key];
|
|
827
|
+
const ok = github ? /^[A-Za-z_][A-Za-z0-9_-]*$/.test(n) : /^[A-Za-z0-9_][A-Za-z0-9_-]*$/.test(n) && !GITLAB_KEYWORDS.has(n);
|
|
828
|
+
if (!ok) throw new Error(`the product plan's ${given[key] !== undefined ? `jobNames.${key}` : `${key} job`} ${JSON.stringify(n)} is not a job name of letters, digits, _ and -, starting with a letter or _${github ? "" : " or a digit, and no GitLab keyword"}`);
|
|
829
|
+
const other = seen.get(n);
|
|
830
|
+
if (other !== undefined) throw new Error(`the product plan names two jobs ${n}: ${other} and ${key}${target ? ` of ${target}` : ""}`);
|
|
831
|
+
seen.set(n, `${key}${target ? ` of ${target}` : ""}`);
|
|
832
|
+
}
|
|
833
|
+
}
|
|
834
|
+
return namesOf;
|
|
835
|
+
}
|
|
836
|
+
|
|
633
837
|
/** The comments the re-plan answers (#4899): the plan command, then the words' aliases for it. Refused when the words name no plan command. */
|
|
634
838
|
function replanCommentsOf(words: CiProductWords): { comments: string[]; gated: Array<{ comment: string; when: string }> } {
|
|
635
839
|
const command = commentLine(words, "plan");
|
|
@@ -639,15 +843,27 @@ function replanCommentsOf(words: CiProductWords): { comments: string[]; gated: A
|
|
|
639
843
|
}
|
|
640
844
|
|
|
641
845
|
/** The re-plan's jobs for one target (#4899), its comments filled in by the caller. */
|
|
642
|
-
function replanJobOf(
|
|
846
|
+
function replanJobOf(
|
|
847
|
+
forge: ForgeKind,
|
|
848
|
+
env: string,
|
|
849
|
+
words: CiProductWords,
|
|
850
|
+
name: string | undefined,
|
|
851
|
+
artifact: string,
|
|
852
|
+
noteWords0: Record<string, string>,
|
|
853
|
+
opts: { notAffected?: boolean; staleNotes?: boolean; jobName: string; noteJobName: string; output?: string; context?: string },
|
|
854
|
+
): Omit<ProductPlanReplanJob, "comments" | "gated"> {
|
|
643
855
|
const github = forge !== "gitlab";
|
|
644
|
-
const
|
|
645
|
-
const noteJobName = github ? (name ? `${REPLAN_NOTE_JOB}-${name}` : REPLAN_NOTE_JOB) : name ? `${name}-${REPLAN_NOTE_JOB}` : REPLAN_NOTE_JOB;
|
|
856
|
+
const { jobName, noteJobName } = opts;
|
|
646
857
|
// pr-post reads the pull request and the head from the re-plan job, never the comment. GitLab's is GitHub's line with its own --forge.
|
|
647
|
-
|
|
858
|
+
// #4987: with staleNotes the note's tip line is the target branch's commit the re-plan ran at, as the comment preview's is.
|
|
859
|
+
// #5003: the product's report directory and status context.
|
|
860
|
+
const post0 = { ...(opts.staleNotes ? { staleNotes: true } : {}), ...(opts.output !== undefined ? { output: opts.output } : {}) };
|
|
861
|
+
const command0 = github ? prLoopPostJob(forge, env, name, words, post0).command : prLoopPostJob("github", env, name, words, post0).command.replace(" --forge github ", " --forge gitlab ");
|
|
862
|
+
const command1 = opts.context !== undefined ? `${command0} --context ${opts.context}` : command0;
|
|
648
863
|
// #4963: the argument the re-plan was narrowed to, which pr-post answers "not affected" for when the change does not reach it.
|
|
649
|
-
const command = opts.notAffected ? `${
|
|
650
|
-
const
|
|
864
|
+
const command = opts.notAffected ? `${command1} --not-affected "$${PLAN_ARGUMENT_ENV}"` : command1;
|
|
865
|
+
const noteWords1 = opts.notAffected && github ? { ...noteWords0, [PLAN_ARGUMENT_ENV]: `\${{ needs.${jobName}.outputs.argument }}` } : noteWords0;
|
|
866
|
+
const noteWords = opts.staleNotes ? { ...noteWords1, TIP_SHA: github ? "${{ github.sha }}" : "$CI_COMMIT_SHA" } : noteWords1;
|
|
651
867
|
const post = github
|
|
652
868
|
? {
|
|
653
869
|
command,
|
|
@@ -691,7 +907,8 @@ function literal(text: string): string {
|
|
|
691
907
|
* a target, the command with at most one word after it.
|
|
692
908
|
*/
|
|
693
909
|
export function gitlabReplanCommentIf(replan: Pick<ProductPlanReplanJob, "comments" | "gated">, target?: string): string {
|
|
694
|
-
|
|
910
|
+
// #4984: the one word never starts with `-`, so a flag such as `--target=x` starts no re-plan.
|
|
911
|
+
const arg = target ? `( +${literal(target)})?` : `( +${REPLAN_WORD_SOURCE})?`;
|
|
695
912
|
const one = (c: string): string => `$${GITLAB_REPLAN_COMMENT_VAR} =~ /^${literal(c)}${arg} *$/`;
|
|
696
913
|
return [...replan.comments.map(one), ...replan.gated.map((g) => `($${g.when} && ${one(g.comment)})`)].join(" || ");
|
|
697
914
|
}
|
|
@@ -739,15 +956,19 @@ export function replanDecideJs(opts: { dispatch?: boolean; reply?: boolean } = {
|
|
|
739
956
|
'const body=String((e.comment&&e.comment.body)||"").trim();',
|
|
740
957
|
'const cmds=JSON.parse(process.env.CHANT_REPLAN_COMMANDS||"[]");',
|
|
741
958
|
'for(const g of JSON.parse(process.env.CHANT_REPLAN_GATED||"[]")){const v=process.env[g.when]||"";if(v&&v!=="0"&&v!=="false")cmds.push(g.comment)}',
|
|
742
|
-
"let arg;",
|
|
959
|
+
"let arg,flag;",
|
|
743
960
|
...(reply ? ['let refusal;const product=process.env.CHANT_REPLAN_PRODUCT||"",others=JSON.parse(process.env.CHANT_REPLAN_OTHERS||"[]");const says=(c)=>body===c||body.startsWith(c+" ")||body.startsWith(c+"\\t");'] : []),
|
|
744
961
|
...(dispatch
|
|
745
962
|
? [
|
|
746
963
|
'if(dispatch){const pv=String(inputs.pr==null?"":inputs.pr).trim();if(!pv){say("the dispatch names no pull request");process.exit(0)}if(!/^[1-9][0-9]{0,9}$/.test(pv)){console.error("chant: the dispatch\\u0027s pr input is a pull request number, like 42");process.exit(1)}',
|
|
747
|
-
|
|
964
|
+
`const k=process.env.CHANT_REPLAN_DISPATCH_ARGUMENT||"argument",a=String(inputs[k]==null?"":inputs[k]).trim();if(a&&!/${REPLAN_WORD_JS}/.test(a)){console.error("chant: the dispatch\\u0027s "+k+" input is one word of letters, digits and _./@+=,:-, not starting with -");process.exit(1)}arg=a}else `,
|
|
748
965
|
]
|
|
749
966
|
: []),
|
|
750
|
-
|
|
967
|
+
// #4984: a word that starts with `-` is a flag (`--target=x`), which the re-plan does not take.
|
|
968
|
+
`for(const c of cmds){if(body===c){arg="";break}if(body.startsWith(c+" ")){const r=body.slice(c.length).trim();if(r.startsWith("-")){flag=r.split(/\\s/)[0];break}if(/${REPLAN_WORD_JS}/.test(r)){arg=r;break}}}`,
|
|
969
|
+
reply
|
|
970
|
+
? 'if(flag!==undefined){refusal="the re-plan takes no flags, and "+flag+" is one: write the command alone, or with one word that does not start with -";arg=""}'
|
|
971
|
+
: 'if(flag!==undefined){say("the re-plan takes no flags, and "+flag+" is one, so nothing is planned again");process.exit(0)}',
|
|
751
972
|
reply
|
|
752
973
|
? 'if(arg===undefined){if(product&&says(product)&&!others.some(says)){refusal="the commands are "+cmds.concat(others).map((c)=>"`"+c+"`").join(", ")}else{say("the comment asks for no plan");process.exit(0)}}'
|
|
753
974
|
: 'if(arg===undefined){say("the comment asks for no plan");process.exit(0)}',
|
|
@@ -846,7 +1067,7 @@ export const PENDING_JS = [
|
|
|
846
1067
|
* report line whatever the verb's exit, then the step exits with the verb's
|
|
847
1068
|
* status. Without a report line, the verb alone.
|
|
848
1069
|
*/
|
|
849
|
-
export function planVerbLines(p: Pick<ProductPlanJob, "command" | "report" | "record">): string[] {
|
|
1070
|
+
export function planVerbLines(p: Pick<ProductPlanJob, "command" | "report" | "record" | "reportDir">): string[] {
|
|
850
1071
|
if (!p.report && !p.record) return [p.command];
|
|
851
1072
|
return [
|
|
852
1073
|
...(p.record ? ['chant_plan_started="$(date -u +%Y-%m-%dT%H:%M:%SZ)"'] : []),
|
|
@@ -854,7 +1075,7 @@ export function planVerbLines(p: Pick<ProductPlanJob, "command" | "report" | "re
|
|
|
854
1075
|
`${p.command} || chant_plan_exit=$?`,
|
|
855
1076
|
...(p.report ? [`${p.report} || echo "chant: the report line exited $?" >&2`] : []),
|
|
856
1077
|
// #4899: the run record goes into the hand-off, for the note job to keep on chant/lifecycle.
|
|
857
|
-
...(p.record ? [`CHANT_PLAN_EXIT="$chant_plan_exit" CHANT_PLAN_STARTED="$chant_plan_started" node -e '${PLAN_RECORD_JS}' ${
|
|
1078
|
+
...(p.record ? [`CHANT_PLAN_EXIT="$chant_plan_exit" CHANT_PLAN_STARTED="$chant_plan_started" node -e '${PLAN_RECORD_JS}' ${productPlanReportDir(p)} || echo "chant: the plan's run record was not written" >&2`] : []),
|
|
858
1079
|
'[ "$chant_plan_exit" -eq 0 ] || exit "$chant_plan_exit"',
|
|
859
1080
|
];
|
|
860
1081
|
}
|
|
@@ -886,25 +1107,27 @@ export const PLAN_RECORD_JS = [
|
|
|
886
1107
|
* #4978: a product plan target's plan job is signed the same way, under the
|
|
887
1108
|
* target's name.
|
|
888
1109
|
*/
|
|
889
|
-
export function planEvidenceOf(forge: ForgeKind, evidence: PipelineEvidence, words: CiProductWords, planJob: string, opts: { noForks?: boolean; member?: { name: string; reportPath: string } } = {}): NonNullable<ProductPlanJob["evidence"]> {
|
|
1110
|
+
export function planEvidenceOf(forge: ForgeKind, evidence: PipelineEvidence, words: CiProductWords, planJob: string, opts: { noForks?: boolean; member?: { name: string; reportPath: string }; dir?: string } = {}): NonNullable<ProductPlanJob["evidence"]> {
|
|
890
1111
|
assertPipelineEvidence(evidence);
|
|
891
1112
|
const key = evidenceKeyEnv(forge, evidence);
|
|
892
1113
|
const bin = words.bin;
|
|
893
1114
|
const member = opts.member ? { member: opts.member.name } : {};
|
|
1115
|
+
// #5003: the product plan's report directory, which the plan job handed on.
|
|
1116
|
+
const reportDir = opts.dir ?? PR_LOOP_REPORT_DIR;
|
|
894
1117
|
if (forge === "gitlab") {
|
|
895
1118
|
// #4914: the job runs in the target branch's plan notes pipeline, before the note job, and signs every open
|
|
896
1119
|
// merge request's settled plan job from its artifact; no job of a merge request pipeline holds the key.
|
|
897
1120
|
const dir = gitlabOpenEvidenceDir(planJob);
|
|
898
1121
|
return {
|
|
899
1122
|
jobName: `${planJob}-evidence`,
|
|
900
|
-
lines: openEvidenceLines({ job: planJob, dir: opts.member?.reportPath ??
|
|
1123
|
+
lines: openEvidenceLines({ job: planJob, dir: opts.member?.reportPath ?? reportDir, out: dir, ...(bin ? { bin } : {}), ...(opts.noForks ? { noForks: true } : {}), ...member }),
|
|
901
1124
|
env: key,
|
|
902
1125
|
dir,
|
|
903
1126
|
...(evidenceKeyless(evidence) ? { idTokens: evidenceIdTokens(evidence) } : {}),
|
|
904
1127
|
};
|
|
905
1128
|
}
|
|
906
1129
|
return {
|
|
907
|
-
lines: planEvidenceLines({ dir:
|
|
1130
|
+
lines: planEvidenceLines({ dir: reportDir, at: '"$HEAD_SHA"', base: '"$BASE_SHA"', result: '"$PLAN_RESULT"', ...(bin ? { bin } : {}), ...member }),
|
|
908
1131
|
env: { HEAD_SHA: "${{ github.sha }}", BASE_SHA: "${{ github.event.pull_request.base.sha }}", PLAN_RESULT: `\${{ needs.${planJob}.result }}`, ...key },
|
|
909
1132
|
...(evidenceKeyless(evidence) ? { idToken: true as const } : {}),
|
|
910
1133
|
};
|