@intentius/chant 0.124.91 → 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-comment-commands.d.ts +11 -1
- package/dist/ci-comment-commands.d.ts.map +1 -1
- package/dist/ci-comment-commands.js +10 -3
- package/dist/ci-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 +42 -1
- package/dist/ci-product.d.ts.map +1 -1
- package/dist/ci-product.js +44 -3
- package/dist/cli/handlers/pr-comment.d.ts.map +1 -1
- package/dist/cli/handlers/pr-comment.js +15 -2
- package/dist/cli/handlers/pr.d.ts.map +1 -1
- package/dist/cli/handlers/pr.js +4 -1
- package/dist/components/pr-pipeline.d.ts +4 -2
- package/dist/components/pr-pipeline.d.ts.map +1 -1
- package/dist/components/pr-pipeline.js +7 -4
- package/dist/components/product-pipeline.d.ts +71 -7
- package/dist/components/product-pipeline.d.ts.map +1 -1
- package/dist/components/product-pipeline.js +84 -22
- package/dist/components/product-plan.d.ts +7 -0
- package/dist/components/product-plan.d.ts.map +1 -1
- package/dist/components/product-plan.js +1 -0
- package/dist/floor-table.data.d.ts.map +1 -1
- package/dist/floor-table.data.js +15 -5
- package/dist/lexicon.d.ts +59 -1
- 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-decide.d.ts +2 -0
- package/dist/op/before-merge-decide.d.ts.map +1 -1
- 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-evidence-jobs.d.ts +3 -2
- package/dist/op/op-waves-evidence-jobs.d.ts.map +1 -1
- package/dist/op/op-waves-evidence-jobs.js +4 -3
- package/dist/op/op-waves-follow-on.d.ts +2 -0
- package/dist/op/op-waves-follow-on.d.ts.map +1 -1
- package/dist/op/op-waves-follow-on.js +8 -2
- package/dist/op/op-waves-names.d.ts +145 -0
- package/dist/op/op-waves-names.d.ts.map +1 -0
- package/dist/op/op-waves-names.js +201 -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/pr-forge-job.d.ts +8 -0
- package/dist/pr-forge-job.d.ts.map +1 -1
- package/dist/pr-forge-job.js +13 -0
- package/dist/pr-plan-record.d.ts +3 -1
- package/dist/pr-plan-record.d.ts.map +1 -1
- package/dist/pr-plan-record.js +1 -1
- package/dist/pr-post.d.ts +9 -3
- package/dist/pr-post.d.ts.map +1 -1
- package/dist/pr-post.js +5 -2
- package/dist/release-floors.d.ts +1 -1
- package/dist/release-floors.d.ts.map +1 -1
- package/dist/release-floors.js +4 -4
- package/dist/wave-runtime.mjs +305 -305
- 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-comment-commands.test.ts +19 -5
- package/src/ci-comment-commands.ts +18 -3
- 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 +54 -3
- package/src/cli/handlers/pr-comment.ts +12 -2
- package/src/cli/handlers/pr.ts +4 -1
- package/src/components/pr-pipeline.ts +7 -4
- package/src/components/product-job-names.test.ts +176 -0
- package/src/components/product-pipeline.ts +143 -31
- package/src/components/product-plan.ts +8 -0
- package/src/floor-table.data.ts +15 -5
- package/src/lexicon.ts +59 -1
- 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-decide.ts +2 -0
- package/src/op/before-merge.ts +12 -0
- package/src/op/index.ts +1 -1
- package/src/op/op-waves-evidence-jobs.ts +4 -3
- package/src/op/op-waves-follow-on.ts +10 -2
- package/src/op/op-waves-names.test.ts +131 -0
- package/src/op/op-waves-names.ts +289 -0
- 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/pr-forge-job.ts +13 -0
- package/src/pr-plan-record.ts +4 -2
- package/src/pr-post-head.test.ts +116 -0
- package/src/pr-post.ts +15 -5
- package/src/release-floors.ts +4 -4
package/src/ci-product.ts
CHANGED
|
@@ -152,7 +152,7 @@ export const COMMENT_LEAVES_COMMIT_FLOOR = "0.124.88";
|
|
|
152
152
|
* The first chant with the comment job on GitHub and Forgejo and the replies to commands no job runs (#4946): `commentJob` in the product pipeline (`chant components pr-comment`, `answerProductComment` in `@intentius/chant/ci-comment-commands`), which replies to a refusal and to a command the pipeline runs no job for, and with waves on merge starts a merged pull request's apply again; the words' `replies` and an alias's `refuse`, which the GitLab note poll reads too, as `chantNoteRuns`' `members`; `retryApply`; and `locks: "plan"` in GitHub's and Forgejo's product plan, with the lock, unlock and comment lock jobs.
|
|
153
153
|
*/
|
|
154
154
|
export const COMMENT_COMMANDS_FLOOR = "0.124.89";
|
|
155
|
-
export { answerProductComment, answeredElsewhere, COMMENT_JOBS_ENV, commentRuns, PR_COMMENT_JOB, RERUN_APPLY_JOBS, type CommentJobs, type CommentOutcome, type CommentRuns, type AnswerCommentOptions } from "./ci-comment-commands";
|
|
155
|
+
export { answerProductComment, answeredElsewhere, COMMENT_JOBS_ENV, commentRuns, PR_COMMENT_JOB, RERUN_APPLY_JOBS, rerunApplyJobs, type CommentJobs, type CommentOutcome, type CommentRuns, type AnswerCommentOptions } from "./ci-comment-commands";
|
|
156
156
|
export { forkReply, memberReply, notRunReply } from "./ci-comment-replies";
|
|
157
157
|
export type { CiProductCommentReplies } from "./ci-product-words";
|
|
158
158
|
export { productCommentJob, type ProductCommentJob } from "./components/product-pipeline";
|
|
@@ -247,13 +247,64 @@ export { PLAN_SUBJECT_LIMIT, planSubjectProblem, sinceLastLine, subjectChanges,
|
|
|
247
247
|
/**
|
|
248
248
|
* 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`).
|
|
249
249
|
*/
|
|
250
|
-
export const PRODUCT_PLAN_NAMES_FLOOR =
|
|
250
|
+
export const PRODUCT_PLAN_NAMES_FLOOR = "0.124.91";
|
|
251
251
|
export { productPlanContext, productPlanReportDir, productPlanWorkflowFile } from "./components/product-plan";
|
|
252
252
|
|
|
253
253
|
/**
|
|
254
254
|
* 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. GitHub and Forgejo refuse it.
|
|
255
255
|
*/
|
|
256
|
-
export const PRODUCT_PLAN_ARTIFACTS_FLOOR =
|
|
256
|
+
export const PRODUCT_PLAN_ARTIFACTS_FLOOR = "0.124.91";
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* 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. A product's own `idTokens` leave them in the plan step, whose verb requests them.
|
|
260
|
+
*/
|
|
261
|
+
export const PRODUCT_PLAN_LOGIN_TOKENS_FLOOR = "0.124.92";
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* 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. `pr-post --head <head>` takes a report, a plan note hand-off or a run record for the head or for the run's merge preview the plan job checked out (`plannedForHead`), so a product's plan verb may write its hand-off for either.
|
|
265
|
+
*/
|
|
266
|
+
export const PR_HEAD_SHA_FLOOR = "0.124.92";
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* 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`.
|
|
270
|
+
*/
|
|
271
|
+
export const OP_WAVES_NAMES_FLOOR = "0.124.92";
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* 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. Without them the job is `comment` and the re-run looks for `RERUN_APPLY_JOBS`, as before.
|
|
275
|
+
*/
|
|
276
|
+
export const PRODUCT_JOB_NAMES_FLOOR = "0.124.92";
|
|
277
|
+
|
|
278
|
+
/**
|
|
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
|
+
*/
|
|
281
|
+
export const OP_WAVES_DEFAULT_BRANCH_FLOOR = NEXT_RELEASE;
|
|
282
|
+
|
|
283
|
+
/**
|
|
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
|
+
*/
|
|
286
|
+
export const OP_WAVES_FIRST_WAVE_NEEDS_FLOOR = NEXT_RELEASE;
|
|
287
|
+
|
|
288
|
+
/**
|
|
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
|
+
*/
|
|
291
|
+
export const NOTIFY_RELAY_NAME_FLOOR = NEXT_RELEASE;
|
|
292
|
+
|
|
293
|
+
/**
|
|
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
|
+
*/
|
|
296
|
+
export const OP_WAVES_RESUME_NAMES_FLOOR = NEXT_RELEASE;
|
|
297
|
+
|
|
298
|
+
/**
|
|
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
|
+
*/
|
|
301
|
+
export const WAVES_BEFORE_MERGE_ENVIRONMENT_FLOOR = NEXT_RELEASE;
|
|
302
|
+
|
|
303
|
+
/**
|
|
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
|
+
*/
|
|
306
|
+
export const NOTE_POLL_NAMES_FLOOR = NEXT_RELEASE;
|
|
307
|
+
export { opWavesArtifacts, opWavesDispatchInputs, opWavesNamer, opWavesResumeWorkflowFile, opWavesWorkflowFile, type OpWavesArtifactNames, type OpWavesDispatchInput, type OpWavesJobNames, type OpWavesJobRef, type OpWavesJobRole, type OpWavesStageNames, type OpWavesStageRef } from "./op/op-waves-names";
|
|
257
308
|
|
|
258
309
|
/**
|
|
259
310
|
* Day-2 actions in the product pipeline (#4654): the `action` comment
|
|
@@ -34,7 +34,7 @@ export function commentJobsFromEnv(raw: string | undefined): CommentJobs {
|
|
|
34
34
|
if (raw === undefined || raw.trim() === "") return {};
|
|
35
35
|
const v: unknown = JSON.parse(raw);
|
|
36
36
|
if (typeof v !== "object" || v === null || Array.isArray(v)) throw new Error(`${COMMENT_JOBS_ENV} is a JSON object of the jobs the pipeline has`);
|
|
37
|
-
const known = new Set(["preview", "applyBeforeMerge", "applyOnMerge", "locks", "agent", "commits", "actions", "skipForks", "targets", "noPlanFlags", "waves", "wavesBeforeMerge"]);
|
|
37
|
+
const known = new Set(["preview", "applyBeforeMerge", "applyOnMerge", "locks", "agent", "commits", "actions", "skipForks", "targets", "noPlanFlags", "waves", "wavesBeforeMerge", "applyJobs"]);
|
|
38
38
|
const jobs: Record<string, unknown> = {};
|
|
39
39
|
for (const [k, x] of Object.entries(v)) {
|
|
40
40
|
if (!known.has(k)) throw new Error(`${COMMENT_JOBS_ENV} names ${JSON.stringify(k)}, which is not one of ${[...known].join(", ")}`);
|
|
@@ -55,6 +55,12 @@ export function commentJobsFromEnv(raw: string | undefined): CommentJobs {
|
|
|
55
55
|
if (x.length > 0) jobs.targets = x;
|
|
56
56
|
continue;
|
|
57
57
|
}
|
|
58
|
+
// #5027: the waves' apply jobs by the product's names, which a re-run looks for.
|
|
59
|
+
if (k === "applyJobs") {
|
|
60
|
+
if (!Array.isArray(x) || x.some((t) => typeof t !== "string" || !/^[A-Za-z0-9_][A-Za-z0-9_.-]*$/.test(t))) throw new Error(`${COMMENT_JOBS_ENV}.applyJobs is a list of job names`);
|
|
61
|
+
if (x.length > 0) jobs.applyJobs = x;
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
58
64
|
if (typeof x !== "boolean") throw new Error(`${COMMENT_JOBS_ENV}.${k} is true or false`);
|
|
59
65
|
if (x) jobs[k] = true;
|
|
60
66
|
}
|
|
@@ -66,15 +72,19 @@ export function commentJobsFromEnv(raw: string | undefined): CommentJobs {
|
|
|
66
72
|
export function wavesBeforeMergeOf(x: unknown): WavesBeforeMergeJobs {
|
|
67
73
|
const what = `${COMMENT_JOBS_ENV}.wavesBeforeMerge`;
|
|
68
74
|
const o = x as Partial<WavesBeforeMergeJobs> | null;
|
|
69
|
-
if (!o || typeof o !== "object" || Array.isArray(o)) throw new Error(`${what} is { workflow?, requires?, plan, pipelineFiles, locks? }`);
|
|
75
|
+
if (!o || typeof o !== "object" || Array.isArray(o)) throw new Error(`${what} is { workflow?, inputs?, requires?, plan, pipelineFiles, locks? }`);
|
|
70
76
|
const strings = (v: unknown): v is string[] => Array.isArray(v) && v.every((s) => typeof s === "string" && s.trim() !== "" && !/[\r\n]/.test(s));
|
|
71
77
|
if (o.workflow !== undefined && (typeof o.workflow !== "string" || !/^[A-Za-z0-9][A-Za-z0-9._-]*\.ya?ml$/.test(o.workflow))) throw new Error(`${what}.workflow is a workflow file name, like deploy.yml`);
|
|
72
78
|
if (o.requires !== undefined && (!Array.isArray(o.requires) || o.requires.some((r) => !(PR_APPLY_REQUIRES as readonly string[]).includes(r)))) throw new Error(`${what}.requires is a list of ${PR_APPLY_REQUIRES.join(", ")}`);
|
|
73
79
|
if (!strings(o.plan)) throw new Error(`${what}.plan is the list of plan statuses that must pass on the head`);
|
|
74
80
|
if (!strings(o.pipelineFiles)) throw new Error(`${what}.pipelineFiles is the list of paths a change may not touch`);
|
|
75
81
|
if (o.locks !== undefined && (typeof o.locks !== "object" || o.locks === null || (o.locks.gate !== undefined && (typeof o.locks.gate !== "string" || !/^[A-Za-z0-9][A-Za-z0-9_.-]{0,127}$/.test(o.locks.gate))))) throw new Error(`${what}.locks is { gate? }`);
|
|
82
|
+
// #5022: the waves workflow's input names, the product's.
|
|
83
|
+
const inputs = o.inputs;
|
|
84
|
+
if (inputs !== undefined && (typeof inputs !== "object" || inputs === null || Object.entries(inputs).some(([k, n]) => !["pr", "head", "digest"].includes(k) || typeof n !== "string" || !/^[A-Za-z_][A-Za-z0-9_-]*$/.test(n)))) throw new Error(`${what}.inputs names the inputs pr, head and digest`);
|
|
76
85
|
return {
|
|
77
86
|
...(o.workflow ? { workflow: o.workflow } : {}),
|
|
87
|
+
...(inputs ? { inputs: { ...inputs } } : {}),
|
|
78
88
|
...(o.requires ? { requires: [...o.requires] } : {}),
|
|
79
89
|
plan: [...o.plan],
|
|
80
90
|
pipelineFiles: [...o.pipelineFiles],
|
package/src/cli/handlers/pr.ts
CHANGED
|
@@ -120,7 +120,7 @@ import {
|
|
|
120
120
|
import { prStatusDescription, prStatusState } from "../../pr-status";
|
|
121
121
|
import { FORGE_KINDS, forgeFromEnv, forgePrincipalOf, type ForgeKind, type PrForge } from "../../pr-forge";
|
|
122
122
|
// #4964: a status for a pull_request run's merge preview goes on the pull request's head.
|
|
123
|
-
import { forgeFromJobEnv } from "../../pr-forge-job";
|
|
123
|
+
import { forgeFromJobEnv, plannedForHead } from "../../pr-forge-job";
|
|
124
124
|
import { GITHUB_COMMENT_LIMIT, GITLAB_NOTE_LIMIT } from "../../plan-summary";
|
|
125
125
|
import { upsertPlanNote } from "../../pr-post";
|
|
126
126
|
import { activeProductWords, commandWord, parseProductComment, productContext } from "../../ci-product-words";
|
|
@@ -2849,11 +2849,14 @@ export async function runComponentsPrPost(ctx: CommandContext): Promise<number>
|
|
|
2849
2849
|
const context = args.statusContexts?.[0];
|
|
2850
2850
|
const description = await descriptionCheckOf(ctx, forge);
|
|
2851
2851
|
if (typeof description === "number") return description;
|
|
2852
|
+
// #5020: --head is the pull request's head; a GitHub plan job checked out the run's merge preview, whose report is the head's.
|
|
2853
|
+
const planned = args.forge === "gitlab" ? undefined : plannedForHead(args.head);
|
|
2852
2854
|
const posted = await postPlanReport({
|
|
2853
2855
|
forge,
|
|
2854
2856
|
dir: resolve(args.output ?? PR_REPORT_DIR),
|
|
2855
2857
|
pr: args.pr,
|
|
2856
2858
|
head: args.head,
|
|
2859
|
+
...(planned ? { planned } : {}),
|
|
2857
2860
|
env: args.env,
|
|
2858
2861
|
...(member ? { member } : {}),
|
|
2859
2862
|
...(context ? { context } : {}),
|
|
@@ -983,9 +983,11 @@ export const PR_PLAN_NOTE_JOB = "plan-note";
|
|
|
983
983
|
* and Forgejo it runs in a fresh job after the plan, at the target branch's
|
|
984
984
|
* commit, and posts the note and the `chant/plan` status from the report
|
|
985
985
|
* the plan job handed on, with the forge token the plan job never held.
|
|
986
|
-
* `HEAD_SHA` is the
|
|
986
|
+
* `HEAD_SHA` is the pull request's head (#5020), `PR_NUMBER` the pull
|
|
987
987
|
* request, and `PLAN_RESULT` the plan job's result, which fails the status
|
|
988
|
-
* when the plan job failed.
|
|
988
|
+
* when the plan job failed. A GitHub plan job checks out the merge preview
|
|
989
|
+
* (`github.sha`), and `pr-post` takes a report for it as the head's
|
|
990
|
+
* (`pullRequestHeads` in ../pr-forge-job.ts).
|
|
989
991
|
*
|
|
990
992
|
* On GitLab (#4328) it runs `pr-post --open` in a pipeline of the target
|
|
991
993
|
* branch, which GitLab builds from that branch's files and gives the
|
|
@@ -1026,7 +1028,8 @@ function prLoopPostJobBase(forge: ForgeKind, env: string, member: string | undef
|
|
|
1026
1028
|
command: withProductBin(command, words?.bin),
|
|
1027
1029
|
env: {
|
|
1028
1030
|
PR_NUMBER: "${{ github.event.pull_request.number }}",
|
|
1029
|
-
|
|
1031
|
+
// #5020: the head, where the forge shows and requires the status; GitHub's github.sha is the merge preview.
|
|
1032
|
+
HEAD_SHA: "${{ github.event.pull_request.head.sha }}",
|
|
1030
1033
|
PLAN_RESULT: "${{ needs.plan.result }}",
|
|
1031
1034
|
...(opts.staleNotes ? { TIP_SHA: "${{ github.event.pull_request.base.sha }}" } : {}),
|
|
1032
1035
|
GITHUB_TOKEN: GITHUB_JOB_TOKEN,
|
|
@@ -1328,7 +1331,7 @@ export function prEnvJobs(forge: ForgeKind, options: PrLoopPipelineOptions = {},
|
|
|
1328
1331
|
jobName: PR_ENV_POST_JOB,
|
|
1329
1332
|
command: ["chant", "components", "pr-env", "post", "--pr", '"$PR_NUMBER"', "--head", '"$HEAD_SHA"', ...common, ...(github ? ["--result", '"$UP_RESULT"'] : [])].join(" "),
|
|
1330
1333
|
env: github
|
|
1331
|
-
? { PR_NUMBER: prNumber, HEAD_SHA: "${{ github.sha }}", UP_RESULT: "${{ needs.env-up.result }}", ...token }
|
|
1334
|
+
? { PR_NUMBER: prNumber, HEAD_SHA: "${{ github.event.pull_request.head.sha }}", UP_RESULT: "${{ needs.env-up.result }}", ...token }
|
|
1332
1335
|
: { PR_NUMBER: prNumber, HEAD_SHA: "$CI_COMMIT_SHA", BASE_SHA: "$CI_MERGE_REQUEST_DIFF_BASE_SHA" },
|
|
1333
1336
|
},
|
|
1334
1337
|
{
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* #5027: the product pipeline names its comment job and its waves' jobs as
|
|
3
|
+
* the product does. The comment job takes `commentJob.jobName` (terragucci's
|
|
4
|
+
* `apply-comment`), and a merged pull request's re-run looks for the waves'
|
|
5
|
+
* jobs under the same `jobNames` the Op waves generator renders (#5022), so
|
|
6
|
+
* terragucci's `apply-wave-<k>`, its shares, its group jobs and `apply-rest`
|
|
7
|
+
* run again. Without them the job is `comment` and the re-run's pattern is
|
|
8
|
+
* `RERUN_APPLY_JOBS`, as before.
|
|
9
|
+
*/
|
|
10
|
+
import { describe, expect, test } from "vitest";
|
|
11
|
+
import type { OpWavesSpec } from "../op/op-waves";
|
|
12
|
+
import type { OpWavesJobRef } from "../op/op-waves-names";
|
|
13
|
+
import { answerProductComment, RERUN_APPLY_JOBS, rerunApplyJobs, type AnswerCommentOptions, type CommentJobs } from "../ci-comment-commands";
|
|
14
|
+
import { assertProductWords } from "../ci-product-words";
|
|
15
|
+
import { commentJobsFromEnv } from "../cli/handlers/pr-comment";
|
|
16
|
+
import type { ForgeReads, PullRequestDetail, RunJob, WorkflowRun } from "../pr-forge-reads";
|
|
17
|
+
import { PR_COMMENT_JOB } from "../ci-comment-commands";
|
|
18
|
+
import { productPipelineJobs } from "./product-pipeline";
|
|
19
|
+
|
|
20
|
+
const words = { product: "terragucci", noun: ["root", "roots"] as [string, string], commands: { plan: "plan" as const, apply: "apply" as const }, approval: "per-wave" as const, op: "tf-apply", bin: "terragucci" };
|
|
21
|
+
|
|
22
|
+
/** The waves of PR 5026's names goldens: a canary, a wide wave with shares, a wave of job groups (one with shares) and a rest wave. */
|
|
23
|
+
const waves = {
|
|
24
|
+
name: "tf-apply",
|
|
25
|
+
op: "tf-apply",
|
|
26
|
+
planWave: ["terragucci", "plan-wave", "{runs}", "{plans}"],
|
|
27
|
+
apply: ["terragucci", "apply", "{target}", "--plan", "{plan}"],
|
|
28
|
+
waves: [
|
|
29
|
+
{ name: "canary", runs: [], discover: true },
|
|
30
|
+
{ name: "wide", runs: [], discover: true, shares: 2 },
|
|
31
|
+
{ name: "regions", runs: [], discover: true, jobs: [{ name: "east", runs: ["east/*"] }, { name: "west", runs: ["west/*"], shares: 2 }] },
|
|
32
|
+
{ name: "rest", runs: [], discover: true, rest: true },
|
|
33
|
+
],
|
|
34
|
+
} as unknown as OpWavesSpec;
|
|
35
|
+
|
|
36
|
+
/** terragucci's names, as PR 5026's names goldens give them. */
|
|
37
|
+
const terragucciJob = (j: OpWavesJobRef): string | undefined => {
|
|
38
|
+
const w = j.rest ? "apply-rest" : `apply-wave-${j.wave}`;
|
|
39
|
+
const part = `${j.group !== undefined ? `-${j.group}` : ""}${j.share !== undefined ? `-share-${j.share}` : ""}`;
|
|
40
|
+
switch (j.role) {
|
|
41
|
+
case "wave":
|
|
42
|
+
case "decide":
|
|
43
|
+
return w;
|
|
44
|
+
case "share":
|
|
45
|
+
case "group":
|
|
46
|
+
case "apply":
|
|
47
|
+
return `${w}${part}`;
|
|
48
|
+
case "plan":
|
|
49
|
+
case "gate":
|
|
50
|
+
case "record":
|
|
51
|
+
return `${w}-${j.role}`;
|
|
52
|
+
case "apply-status":
|
|
53
|
+
return j.wave === waves.waves.length ? "apply-done" : `${w}-status`;
|
|
54
|
+
case "before-merge-done":
|
|
55
|
+
return "pr-merge";
|
|
56
|
+
case "control":
|
|
57
|
+
return "control";
|
|
58
|
+
default:
|
|
59
|
+
return undefined;
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const PUSH_JOBS = ["apply-wave-1", "apply-wave-2", "apply-wave-2-share-1", "apply-wave-2-share-2", "apply-wave-3", "apply-wave-3-east", "apply-wave-3-west-share-1", "apply-wave-3-west-share-2", "apply-rest"];
|
|
64
|
+
const productPlan = { command: "terragucci plan --out {output}", replan: true };
|
|
65
|
+
const env = (jobs: { comment?: { env: Record<string, string> } }): CommentJobs => JSON.parse(jobs.comment!.env.CHANT_COMMENT_JOBS!);
|
|
66
|
+
|
|
67
|
+
describe("the comment job's name (#5027)", () => {
|
|
68
|
+
test("is the product's, and comment by default", () => {
|
|
69
|
+
const named = productPipelineJobs("github", "default", { words, waves, productPlan, commentJob: { jobName: "apply-comment" } });
|
|
70
|
+
expect(named.comment!.jobName).toBe("apply-comment");
|
|
71
|
+
for (const commentJob of [true, {}] as const) expect(productPipelineJobs("github", "default", { words, waves, productPlan, commentJob }).comment!.jobName).toBe(PR_COMMENT_JOB);
|
|
72
|
+
expect(PR_COMMENT_JOB).toBe("comment");
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
test("a name the forge cannot take is refused", () => {
|
|
76
|
+
expect(() => productPipelineJobs("github", "default", { words, waves, productPlan, commentJob: { jobName: "apply comment" } })).toThrow(/commentJob\.jobName "apply comment" is not a job name/);
|
|
77
|
+
expect(() => productPipelineJobs("forgejo", "default", { words, waves, productPlan, commentJob: { jobName: "1st" } })).toThrow(/not a job name/);
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
describe("the re-run's jobs follow the waves' names (#5027)", () => {
|
|
82
|
+
test("by default the comment job carries no list and the re-run keeps RERUN_APPLY_JOBS", () => {
|
|
83
|
+
const jobs = productPipelineJobs("github", "default", { words, waves, productPlan, commentJob: true });
|
|
84
|
+
expect(env(jobs).applyJobs).toBeUndefined();
|
|
85
|
+
expect(jobs.comment!.jobs.applyJobs).toBeUndefined();
|
|
86
|
+
expect(jobs.waves!.pipeline.jobNames).toBeUndefined();
|
|
87
|
+
expect(jobs.waves!.jobs.map((j) => j.jobName)).toEqual(["wave-1-canary", "wave-2-wide-decide", "wave-2-wide-share-1", "wave-2-wide-share-2", "wave-3-regions-decide", "wave-3-regions-east", "wave-3-regions-west-share-1", "wave-3-regions-west-share-2", "wave-4-rest"]);
|
|
88
|
+
expect(rerunApplyJobs({})).toBe(RERUN_APPLY_JOBS);
|
|
89
|
+
expect(rerunApplyJobs({ applyJobs: [] })).toBe(RERUN_APPLY_JOBS);
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
test("with terragucci's names the comment job looks for apply-wave-<k>, its shares, its groups and apply-rest", () => {
|
|
93
|
+
const jobs = productPipelineJobs("github", "default", { words, waves, productPlan, commentJob: { jobName: "apply-comment" }, wavesJobNames: terragucciJob });
|
|
94
|
+
expect(env(jobs).applyJobs).toEqual(PUSH_JOBS);
|
|
95
|
+
expect(jobs.waves!.jobs.map((j) => j.jobName)).toEqual(PUSH_JOBS);
|
|
96
|
+
expect(jobs.waves!.jobs.find((j) => j.jobName === "apply-wave-2-share-1")!.needs).toEqual(["apply-wave-2"]);
|
|
97
|
+
// The generator is handed the same names, so the jobs it renders are the ones the re-run looks for.
|
|
98
|
+
expect(jobs.waves!.pipeline.jobNames).toBe(terragucciJob);
|
|
99
|
+
const pattern = rerunApplyJobs(env(jobs));
|
|
100
|
+
for (const name of PUSH_JOBS) expect(pattern.test(name), name).toBe(true);
|
|
101
|
+
for (const name of ["apply-comment", "apply-wave-1-evidence", "apply-wave-1-status", "apply-done", "stale-notes", "control", "apply-wave-10", "xapply-rest", "wave-1-canary"]) expect(pattern.test(name), name).toBe(false);
|
|
102
|
+
// chant's pattern skips the group jobs and the rest wave, which is what #5027 is about.
|
|
103
|
+
expect(["apply-wave-3-east", "apply-wave-3-west-share-1", "apply-rest"].filter((n) => RERUN_APPLY_JOBS.test(n))).toEqual([]);
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
test("before merge the split jobs are looked for too, by the same names", () => {
|
|
107
|
+
const jobs = productPipelineJobs("github", "default", { words, waves, productPlan, commentJob: { jobName: "apply-comment" }, wavesJobNames: terragucciJob, wavesBeforeMerge: { workflowFile: "terragucci.yml", dispatchInputs: { pr: "apply_pr", head: "apply_head", digest: "apply_digest" } } });
|
|
108
|
+
const names = env(jobs).applyJobs!;
|
|
109
|
+
for (const name of [...PUSH_JOBS, "apply-wave-1-plan", "apply-wave-1-gate", "apply-wave-1-record", "apply-wave-2-share-2", "apply-wave-3-west-share-1", "apply-rest-plan", "apply-rest-record"]) expect(names, name).toContain(name);
|
|
110
|
+
expect(new Set(names).size).toBe(names.length);
|
|
111
|
+
expect(jobs.waves!.pipeline).toMatchObject({ workflowFile: "terragucci.yml", jobNames: terragucciJob });
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
test("is refused without waves, and the generator's checks hold", () => {
|
|
115
|
+
expect(() => productPipelineJobs("github", "default", { words, productPlan, commentJob: true, wavesJobNames: terragucciJob })).toThrow(/wavesJobNames names the waves' jobs, and there are none/);
|
|
116
|
+
expect(() => productPipelineJobs("github", "default", { words, waves, productPlan, commentJob: true, wavesJobNames: () => "apply" })).toThrow(/names two jobs apply/);
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
test("the job reads the list from CHANT_COMMENT_JOBS, and refuses one that is not job names", () => {
|
|
120
|
+
expect(commentJobsFromEnv(JSON.stringify({ applyOnMerge: true, applyJobs: PUSH_JOBS })).applyJobs).toEqual(PUSH_JOBS);
|
|
121
|
+
expect(commentJobsFromEnv(JSON.stringify({ applyJobs: [] })).applyJobs).toBeUndefined();
|
|
122
|
+
expect(() => commentJobsFromEnv(JSON.stringify({ applyJobs: ["apply-rest", "a b"] }))).toThrow(/applyJobs is a list of job names/);
|
|
123
|
+
expect(() => commentJobsFromEnv(JSON.stringify({ applyJobs: "apply-rest" }))).toThrow(/applyJobs is a list of job names/);
|
|
124
|
+
});
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
describe("a merged pull request's apply runs terragucci's jobs again (#5027)", () => {
|
|
128
|
+
const MERGE = "a".repeat(40);
|
|
129
|
+
const run: WorkflowRun = { id: 10, event: "push", headSha: MERGE, status: "completed", conclusion: "failure", done: true, pullRequests: [], workflow: "terragucci.yml", url: "https://github.com/acme/infra/actions/runs/10" };
|
|
130
|
+
const job = (id: number, name: string, conclusion: string): RunJob => ({ id, name, status: "completed", conclusion, done: true }) as RunJob;
|
|
131
|
+
|
|
132
|
+
const answer = async (jobs: CommentJobs, runJobs: RunJob[], forge: "github" | "forgejo" = "github") => {
|
|
133
|
+
const posted: string[] = [];
|
|
134
|
+
const reran: number[] = [];
|
|
135
|
+
const dispatched: string[] = [];
|
|
136
|
+
const reads = {
|
|
137
|
+
kind: forge,
|
|
138
|
+
permission: async () => "write",
|
|
139
|
+
pullRequest: async (n: number) => ({ number: n, title: "", body: "", state: "merged", head: "feature", headSha: "c".repeat(40), base: "main", sameRepo: true, mergeCommit: MERGE }) as PullRequestDetail,
|
|
140
|
+
headRuns: async () => [run],
|
|
141
|
+
runJobs: async () => runJobs,
|
|
142
|
+
branchRuns: async () => [run],
|
|
143
|
+
} as unknown as ForgeReads;
|
|
144
|
+
const opts: AnswerCommentOptions = {
|
|
145
|
+
forge,
|
|
146
|
+
event: { action: "created", comment: { id: 7, body: "/terragucci apply", user: { login: "alice" } }, issue: { number: 12, pull_request: {} }, repository: { full_name: "acme/infra", permissions: { push: true } }, sender: { login: "alice" } },
|
|
147
|
+
repo: "acme/infra",
|
|
148
|
+
reads,
|
|
149
|
+
poster: { addComment: async (_n: number, text: string) => (posted.push(text), { id: 1 } as never), commitStatuses: async () => [] as never },
|
|
150
|
+
runs: { rerunFailed: async (id) => (reran.push(id), {}), dispatch: async (wf) => (dispatched.push(wf), {}) },
|
|
151
|
+
words: assertProductWords(words),
|
|
152
|
+
base: "main",
|
|
153
|
+
jobs,
|
|
154
|
+
};
|
|
155
|
+
const got = await answerProductComment(opts);
|
|
156
|
+
return { got, posted, reran, dispatched };
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
test("a run whose only failure is apply-rest is started again, where chant's pattern would see the earlier waves' successes alone", async () => {
|
|
160
|
+
const jobs = productPipelineJobs("github", "default", { words, waves, productPlan, commentJob: { jobName: "apply-comment" }, wavesJobNames: terragucciJob });
|
|
161
|
+
const runJobs = [...PUSH_JOBS.slice(0, -1).map((n, i) => job(i + 1, n, "success")), job(99, "apply-rest", "failure"), job(100, "apply-comment", "failure")];
|
|
162
|
+
const named = await answer(commentJobsFromEnv(jobs.comment!.env.CHANT_COMMENT_JOBS), runJobs);
|
|
163
|
+
expect(named.reran).toEqual([10]);
|
|
164
|
+
expect(named.got.ran).toBe(true);
|
|
165
|
+
const chant = await answer({ applyOnMerge: true }, runJobs);
|
|
166
|
+
expect(chant.reran).toEqual([]);
|
|
167
|
+
expect(chant.posted[0]).toMatch(/already succeeded/);
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
test("on Forgejo a failed group job dispatches the workflow again", async () => {
|
|
171
|
+
const jobs = productPipelineJobs("forgejo", "default", { words, waves, productPlan, commentJob: { jobName: "apply-comment" }, wavesJobNames: terragucciJob });
|
|
172
|
+
const runJobs = [job(1, "apply-wave-1", "success"), job(2, "apply-wave-3-east", "failure")];
|
|
173
|
+
const got = await answer(commentJobsFromEnv(jobs.comment!.env.CHANT_COMMENT_JOBS), runJobs, "forgejo");
|
|
174
|
+
expect(got.dispatched).toEqual(["terragucci.yml"]);
|
|
175
|
+
});
|
|
176
|
+
});
|