@intentius/chant 0.124.91 → 0.124.92
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ci-comment-commands.d.ts +11 -1
- package/dist/ci-comment-commands.d.ts.map +1 -1
- package/dist/ci-comment-commands.js +10 -3
- package/dist/ci-product.d.ts +18 -1
- package/dist/ci-product.d.ts.map +1 -1
- package/dist/ci-product.js +20 -3
- package/dist/cli/handlers/pr-comment.d.ts.map +1 -1
- package/dist/cli/handlers/pr-comment.js +15 -2
- package/dist/cli/handlers/pr.d.ts.map +1 -1
- package/dist/cli/handlers/pr.js +4 -1
- package/dist/components/pr-pipeline.d.ts +4 -2
- package/dist/components/pr-pipeline.d.ts.map +1 -1
- package/dist/components/pr-pipeline.js +7 -4
- package/dist/components/product-pipeline.d.ts +41 -7
- package/dist/components/product-pipeline.d.ts.map +1 -1
- package/dist/components/product-pipeline.js +57 -20
- package/dist/components/product-plan.d.ts +7 -0
- package/dist/components/product-plan.d.ts.map +1 -1
- package/dist/components/product-plan.js +1 -0
- package/dist/floor-table.data.d.ts.map +1 -1
- package/dist/floor-table.data.js +9 -5
- package/dist/lexicon.d.ts +42 -1
- package/dist/lexicon.d.ts.map +1 -1
- package/dist/op/before-merge-decide.d.ts +2 -0
- package/dist/op/before-merge-decide.d.ts.map +1 -1
- package/dist/op/op-waves-evidence-jobs.d.ts +3 -2
- package/dist/op/op-waves-evidence-jobs.d.ts.map +1 -1
- package/dist/op/op-waves-evidence-jobs.js +4 -3
- package/dist/op/op-waves-follow-on.d.ts +2 -0
- package/dist/op/op-waves-follow-on.d.ts.map +1 -1
- package/dist/op/op-waves-follow-on.js +8 -2
- package/dist/op/op-waves-names.d.ts +122 -0
- package/dist/op/op-waves-names.d.ts.map +1 -0
- package/dist/op/op-waves-names.js +151 -0
- package/dist/pr-forge-job.d.ts +8 -0
- package/dist/pr-forge-job.d.ts.map +1 -1
- package/dist/pr-forge-job.js +13 -0
- package/dist/pr-plan-record.d.ts +3 -1
- package/dist/pr-plan-record.d.ts.map +1 -1
- package/dist/pr-plan-record.js +1 -1
- package/dist/pr-post.d.ts +9 -3
- package/dist/pr-post.d.ts.map +1 -1
- package/dist/pr-post.js +5 -2
- package/dist/release-floors.d.ts +1 -1
- package/dist/release-floors.d.ts.map +1 -1
- package/dist/release-floors.js +4 -4
- package/dist/wave-runtime.mjs +258 -258
- package/package.json +1 -1
- package/src/ci-comment-commands.test.ts +19 -5
- package/src/ci-comment-commands.ts +18 -3
- package/src/ci-product.ts +24 -3
- package/src/cli/handlers/pr-comment.ts +12 -2
- package/src/cli/handlers/pr.ts +4 -1
- package/src/components/pr-pipeline.ts +7 -4
- package/src/components/product-job-names.test.ts +176 -0
- package/src/components/product-pipeline.ts +95 -28
- package/src/components/product-plan.ts +8 -0
- package/src/floor-table.data.ts +9 -5
- package/src/lexicon.ts +42 -1
- package/src/op/before-merge-decide.ts +2 -0
- package/src/op/op-waves-evidence-jobs.ts +4 -3
- package/src/op/op-waves-follow-on.ts +10 -2
- package/src/op/op-waves-names.test.ts +131 -0
- package/src/op/op-waves-names.ts +241 -0
- package/src/pr-forge-job.ts +13 -0
- package/src/pr-plan-record.ts +4 -2
- package/src/pr-post-head.test.ts +116 -0
- package/src/pr-post.ts +15 -5
- package/src/release-floors.ts +4 -4
|
@@ -50,6 +50,8 @@ import { COMMENT_JOBS_ENV, PR_COMMENT_JOB, type CommentJobs } from "../ci-commen
|
|
|
50
50
|
import { GITHUB_JOB_TOKEN } from "../ci-jobs";
|
|
51
51
|
import type { OpWavesBeforeMerge } from "../op/before-merge";
|
|
52
52
|
import { defaultPipelineFiles, type WavesBeforeMergeJobs } from "../op/before-merge-decide";
|
|
53
|
+
import { opWavesDispatchInputs, opWavesInputsRenamed, opWavesNamer, opWavesWorkflowFile, type OpWavesJobNames } from "../op/op-waves-names";
|
|
54
|
+
import { opWaveSplitJobs } from "../op/op-waves-split";
|
|
53
55
|
import type { PrApplyRequire } from "../pr-requires";
|
|
54
56
|
import { LOCK_REACH_ENV } from "../lifecycle/reach-locks";
|
|
55
57
|
|
|
@@ -149,9 +151,19 @@ export interface ProductPipelineOptions extends Omit<PrLoopPipelineOptions, "wor
|
|
|
149
151
|
* chant's), and with waves on merge the re-run of a merged pull request's
|
|
150
152
|
* apply. The jobs it leaves comments to are the ones these options write.
|
|
151
153
|
* On GitLab the note-commands job answers every note already; refused
|
|
152
|
-
* there.
|
|
154
|
+
* there. `{ jobName }` (#5027) names the job, such as terragucci's
|
|
155
|
+
* `apply-comment`. Default `comment`.
|
|
153
156
|
*/
|
|
154
|
-
commentJob?: boolean;
|
|
157
|
+
commentJob?: boolean | ProductCommentJobOptions;
|
|
158
|
+
/**
|
|
159
|
+
* The waves' job names (#5027), the Op waves generators' `jobNames`
|
|
160
|
+
* (#5022): `waves.pipeline` carries them to the generator, `waves.jobs`
|
|
161
|
+
* takes them, and the comment job's re-run of a merged pull request's
|
|
162
|
+
* apply looks for the jobs under them (`CHANT_COMMENT_JOBS`
|
|
163
|
+
* `applyJobs`). Absent: chant's names, and the re-run looks for
|
|
164
|
+
* `RERUN_APPLY_JOBS`. Needs `waves` (or `componentWaves`).
|
|
165
|
+
*/
|
|
166
|
+
wavesJobNames?: OpWavesJobNames;
|
|
155
167
|
/**
|
|
156
168
|
* Waves before merge (#4984, maintainer decision 2026-11-10): `/<product>
|
|
157
169
|
* apply [wave-<n>]` on an open pull request runs the waves on its head.
|
|
@@ -189,11 +201,32 @@ export interface ProductWavesBeforeMerge {
|
|
|
189
201
|
mergeTokenSecret?: string;
|
|
190
202
|
/** Paths a change may not touch to apply before merge; one ending in `/` is a directory. Default the forge's workflow directory and `.chant/op-waves/`. */
|
|
191
203
|
pipelineFiles?: string[];
|
|
204
|
+
/**
|
|
205
|
+
* GitHub and Forgejo (#5022): the workflow the waves are in, which the
|
|
206
|
+
* comment job dispatches, such as `terragucci.yml`. Default `<op>.yml`.
|
|
207
|
+
* The product passes `waves.pipeline` on, which carries it as the
|
|
208
|
+
* generator's `workflowFile`.
|
|
209
|
+
*/
|
|
210
|
+
workflowFile?: string;
|
|
211
|
+
/**
|
|
212
|
+
* GitHub and Forgejo (#5022): the waves workflow's names of the inputs
|
|
213
|
+
* `pr`, `head` and `digest`, which the comment job dispatches with, so
|
|
214
|
+
* they never meet the product's own. `waves.pipeline` carries them as
|
|
215
|
+
* the generator's `dispatchInputs`. Default chant's.
|
|
216
|
+
*/
|
|
217
|
+
dispatchInputs?: Partial<Record<"pr" | "head" | "digest", string>>;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/** {@link ProductPipelineOptions.commentJob}'s settings (#5027). */
|
|
221
|
+
export interface ProductCommentJobOptions {
|
|
222
|
+
/** The comment job's name in the workflow, such as `apply-comment`. Default {@link PR_COMMENT_JOB}. */
|
|
223
|
+
jobName?: string;
|
|
192
224
|
}
|
|
193
225
|
|
|
194
226
|
/** The comment job (#4946): its command, the values it reads, and the comment prefixes that start it. */
|
|
195
227
|
export interface ProductCommentJob {
|
|
196
|
-
jobName
|
|
228
|
+
/** {@link PR_COMMENT_JOB}, or the product's `commentJob.jobName` (#5027). */
|
|
229
|
+
jobName: string;
|
|
197
230
|
/** `<bin> components pr-comment --forge <forge>`. */
|
|
198
231
|
command: string;
|
|
199
232
|
/** `GITHUB_TOKEN` and {@link COMMENT_JOBS_ENV}. */
|
|
@@ -241,8 +274,10 @@ export interface ProductPipelineJobs {
|
|
|
241
274
|
* `applyStatus` and, with `staleNotes`, the stale marking job that runs
|
|
242
275
|
* beside wave 1 on a push (one `--member` per product plan target). The
|
|
243
276
|
* product spreads it into the `OpWavesPipelineOptions` it renders with.
|
|
277
|
+
* #5022: with them, `wavesBeforeMerge`'s `workflowFile` and
|
|
278
|
+
* `dispatchInputs`, which the comment job dispatches by.
|
|
244
279
|
*/
|
|
245
|
-
pipeline: Pick<OpWavesPipelineOptions, "beforeMerge" | "applyStatus" | "staleNotes">;
|
|
280
|
+
pipeline: Pick<OpWavesPipelineOptions, "beforeMerge" | "applyStatus" | "staleNotes" | "workflowFile" | "dispatchInputs" | "jobNames">;
|
|
246
281
|
};
|
|
247
282
|
/**
|
|
248
283
|
* The comment lock and unlock jobs (#4588), under `locks: "plan"`:
|
|
@@ -410,7 +445,7 @@ export function productPipelineJobs(forge: ForgeKind, env: string, options: Prod
|
|
|
410
445
|
// #4946: the comment job answers every command but a commit word (the commit job's) with a reply, so the words may name any.
|
|
411
446
|
const answered: CiProductCommand[] = options.commentJob ? [...new Set<CiProductCommand>([...jobs, ...CI_PRODUCT_COMMANDS.filter((c) => c !== "commit")])] : jobs;
|
|
412
447
|
const words = assertProductWords({ ...options.words, applyMode }, { jobs: answered });
|
|
413
|
-
const { waves: given, wavesSpecFile, member, agent: _agent, commits: _commits, actions: _actions, componentWaves, productPlan, evidence, commentJob: _commentJob, wavesBeforeMerge, applyStatus: _applyStatus, ...loop } = options;
|
|
448
|
+
const { waves: given, wavesSpecFile, member, agent: _agent, commits: _commits, actions: _actions, componentWaves, productPlan, evidence, commentJob: _commentJob, wavesBeforeMerge, applyStatus: _applyStatus, wavesJobNames, ...loop } = options;
|
|
414
449
|
if (options.applyStatus && !given && !componentWaves) throw new Error("applyStatus posts the waves' apply statuses, and there are none: give waves (or componentWaves)");
|
|
415
450
|
const { respond } = options;
|
|
416
451
|
// #4629: the pull request loop puts the responses on the apply and note jobs, as `chant build --pr-loop --respond` does.
|
|
@@ -495,8 +530,13 @@ export function productPipelineJobs(forge: ForgeKind, env: string, options: Prod
|
|
|
495
530
|
if (options.applyBeforeMerge) throw new Error("wavesBeforeMerge and applyBeforeMerge both answer an open pull request's apply; give one");
|
|
496
531
|
if (forge === "gitlab" ? !options.noteCommands : !options.commentJob) throw new Error(`wavesBeforeMerge is decided by ${forge === "gitlab" ? "the note poll: set noteCommands" : "the comment job: set commentJob"}`);
|
|
497
532
|
const targets = productPlan?.targets?.map((t) => t.name);
|
|
533
|
+
if (forge === "gitlab" && (wavesBeforeMerge.workflowFile !== undefined || wavesBeforeMerge.dispatchInputs !== undefined)) throw new Error("wavesBeforeMerge.workflowFile and dispatchInputs name a GitHub or Forgejo workflow; GitLab's note poll starts a pipeline with variables");
|
|
534
|
+
// #5022: the product's workflow and input names, checked as the generator checks them.
|
|
535
|
+
const workflowFile = opWavesWorkflowFile({ name: wavesOp }, wavesBeforeMerge.workflowFile);
|
|
536
|
+
const dispatchInputs = wavesBeforeMerge.dispatchInputs ? opWavesDispatchInputs(wavesBeforeMerge.dispatchInputs) : undefined;
|
|
498
537
|
bmJobs = {
|
|
499
|
-
...(forge !== "gitlab" ? { workflow:
|
|
538
|
+
...(forge !== "gitlab" ? { workflow: workflowFile } : {}),
|
|
539
|
+
...(dispatchInputs && opWavesInputsRenamed(dispatchInputs) ? { inputs: { pr: dispatchInputs.pr, head: dispatchInputs.head, digest: dispatchInputs.digest } } : {}),
|
|
500
540
|
...(wavesBeforeMerge.requires ? { requires: [...wavesBeforeMerge.requires] } : {}),
|
|
501
541
|
// #5003: the product's own status contexts, when it named them.
|
|
502
542
|
plan: planContexts ?? (targets?.length ? targets.map((t) => productStatusContext(words, "plan", t)) : [productStatusContext(words, "plan", member)]),
|
|
@@ -514,6 +554,27 @@ export function productPipelineJobs(forge: ForgeKind, env: string, options: Prod
|
|
|
514
554
|
},
|
|
515
555
|
};
|
|
516
556
|
}
|
|
557
|
+
const wavesRespond = respond ? Object.fromEntries(Object.entries(respond).filter(([e]) => e !== "description")) : {};
|
|
558
|
+
// #4625: the waves run on the apply runner and with the plan's parallelism, unless the spec names its own.
|
|
559
|
+
const applyRunner = prLoopRunner(options, "apply");
|
|
560
|
+
const named = spec
|
|
561
|
+
? {
|
|
562
|
+
...productWavesSpec(
|
|
563
|
+
{
|
|
564
|
+
...spec,
|
|
565
|
+
...(spec.runner === undefined && applyRunner !== undefined ? { runner: applyRunner } : {}),
|
|
566
|
+
...(spec.parallelism === undefined && options.parallelism !== undefined && spec.step !== undefined ? { parallelism: options.parallelism } : {}),
|
|
567
|
+
},
|
|
568
|
+
words,
|
|
569
|
+
),
|
|
570
|
+
...(Object.keys(wavesRespond).length > 0 ? { respond: { ...(spec.respond ?? {}), ...wavesRespond } } : {}),
|
|
571
|
+
}
|
|
572
|
+
: undefined;
|
|
573
|
+
const specFile = named ? (wavesSpecFile ?? productWavesSpecFile(named.name)) : undefined;
|
|
574
|
+
if (wavesJobNames !== undefined && !named) throw new Error("wavesJobNames names the waves' jobs, and there are none: give waves (or componentWaves)");
|
|
575
|
+
// #5027: the waves' jobs under the product's names, the same the generator gives them from the same jobNames.
|
|
576
|
+
const waveJobs = named && specFile ? opWaveJobs(named, specFile, { bin: words.bin, ...(wavesBeforeMerge ? { beforeMerge: true } : {}) }) : undefined;
|
|
577
|
+
const namedWaveJobs = waveJobs && wavesJobNames ? opWavesNamer(named!, forge, wavesJobNames).jobs(waveJobs) : waveJobs;
|
|
517
578
|
// #4946: the comment job answers what no other job of the pipeline takes, so it is told which jobs there are.
|
|
518
579
|
if (options.commentJob) {
|
|
519
580
|
// #4963's re-plan reply answers the same stray comments, so one of the two answers them.
|
|
@@ -535,39 +596,43 @@ export function productPipelineJobs(forge: ForgeKind, env: string, options: Prod
|
|
|
535
596
|
...(out.agent ? { agent: true } : {}),
|
|
536
597
|
...(out.commits ? { commits: true } : {}),
|
|
537
598
|
...(options.actions || options.actionJob ? { actions: true } : {}),
|
|
599
|
+
// #5027: a re-run looks for the waves' jobs by the product's names; without them, by chant's pattern.
|
|
600
|
+
...(namedWaveJobs && wavesJobNames ? { applyJobs: productApplyJobs(named!, waveJobs!, namedWaveJobs, forge, wavesJobNames, wavesBeforeMerge !== undefined) } : {}),
|
|
538
601
|
};
|
|
539
|
-
const comment = productCommentJob(forge, words, commentJobs);
|
|
602
|
+
const comment = productCommentJob(forge, words, commentJobs, typeof options.commentJob === "object" ? options.commentJob.jobName : undefined);
|
|
540
603
|
// #4984: the decision before merge locks what the reach line prints, at stage apply.
|
|
541
604
|
if (bmJobs && productPlan?.reach) comment.env = { ...comment.env, [LOCK_REACH_ENV]: productPlan.reach.command };
|
|
542
605
|
out.comment = { ...comment, ...defaultRunner };
|
|
543
606
|
}
|
|
544
|
-
if (!
|
|
545
|
-
const wavesRespond = respond ? Object.fromEntries(Object.entries(respond).filter(([e]) => e !== "description")) : {};
|
|
546
|
-
// #4625: the waves run on the apply runner and with the plan's parallelism, unless the spec names its own.
|
|
547
|
-
const applyRunner = prLoopRunner(options, "apply");
|
|
548
|
-
const named = {
|
|
549
|
-
...productWavesSpec(
|
|
550
|
-
{
|
|
551
|
-
...spec,
|
|
552
|
-
...(spec.runner === undefined && applyRunner !== undefined ? { runner: applyRunner } : {}),
|
|
553
|
-
...(spec.parallelism === undefined && options.parallelism !== undefined && spec.step !== undefined ? { parallelism: options.parallelism } : {}),
|
|
554
|
-
},
|
|
555
|
-
words,
|
|
556
|
-
),
|
|
557
|
-
...(Object.keys(wavesRespond).length > 0 ? { respond: { ...(spec.respond ?? {}), ...wavesRespond } } : {}),
|
|
558
|
-
};
|
|
559
|
-
const specFile = wavesSpecFile ?? productWavesSpecFile(named.name);
|
|
607
|
+
if (!named || !specFile || !namedWaveJobs) return { ...out, record: record! };
|
|
560
608
|
// #4984: what the generator's before-merge mode takes: the merge after the last wave and the lock file it releases.
|
|
561
609
|
const beforeMerge: OpWavesBeforeMerge | undefined = wavesBeforeMerge
|
|
562
610
|
? { ...(wavesBeforeMerge.merge ? { merge: wavesBeforeMerge.merge } : {}), ...(wavesBeforeMerge.mergeTokenSecret ? { mergeTokenSecret: wavesBeforeMerge.mergeTokenSecret } : {}), ...(productPlan?.reach?.gate ? { gate: productPlan.reach.gate } : {}) }
|
|
563
611
|
: undefined;
|
|
564
612
|
// #4987: the apply statuses after each wave, and with a product plan the stale marking beside wave 1, one --member per target.
|
|
565
|
-
const pipeline: Pick<OpWavesPipelineOptions, "beforeMerge" | "applyStatus" | "staleNotes"> = {
|
|
613
|
+
const pipeline: Pick<OpWavesPipelineOptions, "beforeMerge" | "applyStatus" | "staleNotes" | "workflowFile" | "dispatchInputs" | "jobNames"> = {
|
|
566
614
|
...(beforeMerge ? { beforeMerge } : {}),
|
|
615
|
+
// #5027: the same job names the comment job's re-run looks for.
|
|
616
|
+
...(wavesJobNames ? { jobNames: wavesJobNames } : {}),
|
|
617
|
+
// #5022: the workflow and input names the comment job dispatches, for the generator.
|
|
618
|
+
...(wavesBeforeMerge?.workflowFile ? { workflowFile: wavesBeforeMerge.workflowFile } : {}),
|
|
619
|
+
...(wavesBeforeMerge?.dispatchInputs ? { dispatchInputs: { ...wavesBeforeMerge.dispatchInputs } } : {}),
|
|
567
620
|
...(options.applyStatus ? { applyStatus: { context: productStatusContext(words, "apply", member) } } : {}),
|
|
568
621
|
...(planStale ? { staleNotes: planStale } : {}),
|
|
569
622
|
};
|
|
570
|
-
return { ...out, waves: { spec: named, specFile, jobs:
|
|
623
|
+
return { ...out, waves: { spec: named, specFile, jobs: namedWaveJobs, ...(beforeMerge ? { beforeMerge } : {}), pipeline } };
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
/**
|
|
627
|
+
* The waves' jobs a re-run looks for, by the product's names (#5027): each
|
|
628
|
+
* wave's job, its deciding, share and job group jobs, and before merge the
|
|
629
|
+
* split jobs, named as the Op waves generator names them from the same
|
|
630
|
+
* `jobNames`.
|
|
631
|
+
*/
|
|
632
|
+
function productApplyJobs(spec: OpWavesSpec, chantJobs: readonly OpWaveJob[], named: readonly OpWaveJob[], forge: ForgeKind, jobNames: OpWavesJobNames, split: boolean): string[] {
|
|
633
|
+
const out = named.map((j) => j.jobName);
|
|
634
|
+
if (split) out.push(...opWavesNamer(spec, forge, jobNames).jobs(opWaveSplitJobs(spec, chantJobs)).map((j) => j.jobName));
|
|
635
|
+
return [...new Set(out)];
|
|
571
636
|
}
|
|
572
637
|
|
|
573
638
|
/** The capability steps a component waves spec runs (#4545, #4541): argv templates over `{runs}` and `{plans}`. */
|
|
@@ -684,13 +749,15 @@ export function componentWavesSpec(
|
|
|
684
749
|
* --forge <forge>` through the words' bin, the jobs it leaves comments to as
|
|
685
750
|
* {@link COMMENT_JOBS_ENV}, and the comment prefixes the forge's `if:`
|
|
686
751
|
* starts it on. Throws on GitLab, whose note-commands job answers every
|
|
687
|
-
* note.
|
|
752
|
+
* note. `jobName` is the product's name for the job (#5027), default
|
|
753
|
+
* {@link PR_COMMENT_JOB}.
|
|
688
754
|
*/
|
|
689
|
-
export function productCommentJob(forge: ForgeKind, words: CiProductWords, jobs: CommentJobs): ProductCommentJob {
|
|
755
|
+
export function productCommentJob(forge: ForgeKind, words: CiProductWords, jobs: CommentJobs, jobName: string = PR_COMMENT_JOB): ProductCommentJob {
|
|
690
756
|
if (forge === "gitlab") throw new Error("the comment job answers a GitHub or Forgejo comment; on GitLab the note-commands job (noteCommands) answers every note, so drop commentJob");
|
|
691
757
|
for (const a of words.aliases) if (/['\\]/.test(a.from)) throw new Error(`the alias ${JSON.stringify(a.from)} holds a quote, which the comment job's condition cannot carry`);
|
|
758
|
+
if (typeof jobName !== "string" || !/^[A-Za-z_][A-Za-z0-9_-]*$/.test(jobName)) throw new Error(`commentJob.jobName ${JSON.stringify(jobName)} is not a job name of letters, digits, _ and -, starting with a letter or _`);
|
|
692
759
|
return {
|
|
693
|
-
jobName
|
|
760
|
+
jobName,
|
|
694
761
|
command: withProductBin(`chant components pr-comment --forge ${forge}`, words.bin),
|
|
695
762
|
env: { GITHUB_TOKEN: GITHUB_JOB_TOKEN, [COMMENT_JOBS_ENV]: JSON.stringify(jobs) },
|
|
696
763
|
prefixes: [`/${words.product}`, ...words.aliases.map((a) => a.from)],
|
|
@@ -512,6 +512,13 @@ export interface ProductPlanJob {
|
|
|
512
512
|
login?: OpWaveRunStep[];
|
|
513
513
|
/** The OIDC tokens the plan job requests (#4931), `{ <variable>: <audience> }`: the login's and the product's own. */
|
|
514
514
|
idTokens?: Record<string, string>;
|
|
515
|
+
/**
|
|
516
|
+
* With the product's own `idTokens` (#5021): the plan verb asks the forge
|
|
517
|
+
* for them by audience, so on GitHub and Forgejo the plan step keeps the
|
|
518
|
+
* variables a token is requested with. Without it, every step after the
|
|
519
|
+
* checkout but the login's starts without them.
|
|
520
|
+
*/
|
|
521
|
+
ownIdTokens?: true;
|
|
515
522
|
/** The pending status posted before the checkout (#4899), on GitHub and Forgejo. */
|
|
516
523
|
pending?: { context: string; description: string };
|
|
517
524
|
/** The control repo read after the checkout (#4899). */
|
|
@@ -769,6 +776,7 @@ export function productPlanJobs(forge: ForgeKind, env: string, loop: PrLoopPipel
|
|
|
769
776
|
...(Object.keys(jobEnv).length > 0 ? { jobEnv } : {}),
|
|
770
777
|
...(login && login.steps.length > 0 ? { login: login.steps } : {}),
|
|
771
778
|
...(Object.keys(idTokens).length > 0 ? { idTokens } : {}),
|
|
779
|
+
...(Object.keys(ownTokens ?? {}).length > 0 ? { ownIdTokens: true as const } : {}),
|
|
772
780
|
...(plan.pending && github ? { pending: { context: context ?? productStatusContext(words, "plan", name), description: "planning" } } : {}),
|
|
773
781
|
...(control ? { control } : {}),
|
|
774
782
|
...(plan.setup?.length ? { setup: plan.setup } : {}),
|
package/src/floor-table.data.ts
CHANGED
|
@@ -50,8 +50,12 @@ export const FLOOR_ROWS: readonly FloorRow[] = [
|
|
|
50
50
|
{ name: "PRODUCT_PLAN_RECORD_FLOOR", version: "0.124.88", gates: "The first chant whose product plan takes `record` (#4899): the plan step writes the plan job's run record into the hand-off, and the note job keeps it as Op `pr-plan` on `chant/lifecycle` with `pr-post --record-run <plan job>` (`--open` on GitLab), as `chant ci run plan --in-place` records `pr-plan`'s.", issue: "#4899", file: "ci-product.ts", modules: ["@intentius/chant/ci-product"] },
|
|
51
51
|
{ name: "PRODUCT_PLAN_REPLAN_FLOOR", version: "0.124.89", gates: "The first chant whose product plan carries what terragucci's and sql-yodeler's plan jobs did themselves (#4963, #4951): `trade` (a plan's or a target's) before the checkout, `replan: { dispatch, reply, notAffected }` (a re-plan from `workflow_dispatch`, a reply to a comment no other job takes, `pr-post --not-affected`), `previousMarker` (`CHANT_PLAN_PREVIOUS_MARKER`), `noteSteps.pullRequest`, a `PrReport`'s `marker`, and a hand-off of the product's own note text (`planBodyHandoff`).", issue: "#4963", file: "ci-product.ts", modules: ["@intentius/chant/ci-product"] },
|
|
52
52
|
{ name: "PRODUCT_PLAN_SUBJECT_FLOOR", version: "0.124.89", gates: "The first chant whose note job compares the plan's subject with the previous note's (#4972), on GitHub, Forgejo and GitLab: a plan note hand-off's `subject` (`PrPlanSubject`, an id and named parts) is kept in the note, and `pr-post` adds the note words' `sinceLast` line, naming the parts added, gone and changed (`subjectParts`), when the previous note kept another id.", issue: "#4972", file: "ci-product.ts", modules: ["@intentius/chant/ci-product"] },
|
|
53
|
-
{ name: "PRODUCT_PLAN_NAMES_FLOOR", version:
|
|
54
|
-
{ name: "PRODUCT_PLAN_ARTIFACTS_FLOOR", version:
|
|
53
|
+
{ name: "PRODUCT_PLAN_NAMES_FLOOR", version: "0.124.91", gates: "The first chant whose product plan keeps a product's own names (#5003): `workflowFile` (the generators' `path`), `jobNames` (the plan, note, re-plan and re-plan note jobs, with `{target}`), `statusContext` (which `pr-post --context`, the pending step, the stale job and the apply before merge use) and `reportDir` (`{output}`, the hand-off, the artifact's path and `pr-post --output`), and whose `pr-post --open` finds a plan job of the product's name (`--plan-job`).", issue: "#5003", file: "ci-product.ts", modules: ["@intentius/chant/ci-product"] },
|
|
54
|
+
{ name: "PRODUCT_PLAN_ARTIFACTS_FLOOR", version: "0.124.91", gates: "The first chant whose GitLab product plan job keeps a product's own artifacts beside the report directory (#5004): `productPlan.artifacts: { paths, reports }`, as `artifacts:paths` and `artifacts:reports`, such as terragucci's `terraform` report for the merge request's widget, with `{target}` and `{output}` filled.", issue: "#5004", file: "ci-product.ts", modules: ["@intentius/chant/ci-product"] },
|
|
55
|
+
{ name: "PRODUCT_PLAN_LOGIN_TOKENS_FLOOR", version: NEXT_RELEASE, gates: "The first chant whose GitHub and Forgejo product plan, after a `login` or with `idTokens`, starts every step after the checkout but the login's without `ACTIONS_ID_TOKEN_REQUEST_URL` and `ACTIONS_ID_TOKEN_REQUEST_TOKEN` (#5021), as after a `trade`: the setup, the probe and the plan step, in the plan and the re-plan job, so the change's code can request no token.", issue: "#5021", file: "ci-product.ts", modules: ["@intentius/chant/ci-product"] },
|
|
56
|
+
{ name: "PR_HEAD_SHA_FLOOR", version: NEXT_RELEASE, gates: "The first chant whose pull request jobs on GitHub and Forgejo name the pull request's head, `github.event.pull_request.head.sha`, where `github.sha` named the merge preview (#5020): the product plan's pending step (`CHANT_PENDING_SHA`), the note job's `HEAD_SHA` (the product plan's, the pull request loop's and the product pipeline's) and the `env-post` job's.", issue: "#5020", file: "ci-product.ts", modules: ["@intentius/chant/ci-product"] },
|
|
57
|
+
{ name: "OP_WAVES_NAMES_FLOOR", version: NEXT_RELEASE, gates: "The first chant whose Op waves generators keep a product's own names (#5022): `jobNames` (every job they write: a wave's, deciding, share and job group jobs, a split wave's plan, gate, apply and record jobs, the policy and evidence jobs, the apply status, stale, before-merge done and control jobs; `needs:`, `if:`, `{job}` and `--from-job` follow it), `stageNames` (GitLab), `artifactNames` (the outcome, decision, saved plan and check claims artifacts, and the pattern a wave job downloads the earlier outcomes with), `workflowFile` (the generators' file and the follow-on's dispatch), `runIf` (the jobs go in the product's own workflow, each running on a push it admits or a before-merge or follow-on dispatch, with its own permissions; on GitLab joined to every rule) and `dispatchInputs` (the dispatch inputs' names, which the comment job's dispatch and the follow-on use), with `buildForgejoOpWavesDoc` for the Forgejo jobs, and whose product pipeline's `wavesBeforeMerge` takes `workflowFile` and `dispatchInputs`.", issue: "#5022", file: "ci-product.ts", modules: ["@intentius/chant/ci-product"] },
|
|
58
|
+
{ name: "PRODUCT_JOB_NAMES_FLOOR", version: NEXT_RELEASE, gates: "The first chant whose product pipeline names its comment job and its waves' jobs as the product does (#5027): `commentJob: { jobName }` (default `comment`, such as terragucci's `apply-comment`), refused when another job of the workflow has the name, and `wavesJobNames`, the Op waves generators' `jobNames`, which `waves.pipeline` carries to the generator and `waves.jobs` takes, and under which the comment job's re-run of a merged pull request's apply looks for the waves' jobs (`CHANT_COMMENT_JOBS` `applyJobs`, `rerunApplyJobs`), so terragucci's `apply-wave-<k>`, `-share-<n>`, group jobs and `apply-rest` run again.", issue: "#5027", file: "ci-product.ts", modules: ["@intentius/chant/ci-product"] },
|
|
55
59
|
{ name: "PRODUCT_ACTIONS_FLOOR", version: "0.124.58", gates: "Day-2 actions in the product pipeline (#4654): the `action` comment command counted as answered by the product's own workflow (`productPipelineJobs(forge, env, { words, actions: true })`), or the pipeline's own action job (`actionJob`, `build --pr-loop --action-job`), which answers the comment and a dispatch with a member and an action input, and runs the product's action verb with `--from-event`.", issue: "#4654", file: "ci-product.ts", modules: ["@intentius/chant/ci-product"] },
|
|
56
60
|
{ name: "APPROVAL_STATUS_FLOOR", version: "0.124.56", gates: "The approval status before merge (#4630): under a `pr-review` wave, the op waves generators add a job that posts `<product>/approval` on each open pull request's head.", issue: "#4630", file: "ci-product.ts", modules: ["@intentius/chant/ci-product"] },
|
|
57
61
|
{ name: "APPROVAL_STATUS_PULL_REQUEST_FLOOR", version: "0.124.56", gates: "The approval status for `pull-request` waves too (#4630, 2026-10-28 ruling): the generators add the record-plans and approval-status jobs for a spec whose waves take the pull request's own approval, and the status reads that approval's coverage of each wave's change set.", issue: "#4630", file: "ci-product.ts", modules: ["@intentius/chant/ci-product"] },
|
|
@@ -216,16 +220,16 @@ export const FLOOR_ROWS: readonly FloorRow[] = [
|
|
|
216
220
|
{ name: "CHECK_JOB_ARTIFACTS_FLOOR", version: "0.124.90", gates: "The first chant whose `checkJob` takes `artifacts: { paths, reports }` (`PrCheckArtifacts`), which GitLab's check job keeps beside its report as `artifacts:paths` and `artifacts:reports`, such as a lint hook's `codequality` report (#4988).", issue: "#4988", file: "release-floors.ts", modules: ["@intentius/chant/components/pr-checks","@intentius/chant/release-floors"] },
|
|
217
221
|
{ name: "GITLAB_WAVE_KEY_SCOPE_FLOOR", version: "0.124.89", gates: "The first chant whose GitLab Op waves pipeline with a runner key hands it to no wave job: each deciding wave's `<wave job>-evidence` job names the `chant-evidence` environment and signs `plan:<wave>` from the wave job (#4964).", issue: "#4964", file: "release-floors.ts", modules: ["@intentius/chant/ci-evidence-jobs","@intentius/chant/release-floors"] },
|
|
218
222
|
{ name: "ACTOR_ORDER_FLOOR", version: "0.124.89", gates: "The first chant with `actorOf` and `actorOrder` in `@intentius/chant/actor`: the actor fallback with `GITHUB_TRIGGERING_ACTOR` ahead of the forge's actor and git's `user.name` before the login, each place switched on or off by the caller (#4966).", issue: "#4966", file: "release-floors.ts", modules: ["@intentius/chant/actor","@intentius/chant/release-floors"] },
|
|
219
|
-
{ name: "ACTOR_GIT_ENV_FLOOR", version:
|
|
223
|
+
{ name: "ACTOR_GIT_ENV_FLOOR", version: "0.124.91", gates: "The first chant whose `actorOf({ env, repo })` runs `git config` in `repo` with the `env` it is given rather than the process's, so a job's `GIT_CONFIG_GLOBAL` or `HOME` picks the `user.name` it reads (#5005).", issue: "#5005", file: "release-floors.ts", modules: ["@intentius/chant/actor","@intentius/chant/release-floors"] },
|
|
220
224
|
{ name: "CI_BASE_REF_FLOOR", version: "0.124.89", gates: "The first chant with `@intentius/chant/ci-base` (`ciBaseRef`), the base a CI job measures a change from (the pull request's target branch, else the default branch for a push to another branch), and whose `chant ci check` defaults `--base` to it (#4966).", issue: "#4966", file: "release-floors.ts", modules: ["@intentius/chant/ci-base","@intentius/chant/release-floors"] },
|
|
221
225
|
{ name: "PLANNED_FILES_FLOOR", version: "0.124.89", gates: "The first chant with `@intentius/chant/planned-files` (`planFile`, `planRemoval`, `writePlannedFiles`, `staleGeneratedFiles`): an init's planned files with their modes, written or removed in one call, and the generated files a product no longer renders, found by their header (#4966).", issue: "#4966", file: "release-floors.ts", modules: ["@intentius/chant/planned-files","@intentius/chant/release-floors"] },
|
|
222
|
-
{ name: "PLANNED_BYTES_FLOOR", version:
|
|
226
|
+
{ name: "PLANNED_BYTES_FLOOR", version: "0.124.91", gates: "The first chant whose `planFile` in `@intentius/chant/planned-files` takes bytes (`Uint8Array` or `Buffer`) as well as text: `writePlannedFiles` writes them unchanged and the plan compares them with the file byte for byte (#5006).", issue: "#5006", file: "release-floors.ts", modules: ["@intentius/chant/planned-files","@intentius/chant/release-floors"] },
|
|
223
227
|
{ name: "FORGE_CHECK_OWN_JOBS_FLOOR", version: "0.124.89", gates: "The first chant whose `pipelineContract` takes `jobs`, the jobs a product builds from its own config, beside or in place of `pipelines`, so a product's forge check gets the required statuses and `refGateStatus` from chant (#4966).", issue: "#4966", file: "release-floors.ts", modules: ["@intentius/chant/forge-check","@intentius/chant/forge-check/index","@intentius/chant/release-floors"] },
|
|
224
228
|
{ name: "BEFORE_MERGE_REF_GATE_FLOOR", version: "0.124.89", gates: "The first chant whose `chant components pr-apply --before-merge` waits for the ref gate's status: the status the policy at base sets for the target branch is passed as `require` to the `checks` require (#4966).", issue: "#4966", file: "release-floors.ts", modules: ["@intentius/chant/release-floors"] },
|
|
225
229
|
{ name: "TARGET_SIGNED_CHECKS_FLOOR", version: "0.124.89", gates: "The first chant whose product plan with `targets` and `evidence` signs each target's plan job as `plan:<target>` and `policy:<target>` (`ci evidence sign --member <target>`, `targetEvidenceCheck`, `productPlanEvidenceChecks`), and whose `refGateInitPlan` takes `targets` and names those checks in the `refs` rule (#4978).", issue: "#4978", file: "release-floors.ts", modules: ["@intentius/chant/ci-evidence-jobs","@intentius/chant/ref-gate-init","@intentius/chant/release-floors"] },
|
|
226
230
|
{ name: "RUNTIME_WAVES_SPEC_FLOOR", version: "0.124.89", gates: "The first chant whose Op waves generators take `renderSpec` (the wave jobs run `chant run wave --render-spec`, and `CHANT_WAVES_SPEC_COMMAND` names the product command that prints the spec at the commit in `CHANT_WAVES_SPEC_AT`), so a product whose spec is built from its config at base renders its wave jobs, policy step, evidence job and cloud trade through chant (#4982).", issue: "#4982", file: "release-floors.ts", modules: ["@intentius/chant/op","@intentius/chant/op/index","@intentius/chant/op/op-waves-render-spec","@intentius/chant/release-floors"] },
|
|
227
231
|
{ name: "GITLAB_WAVE_EVIDENCE_RETRY_FLOOR", version: "0.124.89", gates: "The first chant whose `chant run resume` (`resumeGateRun`) on GitLab retries a wave job's `<wave job>-evidence` with the wave job when the evidence job already ran, and whose `ci evidence sign --from-job` waits for a job it reads to finish, so a resumed wave's evidence job signs from the new try (#4978).", issue: "#4978", file: "release-floors.ts", modules: ["@intentius/chant/ci-evidence-jobs","@intentius/chant/release-floors"] },
|
|
228
|
-
{ name: "TERRAFORM_COMMAND_TRACE_FLOOR", version:
|
|
232
|
+
{ name: "TERRAFORM_COMMAND_TRACE_FLOOR", version: "0.124.91", gates: "The first chant whose terraform lexicon's engine runs carry what a product's own command tracing read: `runBinary` and the engine runner's `exec` and `execSync` answer stderr apart (`Ran.stderr`) and a spawn failure's message (`Ran.error`), a hook's `after` gets a binary that could not be started as a null code with `error`, `commandTrace` ends that span with the message, and `composeCommandHooks` runs a product's own hook and `commandTrace` as one `onCommand` (#5007).", issue: "#5007", file: "release-floors.ts", modules: ["@intentius/chant/release-floors"] },
|
|
229
233
|
{ name: "RUN_EVENT_FLOOR", version: "0.124.28", gates: "The first chant that writes contract version 1 of the run-event stream.", file: "run-event.ts", modules: ["@intentius/chant","@intentius/chant/index","@intentius/chant/run-event"] },
|
|
230
234
|
{ name: "RUN_EVENT_FAILURE_FLOOR", version: "0.124.30", gates: "The first chant that writes `failure` on `run-settle` (#4094).", issue: "#4094", file: "run-event.ts", modules: ["@intentius/chant","@intentius/chant/index","@intentius/chant/run-event"] },
|
|
231
235
|
{ name: "RUN_EVENT_COMPONENT_SKIP_FLOOR", version: "0.124.29", gates: "The first chant that writes `blocked`, `already-applied` and `blockedBy` on `component-settle` (#4007).", issue: "#4007", file: "run-event.ts", modules: ["@intentius/chant","@intentius/chant/index","@intentius/chant/run-event"] },
|
package/src/lexicon.ts
CHANGED
|
@@ -1231,6 +1231,46 @@ export interface OpWavesPipelineOptions
|
|
|
1231
1231
|
* target. On GitLab it posts with `CHANT_FORGE_TOKEN`.
|
|
1232
1232
|
*/
|
|
1233
1233
|
staleNotes?: { command: string; env: Record<string, string> };
|
|
1234
|
+
/**
|
|
1235
|
+
* A product's job names (#5022, `@intentius/chant/op/op-waves-names`): a
|
|
1236
|
+
* function that gives each job the generator writes (a wave's job, its
|
|
1237
|
+
* deciding, share and job group jobs, a split wave's plan, gate, apply
|
|
1238
|
+
* and record jobs, the policy and evidence jobs, the apply status, stale,
|
|
1239
|
+
* before-merge done and control jobs) the product's name, or undefined
|
|
1240
|
+
* for chant's. Every `needs:`, `if:`, `{job}` and `--from-job` follows
|
|
1241
|
+
* it. A name the forge cannot take, and two jobs that share one, are
|
|
1242
|
+
* refused. Absent: chant's names.
|
|
1243
|
+
*/
|
|
1244
|
+
jobNames?: import("./op/op-waves-names").OpWavesJobNames;
|
|
1245
|
+
/** GitLab (#5022): a product's stage names, as {@link jobNames}. Two stages may share one, such as terragucci's `apply`. Absent: chant's. */
|
|
1246
|
+
stageNames?: import("./op/op-waves-names").OpWavesStageNames;
|
|
1247
|
+
/** GitHub and Forgejo (#5022): the outcome, decision, saved plan and check claims artifacts' names, and the pattern a wave job downloads the earlier outcomes with. Absent: chant's. */
|
|
1248
|
+
artifactNames?: import("./op/op-waves-names").OpWavesArtifactNames;
|
|
1249
|
+
/**
|
|
1250
|
+
* GitHub and Forgejo (#5022): the workflow file the jobs go in, such as
|
|
1251
|
+
* `terragucci.yml`: the generator's file, and the one a rest wave's
|
|
1252
|
+
* record job dispatches. GitLab takes `opsFileName`. Absent: `<spec>.yml`.
|
|
1253
|
+
*/
|
|
1254
|
+
workflowFile?: string;
|
|
1255
|
+
/**
|
|
1256
|
+
* The jobs go in a product's own workflow or pipeline beside its other
|
|
1257
|
+
* jobs (#5022). GitHub and Forgejo: an expression (without `${{ }}`)
|
|
1258
|
+
* for the push the waves run on, such as `github.ref ==
|
|
1259
|
+
* format('refs/heads/{0}', github.event.repository.default_branch)`;
|
|
1260
|
+
* each job runs only on such a push, or a before-merge or follow-on
|
|
1261
|
+
* dispatch of its own inputs, and carries its permissions itself. GitLab:
|
|
1262
|
+
* a condition joined with `&&` to every rule of every job. Absent: the
|
|
1263
|
+
* jobs are the workflow's own, as before.
|
|
1264
|
+
*/
|
|
1265
|
+
runIf?: string;
|
|
1266
|
+
/**
|
|
1267
|
+
* GitHub and Forgejo (#5022): the names of the `workflow_dispatch`
|
|
1268
|
+
* inputs `pr`, `head`, `digest` (before merge) and `wave`, `commit` (a
|
|
1269
|
+
* rest wave's follow-on), so they never meet the product's own, such as
|
|
1270
|
+
* a re-plan's `pr`. The comment job dispatches them by the same names
|
|
1271
|
+
* (`wavesBeforeMerge.dispatchInputs`). Absent: chant's.
|
|
1272
|
+
*/
|
|
1273
|
+
dispatchInputs?: Partial<Record<import("./op/op-waves-names").OpWavesDispatchInput, string>>;
|
|
1234
1274
|
}
|
|
1235
1275
|
|
|
1236
1276
|
/** A run step a product adds to a generated job (#4791): its name, and its shell lines in order. */
|
|
@@ -1264,7 +1304,8 @@ export interface OpWaveJobInputs {
|
|
|
1264
1304
|
report?: OpWaveRunStep;
|
|
1265
1305
|
/**
|
|
1266
1306
|
* Files the job keeps as an artifact whatever its exit. `{job}` in
|
|
1267
|
-
* `name` is the job's name
|
|
1307
|
+
* `name` is the job's name (#5022: the product's, under `jobNames`), so
|
|
1308
|
+
* a wide wave's jobs keep one each. GitHub
|
|
1268
1309
|
* and Forgejo: an upload step named `step` after the report. GitLab: the
|
|
1269
1310
|
* path joins the job's `artifacts:`, which keep the outcome files too,
|
|
1270
1311
|
* under `name`.
|
|
@@ -45,6 +45,8 @@ import type { BeforeMergeDecision, BeforeMergeRecord } from "./before-merge";
|
|
|
45
45
|
export interface WavesBeforeMergeJobs {
|
|
46
46
|
/** GitHub and Forgejo: the waves workflow's file, which the comment job dispatches. */
|
|
47
47
|
workflow?: string;
|
|
48
|
+
/** GitHub and Forgejo (#5022): the product's names of the dispatch inputs `pr`, `head` and `digest`, as the waves workflow takes them. Default chant's. */
|
|
49
|
+
inputs?: Partial<Record<"pr" | "head" | "digest", string>>;
|
|
48
50
|
/** The requires the forge is asked (`apply.requires`). Default every one. */
|
|
49
51
|
requires?: PrApplyRequire[];
|
|
50
52
|
/** The statuses that must have passed on the head: the product plan's `<product>/plan`, or one per target. */
|
|
@@ -87,12 +87,13 @@ export function opWavePolicyStepName(wave: number, name: string): string {
|
|
|
87
87
|
/**
|
|
88
88
|
* The evidence job's `CHANT_EVIDENCE_SOURCES`: on GitHub and Forgejo the
|
|
89
89
|
* command step for `plan:<wave>` and the policy step for `policy:<wave>`, by
|
|
90
|
-
* name; on GitLab the wave job and its policy job
|
|
90
|
+
* name; on GitLab the wave job and its policy job (`policyJob`, a
|
|
91
|
+
* product's name for it, #5022).
|
|
91
92
|
*/
|
|
92
|
-
export function opWaveEvidenceSources(forge: "github" | "forgejo" | "gitlab", plan: OpWaveEvidencePlan, job: Pick<OpWaveJob, "jobName" | "wave">, waveName: string, commandStep: string): Record<string, EvidenceSourceSpec> {
|
|
93
|
+
export function opWaveEvidenceSources(forge: "github" | "forgejo" | "gitlab", plan: OpWaveEvidencePlan, job: Pick<OpWaveJob, "jobName" | "wave">, waveName: string, commandStep: string, policyJob = opWavePolicyJobName(job)): Record<string, EvidenceSourceSpec> {
|
|
93
94
|
const out: Record<string, EvidenceSourceSpec> = {};
|
|
94
95
|
for (const check of plan.evidenceJob?.checks ?? []) {
|
|
95
|
-
if (forge === "gitlab") out[check] = check === plan.policy ? { job:
|
|
96
|
+
if (forge === "gitlab") out[check] = check === plan.policy ? { job: policyJob } : {};
|
|
96
97
|
else out[check] = { step: check === plan.policy ? opWavePolicyStepName(job.wave, waveName) : commandStep };
|
|
97
98
|
}
|
|
98
99
|
return out;
|
|
@@ -74,6 +74,8 @@ export interface OpWavesFollowOnTarget {
|
|
|
74
74
|
forge: "github" | "forgejo" | "gitlab";
|
|
75
75
|
/** GitHub and Forgejo: the waves workflow's file name, which the record job dispatches. */
|
|
76
76
|
workflow?: string;
|
|
77
|
+
/** GitHub and Forgejo (#5022): the product's names of the dispatch inputs `pr`, `head`, `digest`, `wave` and `commit`, when it renamed any. */
|
|
78
|
+
inputs?: Partial<Record<"pr" | "head" | "digest" | "wave" | "commit", string>>;
|
|
77
79
|
}
|
|
78
80
|
|
|
79
81
|
/** The rest wave's number when the spec's last wave has `rest`, else undefined. */
|
|
@@ -107,7 +109,11 @@ export function parseFollowOnTarget(raw: string | undefined): OpWavesFollowOnTar
|
|
|
107
109
|
const o = v as Partial<OpWavesFollowOnTarget> | null;
|
|
108
110
|
if (!o || (o.forge !== "github" && o.forge !== "forgejo" && o.forge !== "gitlab")) throw new Error(`${OP_WAVES_FOLLOW_ON_ENV}.forge is github, forgejo or gitlab`);
|
|
109
111
|
if (o.forge !== "gitlab" && (typeof o.workflow !== "string" || !/^[A-Za-z0-9._-]+\.ya?ml$/.test(o.workflow))) throw new Error(`${OP_WAVES_FOLLOW_ON_ENV}.workflow names the waves workflow's file`);
|
|
110
|
-
|
|
112
|
+
const inputs = o.inputs;
|
|
113
|
+
if (inputs !== undefined && (typeof inputs !== "object" || inputs === null || Object.entries(inputs).some(([k, n]) => !["pr", "head", "digest", "wave", "commit"].includes(k) || typeof n !== "string" || !/^[A-Za-z_][A-Za-z0-9_-]*$/.test(n)))) {
|
|
114
|
+
throw new Error(`${OP_WAVES_FOLLOW_ON_ENV}.inputs names the dispatch inputs pr, head, digest, wave and commit`);
|
|
115
|
+
}
|
|
116
|
+
return { forge: o.forge, ...(o.workflow ? { workflow: o.workflow } : {}), ...(inputs ? { inputs: { ...inputs } } : {}) };
|
|
111
117
|
}
|
|
112
118
|
|
|
113
119
|
/**
|
|
@@ -380,6 +386,8 @@ export async function startFollowOn(target: OpWavesFollowOnTarget, wave: number,
|
|
|
380
386
|
}
|
|
381
387
|
const ref = env.GITHUB_REF_NAME?.trim() || env.GITHUB_REF?.replace(/^refs\/heads\//, "");
|
|
382
388
|
if (!ref) throw new Error("the job names no branch (no GITHUB_REF_NAME)");
|
|
383
|
-
|
|
389
|
+
// #5022: the inputs under the product's names, when it renamed them.
|
|
390
|
+
const inputs = Object.fromEntries(Object.entries(values).map(([k, v]) => [target.inputs?.[k as keyof NonNullable<OpWavesFollowOnTarget["inputs"]>] ?? k, v]));
|
|
391
|
+
await post(`${t.apiBase}/repos/${t.repo}/actions/workflows/${encodeURIComponent(target.workflow!)}/dispatches`, { Authorization: `token ${t.token}` }, { ref, inputs });
|
|
384
392
|
return {};
|
|
385
393
|
}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* #5022: a product's own names in an Op waves pipeline: the job names and
|
|
3
|
+
* their needs, the dispatch inputs and artifact names, the follow-on
|
|
4
|
+
* dispatch under the product's workflow and inputs, and the product
|
|
5
|
+
* pipeline's before-merge workflow and inputs.
|
|
6
|
+
*/
|
|
7
|
+
import { describe, expect, test } from "vitest";
|
|
8
|
+
import { opWaveJobs, type OpWavesSpec } from "./op-waves";
|
|
9
|
+
import { opWaveSplitJobs } from "./op-waves-split";
|
|
10
|
+
import { opWavesArtifacts, opWavesDispatchInputs, opWavesInputsRenamed, opWavesNamer, opWavesWorkflowFile, type OpWavesJobRef } from "./op-waves-names";
|
|
11
|
+
import { parseFollowOnTarget, startFollowOn } from "./op-waves-follow-on";
|
|
12
|
+
import { productPipelineJobs } from "../components/product-pipeline";
|
|
13
|
+
|
|
14
|
+
const spec = {
|
|
15
|
+
name: "tf-apply",
|
|
16
|
+
op: "tf-apply",
|
|
17
|
+
planWave: ["terragucci", "plan-wave", "{runs}", "{plans}"],
|
|
18
|
+
apply: ["terragucci", "apply", "{target}", "--plan", "{plan}"],
|
|
19
|
+
waves: [
|
|
20
|
+
{ name: "canary", runs: [], discover: true },
|
|
21
|
+
{ name: "wide", runs: [], discover: true, shares: 2 },
|
|
22
|
+
{ name: "rest", runs: [], discover: true, rest: true },
|
|
23
|
+
],
|
|
24
|
+
} as unknown as OpWavesSpec;
|
|
25
|
+
|
|
26
|
+
const terragucci = (j: OpWavesJobRef): string | undefined => {
|
|
27
|
+
const w = j.rest ? "apply-rest" : `apply-wave-${j.wave}`;
|
|
28
|
+
if (j.role === "wave" || j.role === "decide") return w;
|
|
29
|
+
if (j.role === "share") return `${w}-share-${j.share}`;
|
|
30
|
+
if (j.role === "plan" || j.role === "gate" || j.role === "record") return `${w}-${j.role}`;
|
|
31
|
+
if (j.role === "apply") return j.share !== undefined ? `${w}-share-${j.share}` : w;
|
|
32
|
+
return undefined;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
describe("the job names (#5022)", () => {
|
|
36
|
+
test("each job takes the product's name, and its needs follow", () => {
|
|
37
|
+
const jobs = opWavesNamer(spec, "github", terragucci).jobs(opWaveJobs(spec, "s.json"));
|
|
38
|
+
expect(jobs.map((j) => [j.jobName, j.needs])).toEqual([
|
|
39
|
+
["apply-wave-1", []],
|
|
40
|
+
["apply-wave-2", ["apply-wave-1"]],
|
|
41
|
+
["apply-wave-2-share-1", ["apply-wave-2"]],
|
|
42
|
+
["apply-wave-2-share-2", ["apply-wave-2"]],
|
|
43
|
+
["apply-rest", ["apply-wave-2-share-1", "apply-wave-2-share-2"]],
|
|
44
|
+
]);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
test("a split pipeline's jobs, and the rest wave's, take theirs", () => {
|
|
48
|
+
const split = opWavesNamer(spec, "github", terragucci).jobs(opWaveSplitJobs(spec, opWaveJobs(spec, "s.json", { beforeMerge: true })));
|
|
49
|
+
expect(split.filter((j) => j.wave === 3).map((j) => [j.jobName, j.needs])).toEqual([
|
|
50
|
+
["apply-rest-plan", ["apply-wave-2-record"]],
|
|
51
|
+
["apply-rest-gate", ["apply-rest-plan"]],
|
|
52
|
+
["apply-rest", ["apply-rest-gate"]],
|
|
53
|
+
["apply-rest-record", ["apply-rest", "apply-rest-gate"]],
|
|
54
|
+
]);
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
test("without names, chant's; the same job asked twice keeps its name", () => {
|
|
58
|
+
const namer = opWavesNamer(spec, "gitlab", undefined);
|
|
59
|
+
expect(namer.jobs(opWaveJobs(spec, "s.json")).map((j) => j.jobName)).toEqual(["wave-1-canary", "wave-2-wide-decide", "wave-2-wide-share-1", "wave-2-wide-share-2", "wave-3-rest"]);
|
|
60
|
+
expect(namer.name({ role: "control", name: "control-dispatch" })).toBe("control-dispatch");
|
|
61
|
+
expect(namer.name({ role: "control", name: "control-dispatch" })).toBe("control-dispatch");
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
test("refuses a name the forge cannot take, and two jobs that share one", () => {
|
|
65
|
+
const jobs = opWaveJobs(spec, "s.json");
|
|
66
|
+
expect(() => opWavesNamer(spec, "github", () => "1-apply").jobs(jobs)).toThrow(/not a job name/);
|
|
67
|
+
expect(() => opWavesNamer(spec, "gitlab", (j) => (j.role === "wave" ? "stages" : undefined)).jobs(jobs)).toThrow(/no GitLab keyword/);
|
|
68
|
+
expect(() => opWavesNamer(spec, "github", (j) => (j.role === "share" ? "apply" : undefined)).jobs(jobs)).toThrow(/names two jobs apply: wave-2-wide-share-1 and wave-2-wide-share-2/);
|
|
69
|
+
const namer = opWavesNamer(spec, "github", (j) => (j.role === "apply-status" ? "control-dispatch" : undefined));
|
|
70
|
+
namer.name({ role: "control", name: "control-dispatch" });
|
|
71
|
+
expect(() => namer.name({ role: "apply-status", name: "apply-status-1", wave: 1 })).toThrow(/names two jobs control-dispatch/);
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
describe("the dispatch inputs, artifacts and workflow file (#5022)", () => {
|
|
76
|
+
test("the inputs are chant's unless renamed, each a name and none twice", () => {
|
|
77
|
+
expect(opWavesDispatchInputs(undefined)).toEqual({ pr: "pr", head: "head", digest: "digest", wave: "wave", commit: "commit" });
|
|
78
|
+
expect(opWavesInputsRenamed(opWavesDispatchInputs({ pr: "pr" }))).toBe(false);
|
|
79
|
+
expect(opWavesDispatchInputs({ pr: "apply_pr", head: "apply_head" })).toMatchObject({ pr: "apply_pr", head: "apply_head", digest: "digest" });
|
|
80
|
+
expect(() => opWavesDispatchInputs({ pr: "head" })).toThrow(/names two inputs head: pr and head/);
|
|
81
|
+
expect(() => opWavesDispatchInputs({ pr: "a b" })).toThrow(/not an input name/);
|
|
82
|
+
expect(() => opWavesDispatchInputs({ root: "r" } as never)).toThrow(/none of pr, head, digest, wave and commit/);
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
test("the artifacts are chant's unless named, each template holding its mark", () => {
|
|
86
|
+
const chant = opWavesArtifacts(spec, undefined);
|
|
87
|
+
expect([chant.outcome("wave-1-canary"), chant.decision(2), chant.plan(2), chant.checks("j"), chant.earlier]).toEqual(["tf-apply-wave-1-canary-outcome", "tf-apply-wave-2-decision", "tf-apply-wave-2-plan", "tf-apply-j-checks", undefined]);
|
|
88
|
+
const tg = opWavesArtifacts(spec, { outcome: "terragucci-report-{job}-outcome", decision: "terragucci-wave-{wave}", earlier: "terragucci-report-apply-wave-*" });
|
|
89
|
+
expect([tg.outcome("apply-wave-1"), tg.decision(2), tg.earlier]).toEqual(["terragucci-report-apply-wave-1-outcome", "terragucci-wave-2", "terragucci-report-apply-wave-*"]);
|
|
90
|
+
expect(() => opWavesArtifacts(spec, { outcome: "outcome" })).toThrow(/artifactNames\.outcome "outcome" holds \{job\}/);
|
|
91
|
+
expect(() => opWavesArtifacts(spec, { decision: "d/{wave}" })).toThrow(/artifactNames\.decision/);
|
|
92
|
+
expect(() => opWavesArtifacts(spec, { decision: "w-{wave}", plan: "w-{wave}" })).toThrow(/the decision and the saved plan one name/);
|
|
93
|
+
expect(() => opWavesArtifacts(spec, { earlier: "a/b" })).toThrow(/artifactNames\.earlier/);
|
|
94
|
+
expect(opWavesWorkflowFile(spec, undefined)).toBe("tf-apply.yml");
|
|
95
|
+
expect(opWavesWorkflowFile(spec, "terragucci.yml")).toBe("terragucci.yml");
|
|
96
|
+
expect(() => opWavesWorkflowFile(spec, ".github/workflows/terragucci.yml")).toThrow(/workflow file's name/);
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
describe("the follow-on under the product's workflow and inputs (#5022)", () => {
|
|
101
|
+
test("the record job dispatches the product's workflow with its input names", async () => {
|
|
102
|
+
const target = parseFollowOnTarget(JSON.stringify({ forge: "github", workflow: "terragucci.yml", inputs: opWavesDispatchInputs({ pr: "apply_pr", head: "apply_head", digest: "apply_digest", wave: "apply_wave", commit: "apply_commit" }) }))!;
|
|
103
|
+
const posts: Array<{ url: string; body: unknown }> = [];
|
|
104
|
+
const fetchFn = (async (url: string, init: { body: string }) => (posts.push({ url, body: JSON.parse(init.body) }), new Response(null, { status: 204 }))) as unknown as typeof fetch;
|
|
105
|
+
const HEAD = "a".repeat(40);
|
|
106
|
+
const env = { GITHUB_REPOSITORY: "acme/infra", GITHUB_API_URL: "https://api.github.com", GITHUB_REF_NAME: "main", CHANT_WAVES_FOLLOW_ON_TOKEN: "t" };
|
|
107
|
+
await startFollowOn(target, 4, { ...env, CHANT_BEFORE_MERGE_PR: "7", CHANT_BEFORE_MERGE_HEAD: HEAD, CHANT_BEFORE_MERGE_DIGEST: `sha256:${"e".repeat(64)}` }, fetchFn);
|
|
108
|
+
expect(posts.at(-1)).toEqual({ url: "https://api.github.com/repos/acme/infra/actions/workflows/terragucci.yml/dispatches", body: { ref: "main", inputs: { apply_pr: "7", apply_head: HEAD, apply_digest: `sha256:${"e".repeat(64)}`, apply_wave: "4" } } });
|
|
109
|
+
await startFollowOn(target, 4, { ...env, CHANT_WAVES_COMMIT: "d".repeat(40) }, fetchFn);
|
|
110
|
+
expect(posts.at(-1)!.body).toEqual({ ref: "main", inputs: { apply_wave: "4", apply_commit: "d".repeat(40) } });
|
|
111
|
+
expect(() => parseFollowOnTarget(JSON.stringify({ forge: "github", workflow: "x.yml", inputs: { root: "r" } }))).toThrow(/inputs names the dispatch inputs/);
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
describe("the product pipeline's waves before merge in a product's workflow (#5022)", () => {
|
|
116
|
+
const words = { product: "terragucci", noun: ["root", "roots"] as [string, string], commands: { plan: "plan" as const, apply: "apply" as const }, approval: "per-wave" as const, op: "tf-apply", bin: "terragucci" };
|
|
117
|
+
const waves = { name: "tf-apply", op: "tf-apply", step: { kind: "terraform-apply", root: "{target}" }, waves: [{ name: "dev", runs: [{ target: "envs/dev" }] }] } as OpWavesSpec;
|
|
118
|
+
const productPlan = { command: "terragucci plan --out {output}" };
|
|
119
|
+
|
|
120
|
+
test("the comment job dispatches the product's workflow by its input names, and the generator is handed both", () => {
|
|
121
|
+
const dispatchInputs = { pr: "apply_pr", head: "apply_head", digest: "apply_digest" };
|
|
122
|
+
const jobs = productPipelineJobs("github", "default", { words, waves, productPlan, commentJob: true, wavesBeforeMerge: { workflowFile: "terragucci.yml", dispatchInputs } });
|
|
123
|
+
expect(jobs.comment!.jobs.wavesBeforeMerge).toMatchObject({ workflow: "terragucci.yml", inputs: dispatchInputs });
|
|
124
|
+
expect(jobs.waves!.pipeline).toMatchObject({ workflowFile: "terragucci.yml", dispatchInputs });
|
|
125
|
+
const chant = productPipelineJobs("github", "default", { words, waves, productPlan, commentJob: true, wavesBeforeMerge: {} });
|
|
126
|
+
expect(chant.comment!.jobs.wavesBeforeMerge!.workflow).toBe("tf-apply.yml");
|
|
127
|
+
expect(chant.comment!.jobs.wavesBeforeMerge!.inputs).toBeUndefined();
|
|
128
|
+
expect(chant.waves!.pipeline.workflowFile).toBeUndefined();
|
|
129
|
+
expect(() => productPipelineJobs("gitlab", "default", { words, waves, productPlan: { ...productPlan, replan: true }, noteCommands: true, wavesBeforeMerge: { workflowFile: "terragucci.yml" } })).toThrow(/GitLab's note poll starts a pipeline with variables/);
|
|
130
|
+
});
|
|
131
|
+
});
|