@intentius/chant 0.124.93 → 0.124.94
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-product.d.ts +17 -1
- package/dist/ci-product.d.ts.map +1 -1
- package/dist/ci-product.js +23 -7
- package/dist/cli/handlers/run-wave.js +17 -3
- package/dist/cli/main.d.ts.map +1 -1
- package/dist/cli/main.js +4 -1
- package/dist/floor-table.data.d.ts.map +1 -1
- package/dist/floor-table.data.js +13 -6
- package/dist/gate-resume-run.d.ts +7 -0
- package/dist/gate-resume-run.d.ts.map +1 -1
- package/dist/gate-resume-run.js +42 -3
- package/dist/lexicon.d.ts +47 -1
- package/dist/lexicon.d.ts.map +1 -1
- package/dist/lifecycle/gate-applied.d.ts +18 -0
- package/dist/lifecycle/gate-applied.d.ts.map +1 -1
- package/dist/op/gate-run-locator.d.ts +17 -0
- package/dist/op/gate-run-locator.d.ts.map +1 -1
- package/dist/op/index.d.ts +3 -1
- package/dist/op/index.d.ts.map +1 -1
- package/dist/op/index.js +2 -1
- package/dist/op/op-waves-names.d.ts +40 -0
- package/dist/op/op-waves-names.d.ts.map +1 -1
- package/dist/op/op-waves-names.js +79 -0
- package/dist/op/op-waves-remainder.d.ts +110 -0
- package/dist/op/op-waves-remainder.d.ts.map +1 -0
- package/dist/op/op-waves-remainder.js +120 -0
- package/dist/op/op-waves-render-spec.d.ts +63 -5
- package/dist/op/op-waves-render-spec.d.ts.map +1 -1
- package/dist/op/op-waves-render-spec.js +68 -10
- package/dist/op/op-waves-run.d.ts +27 -1
- package/dist/op/op-waves-run.d.ts.map +1 -1
- package/dist/op/op-waves-run.js +192 -4
- package/dist/op/op-waves-split-resume.d.ts +57 -0
- package/dist/op/op-waves-split-resume.d.ts.map +1 -0
- package/dist/op/op-waves-split-resume.js +94 -0
- package/dist/op/op-waves.d.ts +26 -1
- package/dist/op/op-waves.d.ts.map +1 -1
- package/dist/op/op-waves.js +11 -2
- package/dist/release-floors.d.ts +9 -1
- package/dist/release-floors.d.ts.map +1 -1
- package/dist/release-floors.js +9 -1
- package/dist/wave-runtime.mjs +360 -360
- package/package.json +1 -1
- package/src/ci-product.ts +26 -7
- package/src/cli/handlers/run-wave.ts +16 -3
- package/src/cli/main.ts +4 -1
- package/src/floor-table.data.ts +13 -6
- package/src/gate-resume-run.ts +38 -3
- package/src/lexicon.ts +47 -1
- package/src/lifecycle/gate-applied.ts +16 -0
- package/src/op/gate-run-locator.ts +14 -0
- package/src/op/index.ts +5 -0
- package/src/op/op-waves-names.ts +80 -0
- package/src/op/op-waves-remainder.test.ts +342 -0
- package/src/op/op-waves-remainder.ts +146 -0
- package/src/op/op-waves-render-spec.test.ts +107 -0
- package/src/op/op-waves-render-spec.ts +81 -10
- package/src/op/op-waves-run.ts +200 -5
- package/src/op/op-waves-split-resume.test.ts +149 -0
- package/src/op/op-waves-split-resume.ts +109 -0
- package/src/op/op-waves.ts +33 -2
- package/src/release-floors.ts +13 -1
package/package.json
CHANGED
package/src/ci-product.ts
CHANGED
|
@@ -278,33 +278,48 @@ export const PRODUCT_JOB_NAMES_FLOOR = "0.124.92";
|
|
|
278
278
|
/**
|
|
279
279
|
* 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. Every job's guard admits the default branch (GitLab's `CI_DEFAULT_BRANCH`; on GitHub and Forgejo `CHANT_DEFAULT_BRANCH`, which each guarded job sets from `github.event.repository.default_branch`) and the named branches, every GitLab rule matches `$CI_DEFAULT_BRANCH` (the push's, the before-merge and the follow-on pipelines', the evidence, status, control and stale-notes jobs'), the GitHub and Forgejo jobs' `if:` names it when the product gives no `runIf`, and the stand-down counts a newer commit on it. Without it the waves run from `branches`, default `main`, as before.
|
|
280
280
|
*/
|
|
281
|
-
export const OP_WAVES_DEFAULT_BRANCH_FLOOR =
|
|
281
|
+
export const OP_WAVES_DEFAULT_BRANCH_FLOOR = "0.124.93";
|
|
282
282
|
|
|
283
283
|
/**
|
|
284
284
|
* 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. GitHub and Forgejo: each must pass, or, in a dispatched run, not have run, and it goes with `runIf`; GitLab: optional needs, each to pass. Absent, the jobs render as before.
|
|
285
285
|
*/
|
|
286
|
-
export const OP_WAVES_FIRST_WAVE_NEEDS_FLOOR =
|
|
286
|
+
export const OP_WAVES_FIRST_WAVE_NEEDS_FLOOR = "0.124.93";
|
|
287
287
|
|
|
288
288
|
/**
|
|
289
289
|
* 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>`. Without it the messages are as before.
|
|
290
290
|
*/
|
|
291
|
-
export const NOTIFY_RELAY_NAME_FLOOR =
|
|
291
|
+
export const NOTIFY_RELAY_NAME_FLOOR = "0.124.93";
|
|
292
292
|
|
|
293
293
|
/**
|
|
294
294
|
* 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). Without them the files render as before.
|
|
295
295
|
*/
|
|
296
|
-
export const OP_WAVES_RESUME_NAMES_FLOOR =
|
|
296
|
+
export const OP_WAVES_RESUME_NAMES_FLOOR = "0.124.93";
|
|
297
297
|
|
|
298
298
|
/**
|
|
299
299
|
* 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`. Without it the job is as before.
|
|
300
300
|
*/
|
|
301
|
-
export const WAVES_BEFORE_MERGE_ENVIRONMENT_FLOOR =
|
|
301
|
+
export const WAVES_BEFORE_MERGE_ENVIRONMENT_FLOOR = "0.124.93";
|
|
302
302
|
|
|
303
303
|
/**
|
|
304
304
|
* 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. Refused on GitHub and Forgejo, without `noteCommands`, and on a name another job has. Without it the pipeline is as before.
|
|
305
305
|
*/
|
|
306
|
-
export const NOTE_POLL_NAMES_FLOOR =
|
|
307
|
-
|
|
306
|
+
export const NOTE_POLL_NAMES_FLOOR = "0.124.93";
|
|
307
|
+
|
|
308
|
+
/**
|
|
309
|
+
* The first chant whose Op waves generators take `commandToken` (#5044), GitHub and Forgejo: the jobs that run only the default branch's code (a push's wave, deciding, share and job group jobs; a split wave's gate and record jobs) hand their command step the job's token as `GITHUB_TOKEN`, so the spec's `respond` posts a refused wave's diff and a failed apply's triage and a product's hooks can read the forge, and ask for `permissions` beside chant's own. A split wave's plan and applying jobs never get it; GitLab refuses it. Without it no wave job holds a token, as before.
|
|
310
|
+
*/
|
|
311
|
+
export const OP_WAVES_COMMAND_TOKEN_FLOOR = NEXT_RELEASE;
|
|
312
|
+
|
|
313
|
+
/**
|
|
314
|
+
* The first chant whose GitLab Op waves generator takes `cache` (#5045): the `cache:` entry or entries of each job that runs the wave's command (the wave's own, deciding, share and job group jobs, the policy job, a split wave's plan and applying jobs), such as terragucci's Terragrunt sources and providers cache. The gate and record jobs take none; GitHub and Forgejo refuse it, since a wave's `setup` step does this there. Without it no wave job has a cache, as before.
|
|
315
|
+
*/
|
|
316
|
+
export const OP_WAVES_GITLAB_CACHE_FLOOR = NEXT_RELEASE;
|
|
317
|
+
|
|
318
|
+
/**
|
|
319
|
+
* The first chant whose Op waves generators take `controlGroup` and `resumeGroup` (#5053): the control job's group (GitHub and Forgejo `concurrency` with `cancel-in-progress: false`, GitLab `resource_group`), with `{commit}` standing for the commit it tells the control repo about, so a push's run and a resume's run send one dispatch per commit; and the GitLab resume job's `resource_group`. Without them neither job has a group, as before.
|
|
320
|
+
*/
|
|
321
|
+
export const OP_WAVES_GROUPS_FLOOR = NEXT_RELEASE;
|
|
322
|
+
export { opWavesArtifacts, opWavesCommandToken, opWavesControlGroup, opWavesDispatchInputs, opWavesGitlabCache, opWavesNamer, opWavesResumeGroup, opWavesResumeWorkflowFile, opWavesWorkflowFile, type OpWavesArtifactNames, type OpWavesCommandToken, type OpWavesDispatchInput, type OpWavesJobNames, type OpWavesJobRef, type OpWavesJobRole, type OpWavesStageNames, type OpWavesStageRef } from "./op/op-waves-names";
|
|
308
323
|
|
|
309
324
|
/**
|
|
310
325
|
* Day-2 actions in the product pipeline (#4654): the `action` comment
|
|
@@ -517,6 +532,10 @@ export type { ProductMcpContext, ProductMcpHook } from "./cli/mcp/product-tools"
|
|
|
517
532
|
* and `destructiveHint`, and a contribution's `annotations` add the rest.
|
|
518
533
|
*/
|
|
519
534
|
export { MCP_TOOL_ANNOTATIONS_FLOOR, PRODUCT_MCP_PROPOSE_FLOOR, PRODUCT_TOOL_PROPOSE_WORDS } from "./cli/mcp/product-tools";
|
|
535
|
+
/** #5047: the Op waves keep the stopped-apply record (`approvals.remainder`, `approvals.spendStanding`), in place of a product's own. */
|
|
536
|
+
export { OP_WAVES_REMAINDER_FLOOR } from "./release-floors";
|
|
537
|
+
export { OP_WAVES_SPLIT_RESUME_FLOOR } from "./release-floors";
|
|
538
|
+
export { OP_WAVES_REMAINDER_PARITY_FLOOR } from "./release-floors";
|
|
520
539
|
export type { McpToolContribution, ToolAnnotations } from "./mcp/types";
|
|
521
540
|
export {
|
|
522
541
|
activeOtlp,
|
|
@@ -131,9 +131,22 @@ async function runOpWaveJobCommand(ctx: CommandContext): Promise<number> {
|
|
|
131
131
|
if (args.renderSpec) {
|
|
132
132
|
const at = await import("../../op/op-waves-render-spec");
|
|
133
133
|
const file = relative(process.cwd(), path);
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
const
|
|
134
|
+
const command = at.opWavesSpecCommandFromEnv();
|
|
135
|
+
// #5046: with CHANT_WAVES_SPEC_RUNS=head the runs come from the applied commit; the gate and record jobs take them from the saved plan.
|
|
136
|
+
const runsAtHead = at.opWavesSpecRunsAtHead() && phase !== "gate" && phase !== "record";
|
|
137
|
+
const rendered = at.renderOpWavesJobSpec({
|
|
138
|
+
specFile: file,
|
|
139
|
+
base: args.base ?? "HEAD^1",
|
|
140
|
+
cwd: process.cwd(),
|
|
141
|
+
render: at.commandSpecRender(command, file, process.cwd()),
|
|
142
|
+
fallback: gitShowAtBase,
|
|
143
|
+
parse: parseOpWavesSpec,
|
|
144
|
+
...(runsAtHead ? { runsAtHead, headRender: (baseSha: string) => at.commandSpecRender(command, file, process.cwd(), { [at.OP_WAVES_SPEC_BASE_ENV]: baseSha }) } : {}),
|
|
145
|
+
});
|
|
146
|
+
show = rendered.show;
|
|
147
|
+
spec = rendered.spec;
|
|
148
|
+
if (runsAtHead) console.error(`${spec.name}: the runs come from the spec rendered at ${rendered.sha.slice(0, 12)}, the applied commit; the rules from the one rendered at base`);
|
|
149
|
+
const missing = at.renderedJobMissing(spec, args.wave, job, rendered.at);
|
|
137
150
|
if (missing) {
|
|
138
151
|
console.error(`${missing}, so this job has nothing to apply`);
|
|
139
152
|
return 0;
|
package/src/cli/main.ts
CHANGED
|
@@ -618,7 +618,10 @@ Ops:
|
|
|
618
618
|
--render-spec runs the command CHANT_WAVES_SPEC_COMMAND
|
|
619
619
|
names (a JSON argv) with CHANT_WAVES_SPEC_AT set to
|
|
620
620
|
the base, writes the spec it prints over --spec, and
|
|
621
|
-
reads the rules at base from it (#4982).
|
|
621
|
+
reads the rules at base from it (#4982). With
|
|
622
|
+
CHANT_WAVES_SPEC_RUNS=head the spec it writes is
|
|
623
|
+
printed at HEAD, with CHANT_WAVES_SPEC_BASE set to
|
|
624
|
+
the base, and the rules still come from base (#5046).
|
|
622
625
|
--phase plan|gate|apply|record: one of a wave's four
|
|
623
626
|
jobs before merge (#4987). plan saves the plan and
|
|
624
627
|
writes nothing to chant/lifecycle; gate decides the
|
package/src/floor-table.data.ts
CHANGED
|
@@ -56,12 +56,15 @@ export const FLOOR_ROWS: readonly FloorRow[] = [
|
|
|
56
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
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
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:
|
|
60
|
-
{ name: "OP_WAVES_FIRST_WAVE_NEEDS_FLOOR", version:
|
|
61
|
-
{ name: "NOTIFY_RELAY_NAME_FLOOR", version:
|
|
62
|
-
{ name: "OP_WAVES_RESUME_NAMES_FLOOR", version:
|
|
63
|
-
{ name: "WAVES_BEFORE_MERGE_ENVIRONMENT_FLOOR", version:
|
|
64
|
-
{ name: "NOTE_POLL_NAMES_FLOOR", version:
|
|
59
|
+
{ name: "OP_WAVES_DEFAULT_BRANCH_FLOOR", version: "0.124.93", 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: "0.124.93", 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: "0.124.93", 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: "0.124.93", 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: "0.124.93", 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: "0.124.93", 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"] },
|
|
65
|
+
{ name: "OP_WAVES_COMMAND_TOKEN_FLOOR", version: NEXT_RELEASE, gates: "The first chant whose Op waves generators take `commandToken` (#5044), GitHub and Forgejo: the jobs that run only the default branch's code (a push's wave, deciding, share and job group jobs; a split wave's gate and record jobs) hand their command step the job's token as `GITHUB_TOKEN`, so the spec's `respond` posts a refused wave's diff and a failed apply's triage and a product's hooks can read the forge, and ask for `permissions` beside chant's own.", issue: "#5044", file: "ci-product.ts", modules: ["@intentius/chant/ci-product"] },
|
|
66
|
+
{ name: "OP_WAVES_GITLAB_CACHE_FLOOR", version: NEXT_RELEASE, gates: "The first chant whose GitLab Op waves generator takes `cache` (#5045): the `cache:` entry or entries of each job that runs the wave's command (the wave's own, deciding, share and job group jobs, the policy job, a split wave's plan and applying jobs), such as terragucci's Terragrunt sources and providers cache.", issue: "#5045", file: "ci-product.ts", modules: ["@intentius/chant/ci-product"] },
|
|
67
|
+
{ name: "OP_WAVES_GROUPS_FLOOR", version: NEXT_RELEASE, gates: "The first chant whose Op waves generators take `controlGroup` and `resumeGroup` (#5053): the control job's group (GitHub and Forgejo `concurrency` with `cancel-in-progress: false`, GitLab `resource_group`), with `{commit}` standing for the commit it tells the control repo about, so a push's run and a resume's run send one dispatch per commit; and the GitLab resume job's `resource_group`.", issue: "#5053", file: "ci-product.ts", modules: ["@intentius/chant/ci-product"] },
|
|
65
68
|
{ 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"] },
|
|
66
69
|
{ 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"] },
|
|
67
70
|
{ 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"] },
|
|
@@ -234,6 +237,10 @@ export const FLOOR_ROWS: readonly FloorRow[] = [
|
|
|
234
237
|
{ 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"] },
|
|
235
238
|
{ 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"] },
|
|
236
239
|
{ 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"] },
|
|
240
|
+
{ name: "RUNTIME_WAVES_SPEC_RUNS_AT_HEAD_FLOOR", version: NEXT_RELEASE, gates: "The first chant whose Op waves `renderSpec` takes `runsAtHead` (the jobs carry `CHANT_WAVES_SPEC_RUNS=head`): the job's own spec is rendered at the applied commit, with `CHANT_WAVES_SPEC_BASE` set to the base commit beside `CHANT_WAVES_SPEC_AT`, so the runs a change adds apply at its merge, while the gate policy, holds, hooks and evidence rules still come from the render at base (#5046).", issue: "#5046", file: "release-floors.ts", modules: ["@intentius/chant/op","@intentius/chant/op/index","@intentius/chant/op/op-waves-render-spec","@intentius/chant/release-floors"] },
|
|
241
|
+
{ name: "OP_WAVES_REMAINDER_FLOOR", version: NEXT_RELEASE, gates: "The first chant whose Op waves keep the record of an apply under an approval themselves (#5047): with `approvals.spend`, `approvals.remainder` writes each change the approved plans make, the commit and the run on the applied line (a split wave's gate job writes it), the job that applies the whole wave or the record job writes how the apply ended, and a wave run again at that commit applies the rest under the same approval when its plans make only changes the stopped apply did not finish; a wave that plans no change closes a stopped apply, and `approvals.spendStanding` spends an approval of the digest a wave its gate let through applies.", issue: "#5047", file: "release-floors.ts", modules: ["@intentius/chant/ci-product","@intentius/chant/op","@intentius/chant/op/index","@intentius/chant/op/op-waves-remainder","@intentius/chant/release-floors"] },
|
|
242
|
+
{ name: "OP_WAVES_SPLIT_RESUME_FLOOR", version: NEXT_RELEASE, gates: "The first chant whose `chant run resume` starts a killed split apply again on GitLab and Forgejo (#5052): under `approvals.remainder` the gate job's applied line names its run there too, GitLab's with the wave's applying and record jobs by name (`retry`), which the resume retries, and Forgejo's with the run's dispatch inputs (`inputs`), which the resume dispatches with, so the new run applies the rest at the same decided head or commit.", issue: "#5052", file: "release-floors.ts", modules: ["@intentius/chant/ci-product","@intentius/chant/op/op-waves-split-resume","@intentius/chant/release-floors"] },
|
|
243
|
+
{ name: "OP_WAVES_REMAINDER_PARITY_FLOOR", version: NEXT_RELEASE, gates: "The first chant whose `approvals.remainder` resumes the waves terragucci's own records resume (#5056): the terraform step gives a live choudoufu root's plan (`live-plan-set`) its `resourceDigests`, so its applied line names the changes, and the cover leaves out the cost member `(monthly cost)`, whose digest follows from the plans, on both sides.", issue: "#5056", file: "release-floors.ts", modules: ["@intentius/chant/ci-product","@intentius/chant/op/op-waves-remainder","@intentius/chant/release-floors"] },
|
|
237
244
|
{ 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"] },
|
|
238
245
|
{ 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"] },
|
|
239
246
|
{ 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"] },
|
package/src/gate-resume-run.ts
CHANGED
|
@@ -27,6 +27,13 @@
|
|
|
27
27
|
* jobs before the gate run again too; they must be safe to repeat (a wave
|
|
28
28
|
* whose runs already applied plans nothing and applies nothing new).
|
|
29
29
|
*
|
|
30
|
+
* A killed split apply (#5052): a split wave's gate job writes the applied
|
|
31
|
+
* line, and its applying job is the one killed. On GitLab its locator names
|
|
32
|
+
* the wave's applying and record jobs (`retry`), and each applying job's
|
|
33
|
+
* newest try that failed or was cancelled is retried, then the record job.
|
|
34
|
+
* On Forgejo it carries the run's dispatch inputs (`inputs`), and the
|
|
35
|
+
* dispatch sends them, so a before-merge run plans the same decided head.
|
|
36
|
+
*
|
|
30
37
|
* Resuming approves nothing. The resumed job decides the gate again from the
|
|
31
38
|
* ledger, so resuming a run whose approval does not count only makes it wait
|
|
32
39
|
* again. {@link resumeGateRun} skips a run that is still going, that ended
|
|
@@ -77,6 +84,8 @@ export function gitlabEvidenceJobOf(job: string): string {
|
|
|
77
84
|
|
|
78
85
|
/** The GitLab job statuses of a job that ran and ended; a `skipped` or `created` job GitLab runs again after a retry itself. */
|
|
79
86
|
const GITLAB_FINISHED = new Set(["success", "failed", "canceled"]);
|
|
87
|
+
/** The statuses of a job that is not going and will not start by itself: finished, skipped, or waiting for a person. */
|
|
88
|
+
const GITLAB_ENDED = new Set([...GITLAB_FINISHED, "skipped", "manual"]);
|
|
80
89
|
|
|
81
90
|
const trimSlash = (s: string): string => s.replace(/\/+$/, "");
|
|
82
91
|
|
|
@@ -131,6 +140,28 @@ export async function resumeGateRun(loc: GateRunLocator, opts: ResumeGateRunOpti
|
|
|
131
140
|
if (loc.forge === "gitlab") {
|
|
132
141
|
const call = client(loc.api, { "PRIVATE-TOKEN": opts.token }, fetchImpl);
|
|
133
142
|
const project = `/projects/${encodeURIComponent(decodeURIComponent(loc.repo))}`;
|
|
143
|
+
// #5052: a split wave's applying jobs, by name in the same pipeline, and its record job after them.
|
|
144
|
+
if (loc.retry?.apply.length) {
|
|
145
|
+
const listed = await call("GET", `${project}/pipelines/${loc.run}/jobs?per_page=100`);
|
|
146
|
+
// The list leaves retried jobs out, so the job of a name is its newest try.
|
|
147
|
+
const jobs = Array.isArray(listed) ? listed.filter(isObject) : [];
|
|
148
|
+
const newest = (name: string) => jobs.find((j) => j.name === name);
|
|
149
|
+
const applying = loc.retry.apply.map((name) => ({ name, job: newest(name) }));
|
|
150
|
+
const going = applying.find((a) => a.job && !GITLAB_ENDED.has(String(a.job.status)));
|
|
151
|
+
if (going) return skip(`job ${String(going.job!.id)} (${going.name}) is ${String(going.job!.status)}, not finished`);
|
|
152
|
+
const stopped = applying.filter((a) => a.job && (a.job.status === "failed" || a.job.status === "canceled"));
|
|
153
|
+
if (stopped.length > 0) {
|
|
154
|
+
const record = loc.retry.record ? newest(loc.retry.record) : undefined;
|
|
155
|
+
const after = record && GITLAB_FINISHED.has(String(record.status)) ? record : undefined;
|
|
156
|
+
const what = [...stopped.map((a) => `job ${String(a.job!.id)} (${a.name})`), ...(after ? [`its record job ${String(after.id)}`] : [])].join(" and ");
|
|
157
|
+
if (opts.dryRun) return wouldResume(`retry ${what}`);
|
|
158
|
+
for (const a of stopped) await call("POST", `${project}/jobs/${String(a.job!.id)}/retry`);
|
|
159
|
+
// It needs the applying jobs, so it waits for their new tries.
|
|
160
|
+
if (after) await call("POST", `${project}/jobs/${String(after.id)}/retry`);
|
|
161
|
+
return { status: "resumed", forge: "gitlab", how: `retried ${what}`, ...url };
|
|
162
|
+
}
|
|
163
|
+
// No applying job stopped: the gate job's own try says what is left (it succeeded, or stopped before them).
|
|
164
|
+
}
|
|
134
165
|
const job = await call("GET", `${project}/jobs/${loc.job}`);
|
|
135
166
|
if (!isObject(job)) throw new Error(`GET ${project}/jobs/${loc.job} returned no job`);
|
|
136
167
|
const status = String(job.status);
|
|
@@ -172,16 +203,20 @@ export async function resumeGateRun(loc: GateRunLocator, opts: ResumeGateRunOpti
|
|
|
172
203
|
const runs = isObject(listed) && Array.isArray(listed.workflow_runs) ? listed.workflow_runs : Array.isArray(listed) ? listed : [];
|
|
173
204
|
// Forgejo reports `created` in whole seconds.
|
|
174
205
|
const since = opts.since ? Math.floor(new Date(opts.since).getTime() / 1000) * 1000 : undefined;
|
|
206
|
+
// #5052: a run that a resume with inputs started is a dispatch; a push or a comment of the branch since is not one.
|
|
207
|
+
const inputs = loc.inputs && Object.keys(loc.inputs).length > 0 ? loc.inputs : undefined;
|
|
175
208
|
const later = runs.find(
|
|
176
209
|
(r) =>
|
|
177
210
|
isObject(r) && Number(r.id) > Number(loc.run) &&
|
|
178
211
|
(r.prettyref === undefined || r.prettyref === loc.ref) &&
|
|
212
|
+
(!inputs || r.event === undefined || r.event === "workflow_dispatch") &&
|
|
179
213
|
(since === undefined || (typeof r.created === "string" && new Date(r.created).getTime() >= since)),
|
|
180
214
|
);
|
|
181
215
|
if (isObject(later)) return skip(`run ${String(later.id)} of ${loc.workflow} started after the approval`);
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
216
|
+
const with_ = inputs ? ` with ${Object.entries(inputs).map(([k, v]) => `${k}=${v}`).join(", ")}` : "";
|
|
217
|
+
if (opts.dryRun) return wouldResume(`dispatch ${loc.workflow} on ${loc.ref}${with_}`);
|
|
218
|
+
await call("POST", `${repo}/actions/workflows/${encodeURIComponent(loc.workflow!)}/dispatches`, { ref: loc.ref, ...(inputs ? { inputs } : {}) });
|
|
219
|
+
return { status: "resumed", forge: "forgejo", how: `dispatched ${loc.workflow} on ${loc.ref}${with_}`, ...url };
|
|
185
220
|
}
|
|
186
221
|
|
|
187
222
|
/**
|
package/src/lexicon.ts
CHANGED
|
@@ -1182,7 +1182,11 @@ export interface OpWavesPipelineOptions
|
|
|
1182
1182
|
* the commit in `CHANT_WAVES_SPEC_AT`. The spec handed to the generator
|
|
1183
1183
|
* is the pipeline's shape (its waves, shares, job groups, `cloud`,
|
|
1184
1184
|
* runners, environments and `holds.policy`); the rendered one sets the
|
|
1185
|
-
* rules. Absent: the jobs read the committed spec as before.
|
|
1185
|
+
* rules. Absent: the jobs read the committed spec as before. With
|
|
1186
|
+
* `runsAtHead: true` (#5046) the jobs also carry
|
|
1187
|
+
* `CHANT_WAVES_SPEC_RUNS=head`: the job's own spec, its runs, is rendered
|
|
1188
|
+
* at the applied commit with `CHANT_WAVES_SPEC_BASE` set to the base, and
|
|
1189
|
+
* the rules still come from the render at base.
|
|
1186
1190
|
*/
|
|
1187
1191
|
renderSpec?: import("./op/op-waves-render-spec").OpWavesRenderSpec;
|
|
1188
1192
|
/**
|
|
@@ -1288,6 +1292,48 @@ export interface OpWavesPipelineOptions
|
|
|
1288
1292
|
* the same workflow or pipeline, so this goes with `runIf`. Absent: none.
|
|
1289
1293
|
*/
|
|
1290
1294
|
firstWaveNeeds?: string[];
|
|
1295
|
+
/**
|
|
1296
|
+
* GitHub and Forgejo (#5044): the job's token in the command step of the
|
|
1297
|
+
* jobs that run only the default branch's code (a push's wave, deciding,
|
|
1298
|
+
* share and job group jobs; a split wave's gate and record jobs), as
|
|
1299
|
+
* `GITHUB_TOKEN`, so the spec's `respond` posts a refused wave's diff and
|
|
1300
|
+
* a failed apply's triage, and a product's hooks can read the forge. The
|
|
1301
|
+
* jobs ask for `permissions` beside chant's own, such as terragucci's
|
|
1302
|
+
* `pull-requests: write` and, with its review agent, `actions: read`.
|
|
1303
|
+
* A split wave's plan and applying jobs run the change's code and never
|
|
1304
|
+
* get it. GitLab refuses it: its jobs read `CHANT_FORGE_TOKEN`. Absent:
|
|
1305
|
+
* no wave job holds a token, as before.
|
|
1306
|
+
*/
|
|
1307
|
+
commandToken?: import("./op/op-waves-names").OpWavesCommandToken;
|
|
1308
|
+
/**
|
|
1309
|
+
* GitLab (#5045): the `cache:` of each job that runs the wave's command
|
|
1310
|
+
* (the wave's own, deciding, share and job group jobs, the policy job, and
|
|
1311
|
+
* a split wave's plan and applying jobs), one entry or a list as GitLab
|
|
1312
|
+
* takes them, such as terragucci's Terragrunt sources and providers cache.
|
|
1313
|
+
* The gate and record jobs plan and apply nothing, so they take none.
|
|
1314
|
+
* GitHub and Forgejo refuse it: a wave's `setup` step does this there.
|
|
1315
|
+
* Absent: no cache, as before.
|
|
1316
|
+
*/
|
|
1317
|
+
cache?: Record<string, unknown> | Array<Record<string, unknown>>;
|
|
1318
|
+
/**
|
|
1319
|
+
* The control job's group (#5053), so the control repo gets one send per
|
|
1320
|
+
* commit when a push's run and a resume's run both reach it: GitHub and
|
|
1321
|
+
* Forgejo `concurrency: { group, cancel-in-progress: false }`, GitLab
|
|
1322
|
+
* `resource_group`. `{commit}` in it stands for the commit the job tells
|
|
1323
|
+
* the control repo about (`${{ github.sha }}`, or a follow-on run's commit
|
|
1324
|
+
* input; GitLab `$CI_COMMIT_SHA` or `CHANT_WAVES_COMMIT`), such as
|
|
1325
|
+
* terragucci's `terragucci-control-${{ github.repository }}-{commit}`.
|
|
1326
|
+
* Needs `control` on the spec. Absent: no group, as before.
|
|
1327
|
+
*/
|
|
1328
|
+
controlGroup?: string;
|
|
1329
|
+
/**
|
|
1330
|
+
* GitLab (#5053): the resume job's `resource_group`, such as terragucci's
|
|
1331
|
+
* `terragucci-resume`, so two resume pipelines that overlap do not both
|
|
1332
|
+
* retry the same waiting job. GitHub and Forgejo refuse it: their resume
|
|
1333
|
+
* workflow has its own group, `<spec>-resume`. Needs `resume` on the
|
|
1334
|
+
* spec. Absent: no resource group, as before.
|
|
1335
|
+
*/
|
|
1336
|
+
resumeGroup?: string;
|
|
1291
1337
|
}
|
|
1292
1338
|
|
|
1293
1339
|
/** A run step a product adds to a generated job (#4791): its name, and its shell lines in order. */
|
|
@@ -53,6 +53,22 @@ export interface AppliedGateRecord {
|
|
|
53
53
|
* hook again under it; any other job reads it as spent.
|
|
54
54
|
*/
|
|
55
55
|
rerun?: { head: string };
|
|
56
|
+
/**
|
|
57
|
+
* Under `approvals.remainder` (#5047): each change the approved plans
|
|
58
|
+
* make, a run's resource and its digest, sorted. A wave run again at
|
|
59
|
+
* `commit` whose plans make only some of them applies those under this
|
|
60
|
+
* line's approval while no finished line says the apply applied.
|
|
61
|
+
*/
|
|
62
|
+
changes?: AppliedGateChange[];
|
|
63
|
+
/** With `changes` (#5047): the digest members that are no run (the wave's cost), as the approved set held them. */
|
|
64
|
+
extras?: { member: string; planDigest: string }[];
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/** One change an approved plan makes (#5047): a run's resource, by the engine's address, and its digest. */
|
|
68
|
+
export interface AppliedGateChange {
|
|
69
|
+
target: string;
|
|
70
|
+
address: string;
|
|
71
|
+
digest: string;
|
|
56
72
|
}
|
|
57
73
|
|
|
58
74
|
/**
|
|
@@ -28,6 +28,20 @@ export interface GateRunLocator {
|
|
|
28
28
|
workflow?: string;
|
|
29
29
|
/** Forgejo: the branch a dispatch runs on. */
|
|
30
30
|
ref?: string;
|
|
31
|
+
/**
|
|
32
|
+
* GitLab (#5052): the jobs of the same pipeline a resume retries, by name,
|
|
33
|
+
* in place of `job`: a split wave's applying jobs, each retried when its
|
|
34
|
+
* newest try failed or was cancelled, and its record job, retried after
|
|
35
|
+
* them when it ran. The gate job that writes the applied line knows their
|
|
36
|
+
* names, not their ids.
|
|
37
|
+
*/
|
|
38
|
+
retry?: { apply: string[]; record?: string };
|
|
39
|
+
/**
|
|
40
|
+
* Forgejo (#5052): the `workflow_dispatch` inputs a resume dispatches
|
|
41
|
+
* with, so a before-merge run or a follow-on is started again for the
|
|
42
|
+
* same decided head or commit instead of the branch's head.
|
|
43
|
+
*/
|
|
44
|
+
inputs?: Record<string, string>;
|
|
31
45
|
/** The run's page, for a person. */
|
|
32
46
|
url?: string;
|
|
33
47
|
}
|
package/src/op/index.ts
CHANGED
|
@@ -143,13 +143,18 @@ export { notifyOpWave, opWaveNotifyFields } from "./op-waves-notify";
|
|
|
143
143
|
export {
|
|
144
144
|
OP_WAVES_RENDER_SPEC_FLAG,
|
|
145
145
|
OP_WAVES_SPEC_AT_ENV,
|
|
146
|
+
OP_WAVES_SPEC_BASE_ENV,
|
|
146
147
|
OP_WAVES_SPEC_COMMAND_ENV,
|
|
147
148
|
OP_WAVES_SPEC_FILE_ENV,
|
|
149
|
+
OP_WAVES_SPEC_RUNS_ENV,
|
|
148
150
|
RUNTIME_WAVES_SPEC_FLOOR,
|
|
151
|
+
RUNTIME_WAVES_SPEC_RUNS_AT_HEAD_FLOOR,
|
|
149
152
|
opWavesRenderSpecEnv,
|
|
150
153
|
opWavesRenderSpecProblems,
|
|
151
154
|
} from "./op-waves-render-spec";
|
|
152
155
|
export type { OpWavesRenderSpec } from "./op-waves-render-spec";
|
|
156
|
+
export { OP_WAVES_REMAINDER_FLOOR, opWaveApprovedChanges, opWaveCoverRemainder, opWaveRunCovered, opWaveStoppedApply, opWaveUnfinishedApply } from "./op-waves-remainder";
|
|
157
|
+
export type { AppliedGateChange, OpWaveCover, OpWaveRemainderMember } from "./op-waves-remainder";
|
|
153
158
|
export { OP_WAVE_STAND_DOWN_FLOOR, gitOpWaveNewerCommit, newerCommitOnBranch, opWaveDefaultBranch, opWaveRunBranch, opWaveStandDownReason, tipAppliesTargets } from "./op-waves-stand-down";
|
|
154
159
|
export type { OpWaveNewerCommit, OpWaveNewerCommitPort } from "./op-waves-stand-down";
|
|
155
160
|
export { OP_WAVE_RELEASE_RECORD_FLOOR, opWaveReleaseNames, opWaveReleaseProblems, releaseOfCommit } from "./op-waves-release";
|
package/src/op/op-waves-names.ts
CHANGED
|
@@ -208,6 +208,86 @@ export function opWavesFirstWaveNeeds(given: readonly string[] | undefined, forg
|
|
|
208
208
|
return [...given];
|
|
209
209
|
}
|
|
210
210
|
|
|
211
|
+
/**
|
|
212
|
+
* The forge token a wave job's command step gets (#5044): with it, the
|
|
213
|
+
* jobs that run only the default branch's code (a push's wave, deciding,
|
|
214
|
+
* share and job group jobs; a split wave's gate and record jobs) hand their
|
|
215
|
+
* command step the job's token as `GITHUB_TOKEN`, so the spec's `respond`
|
|
216
|
+
* posts and a product's hooks can read the forge, and the job asks for
|
|
217
|
+
* `permissions` on top of chant's own. A split wave's plan and applying jobs
|
|
218
|
+
* run the change's code and never get it. GitHub and Forgejo only.
|
|
219
|
+
*/
|
|
220
|
+
export interface OpWavesCommandToken {
|
|
221
|
+
/** GitHub's permission scopes the jobs ask for beside chant's own, such as `{ "pull-requests": "write", actions: "read" }`. `contents` and `id-token` are chant's. */
|
|
222
|
+
permissions?: Record<string, "read" | "write">;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/** The GitHub permission scopes a product may add with {@link OpWavesCommandToken}. `contents` and `id-token` stay chant's. */
|
|
226
|
+
const COMMAND_TOKEN_SCOPES = new Set(["actions", "attestations", "checks", "deployments", "discussions", "issues", "packages", "pages", "pull-requests", "repository-projects", "security-events", "statuses"]);
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* {@link OpWavesCommandToken}'s permissions, checked (#5044): each a scope
|
|
230
|
+
* GitHub knows that chant does not set itself, `read` or `write`. Undefined
|
|
231
|
+
* when there is no token to give. GitLab refuses it, since its jobs read
|
|
232
|
+
* `CHANT_FORGE_TOKEN`, a CI/CD variable.
|
|
233
|
+
*/
|
|
234
|
+
export function opWavesCommandToken(token: OpWavesCommandToken | undefined, forge: "github" | "forgejo" | "gitlab"): Record<string, "read" | "write"> | undefined {
|
|
235
|
+
if (token === undefined) return undefined;
|
|
236
|
+
if (forge === "gitlab") throw new Error("commandToken gives a GitHub or Forgejo wave job its token; a GitLab job reads CHANT_FORGE_TOKEN, a CI/CD variable, so leave it out");
|
|
237
|
+
if (token === null || typeof token !== "object" || Array.isArray(token)) throw new Error("commandToken is { permissions }");
|
|
238
|
+
const permissions = token.permissions ?? {};
|
|
239
|
+
if (permissions === null || typeof permissions !== "object" || Array.isArray(permissions)) throw new Error("commandToken.permissions maps a permission scope to read or write");
|
|
240
|
+
for (const [scope, level] of Object.entries(permissions)) {
|
|
241
|
+
if (scope === "contents" || scope === "id-token") throw new Error(`commandToken.permissions names ${scope}, which chant sets on the wave jobs itself`);
|
|
242
|
+
if (!COMMAND_TOKEN_SCOPES.has(scope)) throw new Error(`commandToken.permissions names ${JSON.stringify(scope)}, which is not a GitHub permission scope`);
|
|
243
|
+
if (level !== "read" && level !== "write") throw new Error(`commandToken.permissions.${scope} is ${JSON.stringify(level)}; give read or write`);
|
|
244
|
+
}
|
|
245
|
+
return { ...permissions };
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* The control job's group a product names (#5053), checked, with `{commit}`
|
|
250
|
+
* put in as `commit`, the forge's expression of the commit the job tells the
|
|
251
|
+
* control repo about. Undefined when none. One line; a spec without
|
|
252
|
+
* `control` has no job to put it on.
|
|
253
|
+
*/
|
|
254
|
+
export function opWavesControlGroup(group: string | undefined, hasControl: boolean, commit: string): string | undefined {
|
|
255
|
+
if (group === undefined) return undefined;
|
|
256
|
+
if (typeof group !== "string" || group.trim() === "" || /[\r\n]/.test(group)) throw new Error(`controlGroup ${JSON.stringify(group)} is one line naming the control job's group`);
|
|
257
|
+
if (!hasControl) throw new Error("controlGroup names the control job's group, and the spec has no control");
|
|
258
|
+
return group.split("{commit}").join(commit);
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* GitLab (#5053): the resume job's `resource_group` a product names, checked.
|
|
263
|
+
* Undefined when none. GitHub and Forgejo refuse it, since their resume
|
|
264
|
+
* workflow has its own group, `<spec>-resume`.
|
|
265
|
+
*/
|
|
266
|
+
export function opWavesResumeGroup(group: string | undefined, hasResume: boolean, forge: "github" | "forgejo" | "gitlab"): string | undefined {
|
|
267
|
+
if (group === undefined) return undefined;
|
|
268
|
+
if (forge !== "gitlab") throw new Error("resumeGroup is the GitLab resume job's resource_group; the GitHub and Forgejo resume workflow has its own concurrency group, <spec>-resume");
|
|
269
|
+
if (typeof group !== "string" || group.trim() === "" || /[\r\n]/.test(group)) throw new Error(`resumeGroup ${JSON.stringify(group)} is one line naming the resume job's resource_group`);
|
|
270
|
+
if (!hasResume) throw new Error("resumeGroup names the resume job's resource_group, and the spec has no resume");
|
|
271
|
+
return group;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* GitLab (#5045): the `cache:` a product gives the wave jobs that run the
|
|
276
|
+
* wave's command, one entry or a list of them as GitLab takes them, such as
|
|
277
|
+
* terragucci's `{ key: terragucci-terragrunt, paths: [.terragrunt-cache/] }`.
|
|
278
|
+
* Each entry is a mapping with `paths` or `key`. Undefined when none.
|
|
279
|
+
*/
|
|
280
|
+
export function opWavesGitlabCache(cache: Record<string, unknown> | Array<Record<string, unknown>> | undefined): Record<string, unknown> | Array<Record<string, unknown>> | undefined {
|
|
281
|
+
if (cache === undefined) return undefined;
|
|
282
|
+
const entries = Array.isArray(cache) ? cache : [cache];
|
|
283
|
+
if (entries.length === 0) throw new Error("cache is a GitLab cache entry or a list of them; leave it out for none");
|
|
284
|
+
for (const entry of entries) {
|
|
285
|
+
if (entry === null || typeof entry !== "object" || Array.isArray(entry)) throw new Error("cache holds GitLab cache entries, each a mapping such as { key, paths }");
|
|
286
|
+
if (entry.paths === undefined && entry.key === undefined) throw new Error("a cache entry names its paths or its key");
|
|
287
|
+
}
|
|
288
|
+
return cache;
|
|
289
|
+
}
|
|
290
|
+
|
|
211
291
|
/** Refuse a product job of {@link opWavesFirstWaveNeeds} that is a job the generator writes (#5032). */
|
|
212
292
|
export function assertFirstWaveNeedsOutside(needs: readonly string[], jobs: Iterable<string>): void {
|
|
213
293
|
const mine = new Set(jobs);
|