@intentius/chant 0.124.92 → 0.124.93
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/__golden__/notify-defaults-plain.json +52 -0
- package/dist/__golden__/notify-defaults-relay.json +92 -0
- package/dist/ci-job-guard.d.ts +22 -8
- package/dist/ci-job-guard.d.ts.map +1 -1
- package/dist/ci-job-guard.js +93 -49
- package/dist/ci-jobs.d.ts +22 -0
- package/dist/ci-jobs.d.ts.map +1 -1
- package/dist/ci-jobs.js +23 -0
- package/dist/ci-product.d.ts +25 -1
- package/dist/ci-product.d.ts.map +1 -1
- package/dist/ci-product.js +29 -5
- package/dist/components/product-pipeline.d.ts +30 -0
- package/dist/components/product-pipeline.d.ts.map +1 -1
- package/dist/components/product-pipeline.js +28 -3
- package/dist/floor-table.data.d.ts.map +1 -1
- package/dist/floor-table.data.js +10 -4
- package/dist/lexicon.d.ts +17 -0
- package/dist/lexicon.d.ts.map +1 -1
- package/dist/notify.d.ts +8 -0
- package/dist/notify.d.ts.map +1 -1
- package/dist/notify.js +8 -3
- package/dist/op/before-merge.d.ts +8 -0
- package/dist/op/before-merge.d.ts.map +1 -1
- package/dist/op/before-merge.js +6 -0
- package/dist/op/index.d.ts +1 -1
- package/dist/op/index.d.ts.map +1 -1
- package/dist/op/index.js +1 -1
- package/dist/op/op-waves-names.d.ts +25 -2
- package/dist/op/op-waves-names.d.ts.map +1 -1
- package/dist/op/op-waves-names.js +50 -0
- package/dist/op/op-waves-run.d.ts +2 -0
- package/dist/op/op-waves-run.d.ts.map +1 -1
- package/dist/op/op-waves-run.js +2 -2
- package/dist/op/op-waves-stand-down.d.ts +9 -1
- package/dist/op/op-waves-stand-down.d.ts.map +1 -1
- package/dist/op/op-waves-stand-down.js +14 -2
- package/dist/op/op-waves.d.ts +12 -1
- package/dist/op/op-waves.d.ts.map +1 -1
- package/dist/op/op-waves.js +2 -0
- package/dist/release-floors.d.ts +1 -1
- package/dist/release-floors.js +1 -1
- package/dist/wave-runtime.mjs +298 -298
- package/package.json +1 -1
- package/src/__golden__/notify-defaults-plain.json +52 -0
- package/src/__golden__/notify-defaults-relay.json +92 -0
- package/src/ci-job-guard.default-branch.test.ts +125 -0
- package/src/ci-job-guard.ts +64 -10
- package/src/ci-jobs.ts +26 -0
- package/src/ci-product.ts +35 -5
- package/src/components/product-pipeline.ts +49 -4
- package/src/floor-table.data.ts +10 -4
- package/src/lexicon.ts +17 -0
- package/src/notify-bundle.test.ts +3 -2
- package/src/notify-relay-name.test.ts +72 -0
- package/src/notify.ts +16 -3
- package/src/op/before-merge.ts +12 -0
- package/src/op/index.ts +1 -1
- package/src/op/op-waves-names.ts +50 -2
- package/src/op/op-waves-run.ts +4 -2
- package/src/op/op-waves-stand-down.ts +15 -2
- package/src/op/op-waves.ts +13 -1
- package/src/release-floors.ts +1 -1
|
@@ -155,6 +155,16 @@ export interface ProductPipelineOptions extends Omit<PrLoopPipelineOptions, "wor
|
|
|
155
155
|
* `apply-comment`. Default `comment`.
|
|
156
156
|
*/
|
|
157
157
|
commentJob?: boolean | ProductCommentJobOptions;
|
|
158
|
+
/**
|
|
159
|
+
* GitLab's note poll under the product's names (#5038), with
|
|
160
|
+
* `noteCommands`: its job's name (default `note-commands`), its stage
|
|
161
|
+
* (default the job's name), and the variable and value a pipeline
|
|
162
|
+
* schedule starts it with (default `CHANT_NOTE_COMMANDS` and `1`), such
|
|
163
|
+
* as terragucci's `comments` job, which `TERRAGUCCI_SCHEDULE=comments`
|
|
164
|
+
* starts. Its resource group is its name. Refused on GitHub and Forgejo,
|
|
165
|
+
* whose comment job is `commentJob`.
|
|
166
|
+
*/
|
|
167
|
+
noteCommandsJob?: ProductNoteCommandsJobOptions;
|
|
158
168
|
/**
|
|
159
169
|
* The waves' job names (#5027), the Op waves generators' `jobNames`
|
|
160
170
|
* (#5022): `waves.pipeline` carries them to the generator, `waves.jobs`
|
|
@@ -199,6 +209,8 @@ export interface ProductWavesBeforeMerge {
|
|
|
199
209
|
merge?: "auto" | "manual";
|
|
200
210
|
/** The merge token's secret or CI/CD variable, with `merge: "auto"` (needed on Forgejo and GitLab). */
|
|
201
211
|
mergeTokenSecret?: string;
|
|
212
|
+
/** The forge environment the merge job runs in, which the merge token is scoped to (#5037; GitHub and GitLab). `waves.pipeline` carries it as the generator's `beforeMerge.environment`. */
|
|
213
|
+
environment?: string;
|
|
202
214
|
/** 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/`. */
|
|
203
215
|
pipelineFiles?: string[];
|
|
204
216
|
/**
|
|
@@ -217,6 +229,16 @@ export interface ProductWavesBeforeMerge {
|
|
|
217
229
|
dispatchInputs?: Partial<Record<"pr" | "head" | "digest", string>>;
|
|
218
230
|
}
|
|
219
231
|
|
|
232
|
+
/** {@link ProductPipelineOptions.noteCommandsJob} (#5038). */
|
|
233
|
+
export interface ProductNoteCommandsJobOptions {
|
|
234
|
+
/** The job's name, such as `comments`. Default `note-commands`. */
|
|
235
|
+
jobName?: string;
|
|
236
|
+
/** Its stage. Default the job's name. */
|
|
237
|
+
stage?: string;
|
|
238
|
+
/** The variable and value a pipeline schedule starts it with, such as `{ variable: "TERRAGUCCI_SCHEDULE", value: "comments" }`. Default `CHANT_NOTE_COMMANDS` and `1`. */
|
|
239
|
+
schedule?: { variable: string; value: string };
|
|
240
|
+
}
|
|
241
|
+
|
|
220
242
|
/** {@link ProductPipelineOptions.commentJob}'s settings (#5027). */
|
|
221
243
|
export interface ProductCommentJobOptions {
|
|
222
244
|
/** The comment job's name in the workflow, such as `apply-comment`. Default {@link PR_COMMENT_JOB}. */
|
|
@@ -306,7 +328,7 @@ export interface ProductPipelineJobs {
|
|
|
306
328
|
* lexicon renders the same job from `chant build --pr-loop
|
|
307
329
|
* --note-commands`. Refused on GitHub and Forgejo.
|
|
308
330
|
*/
|
|
309
|
-
noteCommands?: { command: string; runner?: CiRunner; env?: Record<string, string
|
|
331
|
+
noteCommands?: { command: string; runner?: CiRunner; env?: Record<string, string>; jobName?: string; stage?: string; schedule?: { variable: string; value: string } };
|
|
310
332
|
/**
|
|
311
333
|
* The agent (#4616), with `agent`: the comment it answers, `/<product>
|
|
312
334
|
* agent <ask>`, and the scheduled Op spec whose generated workflow runs
|
|
@@ -445,7 +467,7 @@ export function productPipelineJobs(forge: ForgeKind, env: string, options: Prod
|
|
|
445
467
|
// #4946: the comment job answers every command but a commit word (the commit job's) with a reply, so the words may name any.
|
|
446
468
|
const answered: CiProductCommand[] = options.commentJob ? [...new Set<CiProductCommand>([...jobs, ...CI_PRODUCT_COMMANDS.filter((c) => c !== "commit")])] : jobs;
|
|
447
469
|
const words = assertProductWords({ ...options.words, applyMode }, { jobs: answered });
|
|
448
|
-
const { waves: given, wavesSpecFile, member, agent: _agent, commits: _commits, actions: _actions, componentWaves, productPlan, evidence, commentJob: _commentJob, wavesBeforeMerge, applyStatus: _applyStatus, wavesJobNames, ...loop } = options;
|
|
470
|
+
const { waves: given, wavesSpecFile, member, agent: _agent, commits: _commits, actions: _actions, componentWaves, productPlan, evidence, commentJob: _commentJob, wavesBeforeMerge, applyStatus: _applyStatus, wavesJobNames, noteCommandsJob, ...loop } = options;
|
|
449
471
|
if (options.applyStatus && !given && !componentWaves) throw new Error("applyStatus posts the waves' apply statuses, and there are none: give waves (or componentWaves)");
|
|
450
472
|
const { respond } = options;
|
|
451
473
|
// #4629: the pull request loop puts the responses on the apply and note jobs, as `chant build --pr-loop --respond` does.
|
|
@@ -501,7 +523,8 @@ export function productPipelineJobs(forge: ForgeKind, env: string, options: Prod
|
|
|
501
523
|
// #4785: GitLab's comment commands, polled from the notes; waves on merge are retried by an apply on a merged merge request.
|
|
502
524
|
// #4899: the product plan's comment re-plan runs in the preview's pipeline, so the poll starts it as it starts a preview.
|
|
503
525
|
const notes = prNoteCommandsJob(forge, { ...prLoop, ...(options.waves || options.componentWaves ? { applyOnMerge: true } : {}), ...(productPlan?.replan ? { previewComment: true } : {}) });
|
|
504
|
-
if (notes) out.noteCommands = { ...notes, ...defaultRunner };
|
|
526
|
+
if (notes) out.noteCommands = { ...notes, ...defaultRunner, ...noteCommandsNames(forge, noteCommandsJob) };
|
|
527
|
+
else if (noteCommandsJob !== undefined) throw new Error(forge === "gitlab" ? "noteCommandsJob names the note poll, and there is none: set noteCommands" : `noteCommandsJob names GitLab's note poll; on ${forge} the comment job (commentJob) answers comments`);
|
|
505
528
|
const preview = prCommentPreviewJob(forge, env, prLoop, member);
|
|
506
529
|
if (preview) out.preview = { ...preview, ...(defaultRunner.runner !== undefined ? { noteRunner: defaultRunner.runner } : {}) };
|
|
507
530
|
// #4616: the agent answers its comment from a workflow of its own, generated from this spec.
|
|
@@ -607,7 +630,7 @@ export function productPipelineJobs(forge: ForgeKind, env: string, options: Prod
|
|
|
607
630
|
if (!named || !specFile || !namedWaveJobs) return { ...out, record: record! };
|
|
608
631
|
// #4984: what the generator's before-merge mode takes: the merge after the last wave and the lock file it releases.
|
|
609
632
|
const beforeMerge: OpWavesBeforeMerge | undefined = wavesBeforeMerge
|
|
610
|
-
? { ...(wavesBeforeMerge.merge ? { merge: wavesBeforeMerge.merge } : {}), ...(wavesBeforeMerge.mergeTokenSecret ? { mergeTokenSecret: wavesBeforeMerge.mergeTokenSecret } : {}), ...(productPlan?.reach?.gate ? { gate: productPlan.reach.gate } : {}) }
|
|
633
|
+
? { ...(wavesBeforeMerge.merge ? { merge: wavesBeforeMerge.merge } : {}), ...(wavesBeforeMerge.mergeTokenSecret ? { mergeTokenSecret: wavesBeforeMerge.mergeTokenSecret } : {}), ...(wavesBeforeMerge.environment !== undefined ? { environment: wavesBeforeMerge.environment } : {}), ...(productPlan?.reach?.gate ? { gate: productPlan.reach.gate } : {}) }
|
|
611
634
|
: undefined;
|
|
612
635
|
// #4987: the apply statuses after each wave, and with a product plan the stale marking beside wave 1, one --member per target.
|
|
613
636
|
const pipeline: Pick<OpWavesPipelineOptions, "beforeMerge" | "applyStatus" | "staleNotes" | "workflowFile" | "dispatchInputs" | "jobNames"> = {
|
|
@@ -744,6 +767,28 @@ export function componentWavesSpec(
|
|
|
744
767
|
};
|
|
745
768
|
}
|
|
746
769
|
|
|
770
|
+
/** GitLab's reserved top-level keys, which no job may be named. */
|
|
771
|
+
const GITLAB_RESERVED = new Set(["default", "include", "stages", "variables", "workflow", "image", "services", "cache", "before_script", "after_script", "spec", "pages"]);
|
|
772
|
+
|
|
773
|
+
/** The note poll's names (#5038), checked: only those the product gave, so a pipeline without them renders as before. */
|
|
774
|
+
function noteCommandsNames(forge: ForgeKind, given: ProductNoteCommandsJobOptions | undefined): Pick<NonNullable<ProductPipelineJobs["noteCommands"]>, "jobName" | "stage" | "schedule"> {
|
|
775
|
+
if (given === undefined) return {};
|
|
776
|
+
if (forge !== "gitlab") throw new Error(`noteCommandsJob names GitLab's note poll; on ${forge} the comment job (commentJob) answers comments`);
|
|
777
|
+
const name = (what: string, v: unknown): string => {
|
|
778
|
+
if (typeof v !== "string" || !/^[A-Za-z0-9_][A-Za-z0-9_.-]*$/.test(v) || GITLAB_RESERVED.has(v)) throw new Error(`noteCommandsJob.${what} ${JSON.stringify(v)} is not a GitLab ${what === "stage" ? "stage" : "job"} name of letters, digits, _, . and -, and no GitLab keyword`);
|
|
779
|
+
return v;
|
|
780
|
+
};
|
|
781
|
+
const s = given.schedule;
|
|
782
|
+
if (s !== undefined && (typeof s.variable !== "string" || !/^[A-Za-z_][A-Za-z0-9_]*$/.test(s.variable) || typeof s.value !== "string" || !/^[A-Za-z0-9_.-]+$/.test(s.value))) {
|
|
783
|
+
throw new Error(`noteCommandsJob.schedule ${JSON.stringify(s)} is a variable name and a value of letters, digits, _, . and -, such as { variable: "TERRAGUCCI_SCHEDULE", value: "comments" }`);
|
|
784
|
+
}
|
|
785
|
+
return {
|
|
786
|
+
...(given.jobName !== undefined ? { jobName: name("jobName", given.jobName) } : {}),
|
|
787
|
+
...(given.stage !== undefined ? { stage: name("stage", given.stage) } : {}),
|
|
788
|
+
...(s !== undefined ? { schedule: { variable: s.variable, value: s.value } } : {}),
|
|
789
|
+
};
|
|
790
|
+
}
|
|
791
|
+
|
|
747
792
|
/**
|
|
748
793
|
* The comment job's descriptor (#4946): `chant components pr-comment
|
|
749
794
|
* --forge <forge>` through the words' bin, the jobs it leaves comments to as
|
package/src/floor-table.data.ts
CHANGED
|
@@ -52,10 +52,16 @@ export const FLOOR_ROWS: readonly FloorRow[] = [
|
|
|
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
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
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:
|
|
56
|
-
{ name: "PR_HEAD_SHA_FLOOR", version:
|
|
57
|
-
{ name: "OP_WAVES_NAMES_FLOOR", version:
|
|
58
|
-
{ name: "PRODUCT_JOB_NAMES_FLOOR", version:
|
|
55
|
+
{ name: "PRODUCT_PLAN_LOGIN_TOKENS_FLOOR", version: "0.124.92", 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: "0.124.92", 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: "0.124.92", 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: "0.124.92", 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"] },
|
|
59
|
+
{ name: "OP_WAVES_DEFAULT_BRANCH_FLOOR", version: NEXT_RELEASE, gates: "The first chant whose Op waves run from the repository's default branch by the name the forge gives it at run time (#5032): the spec's `defaultBranch: true`, with or without `branches` beside it.", issue: "#5032", file: "ci-product.ts", modules: ["@intentius/chant/ci-product"] },
|
|
60
|
+
{ name: "OP_WAVES_FIRST_WAVE_NEEDS_FLOOR", version: NEXT_RELEASE, gates: "The first chant whose Op waves generators take `firstWaveNeeds` (#5032): the product's own jobs, such as terragucci's `check`, that the first wave's own or deciding job (and before merge its plan job, and on GitLab its policy job) needs, so a push that fails the product's check applies nothing.", issue: "#5032", file: "ci-product.ts", modules: ["@intentius/chant/ci-product"] },
|
|
61
|
+
{ name: "NOTIFY_RELAY_NAME_FLOOR", version: NEXT_RELEASE, gates: "The first chant whose notify config takes `relayName` (#5033): the relay's name as people mention it in Teams, a plain value, which `sendNotify` (and so a wave's and a drift notice's messages) passes to the Teams card over the product's words' own, so a waiting wave's card spells out `reply @<name> approve <token>`.", issue: "#5033", file: "ci-product.ts", modules: ["@intentius/chant/ci-product"] },
|
|
62
|
+
{ name: "OP_WAVES_RESUME_NAMES_FLOOR", version: NEXT_RELEASE, gates: "The first chant whose Op waves resume keeps a product's names (#5034): `resumeWorkflowFile` names the GitHub and Forgejo resume workflow's file (such as terragucci's `terragucci-resume.yml`; default `<spec>-resume.yml`, refused on GitLab and when it is the waves' own file), and `jobNames` is called for the resume job with the role `resume` (GitHub and Forgejo `resume`, GitLab `<spec>-resume` by default).", issue: "#5034", file: "ci-product.ts", modules: ["@intentius/chant/ci-product"] },
|
|
63
|
+
{ name: "WAVES_BEFORE_MERGE_ENVIRONMENT_FLOOR", version: NEXT_RELEASE, gates: "The first chant whose Op waves before merge take `beforeMerge.environment` (#5037): the forge environment the job after the last wave runs in, so a merge token scoped to it reaches that job alone (GitLab `environment: { name, action: access }`, GitHub `environment: <name>`; Forgejo refuses it), with the product pipeline's `wavesBeforeMerge.environment` carried through `waves.pipeline`.", issue: "#5037", file: "ci-product.ts", modules: ["@intentius/chant/ci-product"] },
|
|
64
|
+
{ name: "NOTE_POLL_NAMES_FLOOR", version: NEXT_RELEASE, gates: "The first chant whose GitLab note poll keeps a product's names (#5038): the product pipeline's `noteCommandsJob` gives its job's name (default `note-commands`), its stage (default the job's name) and the variable and value a pipeline schedule starts it with (default `CHANT_NOTE_COMMANDS=1`), such as terragucci's `comments` job and `TERRAGUCCI_SCHEDULE=comments`, rendered in the job, its stage, its rule, its resource group and the workflow's rules.", issue: "#5038", file: "ci-product.ts", modules: ["@intentius/chant/ci-product"] },
|
|
59
65
|
{ 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"] },
|
|
60
66
|
{ 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"] },
|
|
61
67
|
{ 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"] },
|
package/src/lexicon.ts
CHANGED
|
@@ -1252,6 +1252,13 @@ export interface OpWavesPipelineOptions
|
|
|
1252
1252
|
* record job dispatches. GitLab takes `opsFileName`. Absent: `<spec>.yml`.
|
|
1253
1253
|
*/
|
|
1254
1254
|
workflowFile?: string;
|
|
1255
|
+
/**
|
|
1256
|
+
* GitHub and Forgejo (#5034): the file the spec's `resume` workflow goes
|
|
1257
|
+
* in, such as terragucci's `terragucci-resume.yml`. GitLab refuses it
|
|
1258
|
+
* (its resume job is in the pipeline; `jobNames` names it with the role
|
|
1259
|
+
* `resume`). Absent: `<spec>-resume.yml`.
|
|
1260
|
+
*/
|
|
1261
|
+
resumeWorkflowFile?: string;
|
|
1255
1262
|
/**
|
|
1256
1263
|
* The jobs go in a product's own workflow or pipeline beside its other
|
|
1257
1264
|
* jobs (#5022). GitHub and Forgejo: an expression (without `${{ }}`)
|
|
@@ -1271,6 +1278,16 @@ export interface OpWavesPipelineOptions
|
|
|
1271
1278
|
* (`wavesBeforeMerge.dispatchInputs`). Absent: chant's.
|
|
1272
1279
|
*/
|
|
1273
1280
|
dispatchInputs?: Partial<Record<import("./op/op-waves-names").OpWavesDispatchInput, string>>;
|
|
1281
|
+
/**
|
|
1282
|
+
* The product's own jobs the first wave's jobs need (#5032), such as
|
|
1283
|
+
* terragucci's `check`, so a push that fails the product's check applies
|
|
1284
|
+
* nothing. They go in `needs:` of wave 1's job (its deciding job for a
|
|
1285
|
+
* wide wave, and before merge its plan job). GitHub and Forgejo: each has
|
|
1286
|
+
* to pass, or, in a dispatched run, not have run. GitLab: each, optional,
|
|
1287
|
+
* has to pass (wave 1's policy job needs them too). The jobs must be in
|
|
1288
|
+
* the same workflow or pipeline, so this goes with `runIf`. Absent: none.
|
|
1289
|
+
*/
|
|
1290
|
+
firstWaveNeeds?: string[];
|
|
1274
1291
|
}
|
|
1275
1292
|
|
|
1276
1293
|
/** A run step a product adds to a generated job (#4791): its name, and its shell lines in order. */
|
|
@@ -40,8 +40,9 @@ describe("the notify bundle", () => {
|
|
|
40
40
|
expect(inputs).toEqual(["packages/core/src/notify-verify.ts", "packages/core/src/notify.ts"]);
|
|
41
41
|
expect(imports).toEqual(["node:crypto"]);
|
|
42
42
|
// 17 KiB since ci.stale (#4678): the ci. events' names and headlines took it to 16.0 KiB, and the cap
|
|
43
|
-
// is there to catch a dependency pulled in, which would add far more than an event name.
|
|
44
|
-
|
|
43
|
+
// is there to catch a dependency pulled in, which would add far more than an event name. 18 KiB since
|
|
44
|
+
// relayName (#5033), whose check and pass-through took it just over 17 KiB (17.3).
|
|
45
|
+
expect(bytes).toBeLessThan(18 * 1024);
|
|
45
46
|
});
|
|
46
47
|
|
|
47
48
|
test("the verifier holds itself alone, and imports only node:crypto", async () => {
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* #5033: a notify config's `relayName`, the relay's name as people mention
|
|
3
|
+
* it in Teams, so a waiting event's card says the whole reply. The
|
|
4
|
+
* `notify-defaults` golden was written from main before the change: a
|
|
5
|
+
* config without it sends what it sent.
|
|
6
|
+
*/
|
|
7
|
+
import { describe, expect, test } from "vitest";
|
|
8
|
+
import { makeNotifyEvent, notifyConfigProblem, notifyVariables, sendNotify, type NotifyFetch } from "./notify";
|
|
9
|
+
|
|
10
|
+
const NOW = new Date("2026-10-11T12:00:00.000Z");
|
|
11
|
+
const GITHUB = { GITHUB_ACTIONS: "true", GITHUB_SERVER_URL: "https://github.com", GITHUB_REPOSITORY: "acme/db", GITHUB_RUN_ID: "42", GITHUB_SHA: "abc123" };
|
|
12
|
+
const DIGEST = "jcs1-sha256:" + "a".repeat(64);
|
|
13
|
+
const env = { ...GITHUB, SLACK: "https://hooks.slack.com/services/T/B/x", TEAMS: "https://teams.example/workflows/x", RELAY_KEY: "relay-secret" };
|
|
14
|
+
|
|
15
|
+
const waiting = makeNotifyEvent(
|
|
16
|
+
{
|
|
17
|
+
source: "terragucci",
|
|
18
|
+
event: "waiting",
|
|
19
|
+
summary: "wave 1 (wave-1) of tf-apply waits for an approval",
|
|
20
|
+
wave: { number: 1, name: "wave-1", gate: "wave-1" },
|
|
21
|
+
targets: ["network"],
|
|
22
|
+
digest: DIGEST,
|
|
23
|
+
approve: { command: `terragucci approve tf-apply wave-1 --plan ${DIGEST}` },
|
|
24
|
+
},
|
|
25
|
+
{ env: GITHUB, now: NOW },
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
/** What each target was sent, by its URL's order. */
|
|
29
|
+
async function sent(config: Parameters<typeof sendNotify>[0]): Promise<unknown[]> {
|
|
30
|
+
const bodies: unknown[] = [];
|
|
31
|
+
const fetch: NotifyFetch = async (_url, init) => {
|
|
32
|
+
bodies.push(JSON.parse(init.body));
|
|
33
|
+
return { ok: true, status: 200 };
|
|
34
|
+
};
|
|
35
|
+
await sendNotify(config, waiting, { env, fetch, now: 1_760_184_000, sleep: async () => {}, log: () => {} });
|
|
36
|
+
return bodies;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
type Card = { attachments: Array<{ content: { body: Array<{ type: string; text?: string; facts?: Array<{ title: string; value: string }> }> } }> };
|
|
40
|
+
const texts = (card: unknown): string => JSON.stringify((card as Card).attachments[0]!.content.body);
|
|
41
|
+
|
|
42
|
+
describe("notify with relayName (#5033)", () => {
|
|
43
|
+
test("the Teams card says the whole reply, mentioning the relay by name", async () => {
|
|
44
|
+
const [, teams] = await sent({ slack: "SLACK", teams: "TEAMS", relay: "RELAY_KEY", relayName: "Terragucci Relay" });
|
|
45
|
+
expect(texts(teams)).toContain("reply @Terragucci Relay approve ");
|
|
46
|
+
expect(texts(teams)).not.toContain("mention the relay and reply");
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
test("it is over the product's words' own name", async () => {
|
|
50
|
+
const bodies: unknown[] = [];
|
|
51
|
+
const fetch: NotifyFetch = async (_url, init) => (bodies.push(JSON.parse(init.body)), { ok: true, status: 200 });
|
|
52
|
+
await sendNotify({ teams: "TEAMS", relay: "RELAY_KEY", relayName: "acme-relay" }, waiting, { env, fetch, message: { relayName: "words-relay" }, sleep: async () => {}, log: () => {} });
|
|
53
|
+
expect(texts(bodies[0])).toContain("reply @acme-relay approve ");
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
test("without the relay's key there are no buttons, so the name changes nothing", async () => {
|
|
57
|
+
expect(await sent({ teams: "TEAMS", relayName: "acme-relay" })).toEqual(await sent({ teams: "TEAMS" }));
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
test("it is checked, and named by no variable", () => {
|
|
61
|
+
expect(notifyConfigProblem({ teams: "TEAMS", relayName: "acme-relay" })).toBeUndefined();
|
|
62
|
+
for (const bad of ["", " lead", "@acme", "a<b>", "two\nlines", "x".repeat(81), 7]) expect(notifyConfigProblem({ teams: "TEAMS", relayName: bad }), String(bad)).toMatch(/relayName/);
|
|
63
|
+
expect(notifyVariables({ teams: "TEAMS", relay: "RELAY_KEY", relayName: "acme-relay" })).toEqual(["TEAMS", "RELAY_KEY"]);
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
describe("notify without relayName (#5033)", () => {
|
|
68
|
+
test("Slack and Teams get what they got before", async () => {
|
|
69
|
+
await expect(JSON.stringify(await sent({ slack: "SLACK", teams: "TEAMS", relay: "RELAY_KEY" }), null, 2) + "\n").toMatchFileSnapshot("./__golden__/notify-defaults-relay.json");
|
|
70
|
+
await expect(JSON.stringify(await sent({ teams: "TEAMS" }), null, 2) + "\n").toMatchFileSnapshot("./__golden__/notify-defaults-plain.json");
|
|
71
|
+
});
|
|
72
|
+
});
|
package/src/notify.ts
CHANGED
|
@@ -403,10 +403,18 @@ export interface NotifyConfig {
|
|
|
403
403
|
* Decline buttons, and its Teams card the reply that approves.
|
|
404
404
|
*/
|
|
405
405
|
relay?: string;
|
|
406
|
+
/**
|
|
407
|
+
* The relay's name as people mention it in Teams (#5033), such as a
|
|
408
|
+
* product's `notify.relay`: a waiting event's Teams card then says the
|
|
409
|
+
* whole reply, `reply @<name> approve <token>`. A plain value, not a
|
|
410
|
+
* variable, since it is no secret. Over the product's words' own
|
|
411
|
+
* `relayName`. Absent: the card says to mention the relay.
|
|
412
|
+
*/
|
|
413
|
+
relayName?: string;
|
|
406
414
|
}
|
|
407
415
|
|
|
408
416
|
const VARIABLE = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
409
|
-
const SETTINGS = ["webhook", "key", "slack", "teams", "events", "relay"];
|
|
417
|
+
const SETTINGS = ["webhook", "key", "slack", "teams", "events", "relay", "relayName"];
|
|
410
418
|
|
|
411
419
|
/** The first problem with a {@link NotifyConfig}, or undefined. `where` prefixes the message. */
|
|
412
420
|
export function notifyConfigProblem(value: unknown, where = "notify"): string | undefined {
|
|
@@ -423,6 +431,9 @@ export function notifyConfigProblem(value: unknown, where = "notify"): string |
|
|
|
423
431
|
}
|
|
424
432
|
if (v.webhook !== undefined && v.key === undefined) return `${where}.key: a webhook needs a signing key; name the variable that holds it`;
|
|
425
433
|
if (v.key !== undefined && v.webhook === undefined) return `${where}.webhook: a key is for a webhook; name the variable that holds its URL`;
|
|
434
|
+
if (v.relayName !== undefined && (typeof v.relayName !== "string" || !/^[^\s@<>][^\r\n@<>]{0,79}$/.test(v.relayName) || v.relayName.trim() !== v.relayName)) {
|
|
435
|
+
return `${where}.relayName: the relay's name as Teams mentions it, one line of at most 80 characters without @, < or >`;
|
|
436
|
+
}
|
|
426
437
|
if (v.webhook === undefined && v.slack === undefined && v.teams === undefined) return `${where}: name a webhook (with its key), a slack or a teams URL variable`;
|
|
427
438
|
if (v.events !== undefined && !(Array.isArray(v.events) && v.events.every((e) => (NOTIFY_EVENTS as readonly unknown[]).includes(e)))) {
|
|
428
439
|
return `${where}.events: a list of ${NOTIFY_EVENTS.join(", ")}`;
|
|
@@ -571,7 +582,9 @@ export async function sendNotify(config: NotifyConfig | undefined, event: Notify
|
|
|
571
582
|
const relayKey = config.relay ? env[config.relay] : undefined;
|
|
572
583
|
if (config.relay && ref && !relayKey) log(`notify: ${config.relay} is not set, so the message carries no relay buttons`);
|
|
573
584
|
const buttons = ref && relayKey ? { token: relayToken(relayKey, ref) } : undefined;
|
|
574
|
-
|
|
575
|
-
|
|
585
|
+
// #5033: the config's relay name, over the product's words'.
|
|
586
|
+
const message = config.relayName ? { ...options.message, relayName: config.relayName } : options.message;
|
|
587
|
+
if (config.slack) await deliver("slack", config.slack, () => json(options.render?.slack ? options.render.slack(event, buttons) : slackMessage(event, buttons, message)));
|
|
588
|
+
if (config.teams) await deliver("teams", config.teams, () => json(options.render?.teams ? options.render.teams(event, buttons) : teamsMessage(event, buttons, message)));
|
|
576
589
|
return out;
|
|
577
590
|
}
|
package/src/op/before-merge.ts
CHANGED
|
@@ -195,6 +195,14 @@ export interface OpWavesBeforeMerge {
|
|
|
195
195
|
mergeTokenSecret?: string;
|
|
196
196
|
/** The lock file the change's locks are in, `_locks/<gate>.json`, which `merge: "auto"` releases. Default the pull request loop's. */
|
|
197
197
|
gate?: string;
|
|
198
|
+
/**
|
|
199
|
+
* The forge environment the job after the last wave runs in (#5037), so
|
|
200
|
+
* a merge token scoped to it reaches that job alone, such as terragucci's
|
|
201
|
+
* `terragucci-merge`. GitLab: `environment: { name, action: access }`,
|
|
202
|
+
* which deploys nothing. GitHub: `environment: <name>`, whose secrets the
|
|
203
|
+
* job reads. Forgejo has no environments and refuses it. Absent: none.
|
|
204
|
+
*/
|
|
205
|
+
environment?: string;
|
|
198
206
|
}
|
|
199
207
|
|
|
200
208
|
/** The job after the last wave of a before-merge run (#4984). */
|
|
@@ -208,6 +216,10 @@ export function assertOpWavesBeforeMerge(forge: "github" | "forgejo" | "gitlab",
|
|
|
208
216
|
if (bm.merge !== undefined && bm.merge !== "auto" && bm.merge !== "manual") throw new Error(`beforeMerge.merge is auto or manual, not ${JSON.stringify(bm.merge)}`);
|
|
209
217
|
if (bm.mergeTokenSecret !== undefined && !/^[A-Za-z_][A-Za-z0-9_]*$/.test(bm.mergeTokenSecret)) throw new Error(`beforeMerge.mergeTokenSecret ${JSON.stringify(bm.mergeTokenSecret)} is not a variable name`);
|
|
210
218
|
if (bm.gate !== undefined && !/^[A-Za-z0-9][A-Za-z0-9_.-]{0,127}$/.test(bm.gate)) throw new Error(`beforeMerge.gate ${JSON.stringify(bm.gate)} is not a lock file name`);
|
|
219
|
+
if (bm.environment !== undefined) {
|
|
220
|
+
if (forge === "forgejo") throw new Error("beforeMerge.environment names a forge environment, and Forgejo Actions has none; scope the merge token another way, or leave it out");
|
|
221
|
+
if (typeof bm.environment !== "string" || !/^[A-Za-z0-9][A-Za-z0-9_.\/-]{0,254}$/.test(bm.environment)) throw new Error(`beforeMerge.environment ${JSON.stringify(bm.environment)} is not an environment name`);
|
|
222
|
+
}
|
|
211
223
|
if (bm.merge === "auto" && forge !== "github" && !bm.mergeTokenSecret) {
|
|
212
224
|
throw new Error(`beforeMerge.merge auto on ${forge} needs mergeTokenSecret: ${forge === "forgejo" ? "Forgejo refuses a merge made with the job's own token" : "GitLab's job token cannot merge"}`);
|
|
213
225
|
}
|
package/src/op/index.ts
CHANGED
|
@@ -150,7 +150,7 @@ export {
|
|
|
150
150
|
opWavesRenderSpecProblems,
|
|
151
151
|
} from "./op-waves-render-spec";
|
|
152
152
|
export type { OpWavesRenderSpec } from "./op-waves-render-spec";
|
|
153
|
-
export { OP_WAVE_STAND_DOWN_FLOOR, gitOpWaveNewerCommit, newerCommitOnBranch, opWaveRunBranch, opWaveStandDownReason, tipAppliesTargets } from "./op-waves-stand-down";
|
|
153
|
+
export { OP_WAVE_STAND_DOWN_FLOOR, gitOpWaveNewerCommit, newerCommitOnBranch, opWaveDefaultBranch, opWaveRunBranch, opWaveStandDownReason, tipAppliesTargets } from "./op-waves-stand-down";
|
|
154
154
|
export type { OpWaveNewerCommit, OpWaveNewerCommitPort } from "./op-waves-stand-down";
|
|
155
155
|
export { OP_WAVE_RELEASE_RECORD_FLOOR, opWaveReleaseNames, opWaveReleaseProblems, releaseOfCommit } from "./op-waves-release";
|
|
156
156
|
export { gitOpWaveReleasePort } from "./op-waves-release-port";
|
package/src/op/op-waves-names.ts
CHANGED
|
@@ -43,7 +43,8 @@ export type OpWavesJobRole =
|
|
|
43
43
|
| "apply-status"
|
|
44
44
|
| "stale-notes"
|
|
45
45
|
| "before-merge-done"
|
|
46
|
-
| "control"
|
|
46
|
+
| "control"
|
|
47
|
+
| "resume";
|
|
47
48
|
|
|
48
49
|
/** One job the generator names (#5022). */
|
|
49
50
|
export interface OpWavesJobRef {
|
|
@@ -55,7 +56,9 @@ export interface OpWavesJobRef {
|
|
|
55
56
|
* job. `plan`, `gate`, `apply`, `record`: a split wave's jobs before merge
|
|
56
57
|
* (`apply` with `share` or `group` for a wide wave's). `policy` (GitLab),
|
|
57
58
|
* `evidence`: the jobs of a wave's checks. The rest are the jobs after
|
|
58
|
-
* or beside the waves
|
|
59
|
+
* or beside the waves; `resume` (#5034) is the scheduled job that starts
|
|
60
|
+
* a waiting wave's job again, `resume` in its own workflow on GitHub and
|
|
61
|
+
* Forgejo and `<spec>-resume` on GitLab.
|
|
59
62
|
*/
|
|
60
63
|
role: OpWavesJobRole;
|
|
61
64
|
/** The wave's number from 1, and its name, on every job but the stale and control jobs and the before-merge done job. */
|
|
@@ -176,6 +179,51 @@ export function opWavesWorkflowFile(spec: Pick<OpWavesSpec, "name">, file: strin
|
|
|
176
179
|
return file;
|
|
177
180
|
}
|
|
178
181
|
|
|
182
|
+
/**
|
|
183
|
+
* The file the resume workflow goes in (#5034, GitHub and Forgejo):
|
|
184
|
+
* `resumeWorkflowFile`, such as terragucci's `terragucci-resume.yml`, else
|
|
185
|
+
* `<spec>-resume.yml`. Refused when it is the waves' own file.
|
|
186
|
+
*/
|
|
187
|
+
export function opWavesResumeWorkflowFile(spec: Pick<OpWavesSpec, "name">, file: string | undefined, wavesFile: string): string {
|
|
188
|
+
if (file === undefined) return `${spec.name}-resume.yml`;
|
|
189
|
+
if (!/^[A-Za-z0-9][A-Za-z0-9._-]*\.ya?ml$/.test(file)) throw new Error(`resumeWorkflowFile ${JSON.stringify(file)} is a workflow file's name, like terragucci-resume.yml, in the forge's workflow directory`);
|
|
190
|
+
if (file === wavesFile) throw new Error(`resumeWorkflowFile ${JSON.stringify(file)} is the waves' own workflow; the resume runs on a schedule of its own`);
|
|
191
|
+
return file;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* The product's own jobs the first wave's jobs need (#5032), such as
|
|
196
|
+
* terragucci's `check`: checked as job names of the forge, each once.
|
|
197
|
+
* Absent or empty: none, and the jobs render as before.
|
|
198
|
+
*/
|
|
199
|
+
export function opWavesFirstWaveNeeds(given: readonly string[] | undefined, forge: "github" | "forgejo" | "gitlab"): string[] {
|
|
200
|
+
if (given === undefined) return [];
|
|
201
|
+
if (!Array.isArray(given)) throw new Error("firstWaveNeeds is a list of the product's job names");
|
|
202
|
+
const github = forge !== "gitlab";
|
|
203
|
+
for (const n of given) {
|
|
204
|
+
const ok = typeof n === "string" && (github ? /^[A-Za-z_][A-Za-z0-9_-]*$/.test(n) : /^[A-Za-z0-9_][A-Za-z0-9_.-]*$/.test(n) && !GITLAB_KEYWORDS.has(n));
|
|
205
|
+
if (!ok) throw new Error(`firstWaveNeeds names ${JSON.stringify(n)}, which is not a job name of letters, digits, _ and -${github ? ", starting with a letter or _" : ", and no GitLab keyword"}`);
|
|
206
|
+
}
|
|
207
|
+
if (new Set(given).size !== given.length) throw new Error(`firstWaveNeeds names a job twice: ${given.join(", ")}`);
|
|
208
|
+
return [...given];
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/** Refuse a product job of {@link opWavesFirstWaveNeeds} that is a job the generator writes (#5032). */
|
|
212
|
+
export function assertFirstWaveNeedsOutside(needs: readonly string[], jobs: Iterable<string>): void {
|
|
213
|
+
const mine = new Set(jobs);
|
|
214
|
+
for (const n of needs) if (mine.has(n)) throw new Error(`firstWaveNeeds names ${n}, a job of the waves themselves; name the product's own jobs, such as its check`);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* GitHub and Forgejo: the condition a first-wave job runs under with
|
|
219
|
+
* {@link opWavesFirstWaveNeeds} (#5032). Each product job passed; in a
|
|
220
|
+
* dispatched run (before merge), one that did not run is no hold, since a
|
|
221
|
+
* product's check runs on its pushes and pull requests.
|
|
222
|
+
*/
|
|
223
|
+
export function githubFirstWaveIf(needs: readonly string[]): string {
|
|
224
|
+
return ["!cancelled()", ...needs.map((n) => `(needs.${n}.result == 'success' || (github.event_name == 'workflow_dispatch' && needs.${n}.result == 'skipped'))`)].join(" && ");
|
|
225
|
+
}
|
|
226
|
+
|
|
179
227
|
const GITLAB_KEYWORDS = new Set(["default", "include", "stages", "variables", "workflow", "image", "services", "cache", "before_script", "after_script", "spec", "pages"]);
|
|
180
228
|
|
|
181
229
|
/** A job of a pipeline as {@link opWavesNamer} reads it: an `opWaveJobs` job, or a split one with its phase. */
|
package/src/op/op-waves-run.ts
CHANGED
|
@@ -109,7 +109,7 @@ import { gitOpWaveReleasePort } from "./op-waves-release-port";
|
|
|
109
109
|
import type { LockGrain } from "../lifecycle/lock-rows";
|
|
110
110
|
import type { LockLiveness, LockRowsLease } from "../lifecycle/resource-lock";
|
|
111
111
|
import type { GatePolicyExec } from "../gate-policy";
|
|
112
|
-
import { gitOpWaveNewerCommit, opWaveStandDownReason, tipAppliesTargets, type OpWaveNewerCommitPort } from "./op-waves-stand-down";
|
|
112
|
+
import { gitOpWaveNewerCommit, opWaveDefaultBranch, opWaveStandDownReason, tipAppliesTargets, type OpWaveNewerCommitPort } from "./op-waves-stand-down";
|
|
113
113
|
import { keyedSerial, mapLimited, type SerialSection } from "../parallelism";
|
|
114
114
|
import {
|
|
115
115
|
applyOpWaveStep,
|
|
@@ -936,6 +936,8 @@ export interface RunOpWaveOptions {
|
|
|
936
936
|
standDown?: boolean;
|
|
937
937
|
/** How the job finds a newer commit on its branch (#4581). Default: fetch the branch from `origin` ({@link gitOpWaveNewerCommit}). */
|
|
938
938
|
newerCommit?: OpWaveNewerCommitPort;
|
|
939
|
+
/** The repository's default branch, for a spec with `defaultBranch` (#5032). Default {@link opWaveDefaultBranch} of the job's environment. */
|
|
940
|
+
defaultBranch?: string;
|
|
939
941
|
/**
|
|
940
942
|
* Where the job's run events go (#4555), on the run-event contract: a
|
|
941
943
|
* phase `wave-<k>` per wave and a step per run target, settled as the
|
|
@@ -4726,7 +4728,7 @@ async function standDownForNewer(options: RunOpWaveOptions, ctx: WaveContext, de
|
|
|
4726
4728
|
log(`wave ${k} (${wave.name}): ${newer.branch} has a newer commit ${newer.tip.slice(0, 12)}, and its spec cannot be read (${err instanceof Error ? err.message : String(err)}), so this job applies`);
|
|
4727
4729
|
return false;
|
|
4728
4730
|
}
|
|
4729
|
-
if (!tipAppliesTargets(atTip, newer.branch, wave.name, targets)) {
|
|
4731
|
+
if (!tipAppliesTargets(atTip, newer.branch, wave.name, targets, options.defaultBranch ?? opWaveDefaultBranch())) {
|
|
4730
4732
|
log(`wave ${k} (${wave.name}): ${newer.branch} has a newer commit ${newer.tip.slice(0, 12)}, and its wave does not apply every target of this job, so this job applies`);
|
|
4731
4733
|
return false;
|
|
4732
4734
|
}
|
|
@@ -86,13 +86,26 @@ export async function newerCommitOnBranch(cwd: string, env: NodeJS.ProcessEnv =
|
|
|
86
86
|
/** The default port: {@link newerCommitOnBranch} with the job's environment. */
|
|
87
87
|
export const gitOpWaveNewerCommit: OpWaveNewerCommitPort = (cwd, head) => newerCommitOnBranch(cwd, process.env, head);
|
|
88
88
|
|
|
89
|
+
/**
|
|
90
|
+
* The repository's default branch as the job's forge names it (#5032):
|
|
91
|
+
* `CHANT_DEFAULT_BRANCH` (a GitHub or Forgejo waves job sets it from the
|
|
92
|
+
* event), else GitLab's `CI_DEFAULT_BRANCH`. Undefined when neither is set.
|
|
93
|
+
*/
|
|
94
|
+
export function opWaveDefaultBranch(env: NodeJS.ProcessEnv = process.env): string | undefined {
|
|
95
|
+
const named = (env.CHANT_DEFAULT_BRANCH || env.CI_DEFAULT_BRANCH || "").trim();
|
|
96
|
+
return named === "" ? undefined : named;
|
|
97
|
+
}
|
|
98
|
+
|
|
89
99
|
/**
|
|
90
100
|
* Whether the spec at the newer commit (`atTip`, null when the file is gone
|
|
91
101
|
* there) applies every one of `targets` in wave `waveName` on `branch`.
|
|
102
|
+
* #5032: a spec with `defaultBranch` runs on `defaultBranch`, the name the
|
|
103
|
+
* forge gives the repository's default branch, beside its `branches`.
|
|
92
104
|
*/
|
|
93
|
-
export function tipAppliesTargets(atTip: OpWavesSpec | null, branch: string, waveName: string, targets: readonly string[]): boolean {
|
|
105
|
+
export function tipAppliesTargets(atTip: OpWavesSpec | null, branch: string, waveName: string, targets: readonly string[], defaultBranch?: string): boolean {
|
|
94
106
|
if (!atTip || !Array.isArray(atTip.waves)) return false;
|
|
95
|
-
|
|
107
|
+
const onDefault = atTip.defaultBranch === true && defaultBranch !== undefined && branch === defaultBranch;
|
|
108
|
+
if (!onDefault && !(atTip.branches ?? (atTip.defaultBranch === true ? [] : ["main"])).includes(branch)) return false;
|
|
96
109
|
const wave = atTip.waves.find((w) => w?.name === waveName);
|
|
97
110
|
if (!wave) return false;
|
|
98
111
|
if (wave.discover === true) return true;
|
package/src/op/op-waves.ts
CHANGED
|
@@ -483,8 +483,19 @@ export interface OpWavesSpec {
|
|
|
483
483
|
* so a change cannot drop the rule for its own gates.
|
|
484
484
|
*/
|
|
485
485
|
neverOverMcp?: boolean;
|
|
486
|
-
/** Branches whose pushes run the waves. Default `["main"]`. */
|
|
486
|
+
/** Branches whose pushes run the waves. Default `["main"]`, or none beside the default branch with `defaultBranch`. */
|
|
487
487
|
branches?: string[];
|
|
488
|
+
/**
|
|
489
|
+
* The pushes to the repository's default branch run the waves, by the
|
|
490
|
+
* name the forge gives it at run time (#5032): GitHub and Forgejo
|
|
491
|
+
* `github.event.repository.default_branch`, GitLab `$CI_DEFAULT_BRANCH`.
|
|
492
|
+
* `branches` names more beside it, and `main` is no longer the default.
|
|
493
|
+
* The job guard admits the default branch and those, the GitLab rules
|
|
494
|
+
* match the same, and the stand-down counts a newer commit on it. A
|
|
495
|
+
* product that renders the waves into a workflow of its own sets this
|
|
496
|
+
* when it never learns the branch's name. Default false.
|
|
497
|
+
*/
|
|
498
|
+
defaultBranch?: boolean;
|
|
488
499
|
/**
|
|
489
500
|
* An apply stands down when a newer commit on the branch will apply the
|
|
490
501
|
* same targets (#4581): its wave applies nothing, the job exits 6
|
|
@@ -996,6 +1007,7 @@ export function assertOpWavesSpec(spec: OpWavesSpec): void {
|
|
|
996
1007
|
}
|
|
997
1008
|
assertOpWaveHooks(where, spec.hooks);
|
|
998
1009
|
if (spec.standDown !== undefined && typeof spec.standDown !== "boolean") throw new Error(`${where}: \`standDown\` must be true or false.`);
|
|
1010
|
+
if (spec.defaultBranch !== undefined && typeof spec.defaultBranch !== "boolean") throw new Error(`${where}: \`defaultBranch\` must be true or false.`);
|
|
999
1011
|
{
|
|
1000
1012
|
const problems = opWaveReleaseProblems(spec);
|
|
1001
1013
|
if (problems.length > 0) throw new Error(`${where}: ${problems.join("; ")}.`);
|
package/src/release-floors.ts
CHANGED
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
* this constant to the next patch (#4501). The check fails while a floor
|
|
20
20
|
* still names this constant after its version shipped.
|
|
21
21
|
*/
|
|
22
|
-
export const NEXT_RELEASE = "0.124.
|
|
22
|
+
export const NEXT_RELEASE = "0.124.93";
|
|
23
23
|
|
|
24
24
|
/** The first chant with `chant dev local` and `chant dev bundle-check`, `@intentius/chant/local-chant` and `@intentius/chant/bundle-check` (`chantRuntimeTarget`, `chantExternalPlugin`, `checkBundle`): a product built against a chant checkout, and its bundle checked, without its own scripts (#4787). */
|
|
25
25
|
export const LOCAL_CHANT_FLOOR = "0.124.86";
|