@intentius/chant 0.124.89 → 0.124.91
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/actor.d.ts +5 -3
- package/dist/actor.d.ts.map +1 -1
- package/dist/actor.js +7 -5
- package/dist/audit/core.d.ts.map +1 -1
- package/dist/audit/core.js +11 -1
- package/dist/ci-comment-commands.d.ts +18 -2
- package/dist/ci-comment-commands.d.ts.map +1 -1
- package/dist/ci-comment-commands.js +30 -2
- package/dist/ci-job-guard.d.ts +42 -45
- package/dist/ci-job-guard.d.ts.map +1 -1
- package/dist/ci-job-guard.js +206 -3
- package/dist/ci-note-commands.d.ts +41 -1
- package/dist/ci-note-commands.d.ts.map +1 -1
- package/dist/ci-note-commands.js +64 -5
- package/dist/ci-product.d.ts +50 -1
- package/dist/ci-product.d.ts.map +1 -1
- package/dist/ci-product.js +52 -6
- package/dist/cli/handlers/pr-comment.d.ts +13 -1
- package/dist/cli/handlers/pr-comment.d.ts.map +1 -1
- package/dist/cli/handlers/pr-comment.js +90 -1
- package/dist/cli/handlers/pr-notes.d.ts.map +1 -1
- package/dist/cli/handlers/pr-notes.js +23 -1
- package/dist/cli/handlers/pr.d.ts +2 -2
- package/dist/cli/handlers/pr.d.ts.map +1 -1
- package/dist/cli/handlers/pr.js +41 -20
- package/dist/cli/handlers/run-wave.d.ts.map +1 -1
- package/dist/cli/handlers/run-wave.js +154 -4
- package/dist/cli/main.d.ts.map +1 -1
- package/dist/cli/main.js +17 -0
- package/dist/cli/parse-args.d.ts.map +1 -1
- package/dist/cli/parse-args.js +28 -0
- package/dist/cli/registry.d.ts +12 -1
- package/dist/cli/registry.d.ts.map +1 -1
- package/dist/components/pr-checks.d.ts +39 -1
- package/dist/components/pr-checks.d.ts.map +1 -1
- package/dist/components/pr-checks.js +45 -2
- package/dist/components/pr-pipeline.d.ts +11 -3
- package/dist/components/pr-pipeline.d.ts.map +1 -1
- package/dist/components/pr-pipeline.js +20 -7
- package/dist/components/product-pipeline.d.ts +54 -2
- package/dist/components/product-pipeline.d.ts.map +1 -1
- package/dist/components/product-pipeline.js +63 -6
- package/dist/components/product-plan.d.ts +92 -2
- package/dist/components/product-plan.d.ts.map +1 -1
- package/dist/components/product-plan.js +172 -22
- package/dist/floor-table.data.d.ts.map +1 -1
- package/dist/floor-table.data.js +37 -23
- package/dist/lexicon-module.d.ts +2 -0
- package/dist/lexicon-module.d.ts.map +1 -1
- package/dist/lexicon-module.js +6 -2
- package/dist/lexicon.d.ts +82 -4
- package/dist/lexicon.d.ts.map +1 -1
- package/dist/lifecycle/gate-applied.d.ts +9 -0
- package/dist/lifecycle/gate-applied.d.ts.map +1 -1
- package/dist/op/apply-status.d.ts +84 -0
- package/dist/op/apply-status.d.ts.map +1 -0
- package/dist/op/apply-status.js +106 -0
- package/dist/op/before-merge-decide.d.ts +102 -0
- package/dist/op/before-merge-decide.d.ts.map +1 -0
- package/dist/op/before-merge-decide.js +142 -0
- package/dist/op/before-merge-done.d.ts +56 -0
- package/dist/op/before-merge-done.d.ts.map +1 -0
- package/dist/op/before-merge-done.js +69 -0
- package/dist/op/before-merge-store.d.ts +20 -0
- package/dist/op/before-merge-store.d.ts.map +1 -0
- package/dist/op/before-merge-store.js +48 -0
- package/dist/op/before-merge.d.ts +150 -0
- package/dist/op/before-merge.d.ts.map +1 -0
- package/dist/op/before-merge.js +207 -0
- package/dist/op/follow-on-run.d.ts +117 -0
- package/dist/op/follow-on-run.d.ts.map +1 -0
- package/dist/op/follow-on-run.js +154 -0
- package/dist/op/follow-on-store.d.ts +17 -0
- package/dist/op/follow-on-store.d.ts.map +1 -0
- package/dist/op/follow-on-store.js +54 -0
- package/dist/op/gate.d.ts +6 -0
- package/dist/op/gate.d.ts.map +1 -1
- package/dist/op/gate.js +10 -1
- package/dist/op/index.d.ts +3 -1
- package/dist/op/index.d.ts.map +1 -1
- package/dist/op/index.js +1 -0
- package/dist/op/op-waves-after-plan.d.ts +13 -0
- package/dist/op/op-waves-after-plan.d.ts.map +1 -1
- package/dist/op/op-waves-evidence-jobs.d.ts +4 -1
- package/dist/op/op-waves-evidence-jobs.d.ts.map +1 -1
- package/dist/op/op-waves-evidence-jobs.js +10 -2
- package/dist/op/op-waves-follow-on.d.ts +162 -0
- package/dist/op/op-waves-follow-on.d.ts.map +1 -0
- package/dist/op/op-waves-follow-on.js +355 -0
- package/dist/op/op-waves-run.d.ts +146 -6
- package/dist/op/op-waves-run.d.ts.map +1 -1
- package/dist/op/op-waves-run.js +871 -99
- package/dist/op/op-waves-split.d.ts +122 -0
- package/dist/op/op-waves-split.d.ts.map +1 -0
- package/dist/op/op-waves-split.js +166 -0
- package/dist/op/op-waves.d.ts +20 -0
- package/dist/op/op-waves.d.ts.map +1 -1
- package/dist/op/op-waves.js +15 -1
- package/dist/op/schedule-overdue.d.ts +15 -1
- package/dist/op/schedule-overdue.d.ts.map +1 -1
- package/dist/op/schedule-overdue.js +18 -2
- package/dist/op/stage-hooks.d.ts +36 -1
- package/dist/op/stage-hooks.d.ts.map +1 -1
- package/dist/op/stage-hooks.js +17 -3
- package/dist/op/wave-stop.d.ts +4 -1
- package/dist/op/wave-stop.d.ts.map +1 -1
- package/dist/op/wave-stop.js +4 -2
- package/dist/planned-files.d.ts +16 -8
- package/dist/planned-files.d.ts.map +1 -1
- package/dist/planned-files.js +12 -8
- package/dist/pr-post.d.ts +6 -0
- package/dist/pr-post.d.ts.map +1 -1
- package/dist/pr-post.js +7 -5
- package/dist/release-floors.d.ts +9 -1
- package/dist/release-floors.d.ts.map +1 -1
- package/dist/release-floors.js +27 -19
- package/dist/wave-blocked.d.ts +7 -1
- package/dist/wave-blocked.d.ts.map +1 -1
- package/dist/wave-blocked.js +7 -2
- package/dist/wave-runtime.mjs +364 -351
- package/package.json +1 -1
- package/src/actor.test.ts +14 -1
- package/src/actor.ts +8 -6
- package/src/audit/core.ts +13 -1
- package/src/audit/first-load.test.ts +101 -0
- package/src/ci-comment-commands.test.ts +63 -0
- package/src/ci-comment-commands.ts +43 -4
- package/src/ci-image.test.ts +1 -2
- package/src/ci-job-guard.before-merge.test.ts +148 -0
- package/src/ci-job-guard.follow-on-record.test.ts +137 -0
- package/src/ci-job-guard.follow-on.test.ts +144 -0
- package/src/ci-job-guard.ts +221 -3
- package/src/ci-note-commands.test.ts +76 -1
- package/src/ci-note-commands.ts +96 -7
- package/src/ci-product.ts +65 -6
- package/src/cli/handlers/pr-comment.ts +85 -2
- package/src/cli/handlers/pr-notes.ts +30 -6
- package/src/cli/handlers/pr.ts +34 -17
- package/src/cli/handlers/run-wave.ts +144 -4
- package/src/cli/main.ts +17 -0
- package/src/cli/parse-args.ts +20 -0
- package/src/cli/registry.ts +12 -1
- package/src/components/pr-checks.ts +66 -2
- package/src/components/pr-pipeline.ts +21 -9
- package/src/components/product-pipeline.apply-status.test.ts +50 -0
- package/src/components/product-pipeline.ts +117 -9
- package/src/components/product-plan-names.test.ts +135 -0
- package/src/components/product-plan.test.ts +23 -5
- package/src/components/product-plan.ts +248 -25
- package/src/floor-table.data.ts +37 -23
- package/src/lexicon-module.ts +6 -2
- package/src/lexicon.ts +78 -1
- package/src/lifecycle/gate-applied.ts +7 -0
- package/src/op/apply-status.test.ts +83 -0
- package/src/op/apply-status.ts +132 -0
- package/src/op/before-merge-decide.ts +190 -0
- package/src/op/before-merge-done.ts +99 -0
- package/src/op/before-merge-store.ts +44 -0
- package/src/op/before-merge.test.ts +201 -0
- package/src/op/before-merge.ts +266 -0
- package/src/op/follow-on-run.ts +206 -0
- package/src/op/follow-on-store.ts +54 -0
- package/src/op/gate.ts +16 -1
- package/src/op/index.ts +5 -0
- package/src/op/op-waves-after-plan.ts +13 -0
- package/src/op/op-waves-evidence-jobs.ts +11 -3
- package/src/op/op-waves-follow-on-record.test.ts +152 -0
- package/src/op/op-waves-follow-on.test.ts +247 -0
- package/src/op/op-waves-follow-on.ts +385 -0
- package/src/op/op-waves-render-spec.test.ts +1 -2
- package/src/op/op-waves-run.ts +971 -93
- package/src/op/op-waves-split-product.test.ts +288 -0
- package/src/op/op-waves-split-step.test.ts +298 -0
- package/src/op/op-waves-split.test.ts +196 -0
- package/src/op/op-waves-split.ts +189 -0
- package/src/op/op-waves.ts +28 -3
- package/src/op/schedule-overdue.test.ts +29 -1
- package/src/op/schedule-overdue.ts +27 -3
- package/src/op/stage-hooks.ts +52 -4
- package/src/op/wave-stop.ts +5 -3
- package/src/planned-files.test.ts +33 -0
- package/src/planned-files.ts +26 -10
- package/src/pr-post.ts +13 -5
- package/src/release-floors.ts +31 -19
- package/src/wave-blocked.ts +9 -4
package/src/cli/handlers/pr.ts
CHANGED
|
@@ -2816,8 +2816,8 @@ function writeWaveChangeSet(ctx: CommandContext, wave: number, doc: PrPlanSet["d
|
|
|
2816
2816
|
}
|
|
2817
2817
|
|
|
2818
2818
|
/**
|
|
2819
|
-
* chant components pr-post --pr <n> --head <sha> --env <env> --forge <kind> [--member <name>] [--output <dir>] [--result <result>] [--not-affected <argument>] (#4295, #4963)
|
|
2820
|
-
* chant components pr-post --open --env <env> --forge gitlab [--branch <branch>] [--member <name>] [--output <dir>] (#4328)
|
|
2819
|
+
* chant components pr-post --pr <n> --head <sha> --env <env> --forge <kind> [--member <name>] [--output <dir>] [--result <result>] [--not-affected <argument>] [--context <context>] (#4295, #4963, #5003)
|
|
2820
|
+
* chant components pr-post --open --env <env> --forge gitlab [--branch <branch>] [--member <name>] [--output <dir>] [--context <context>] [--plan-job <name>] (#4328, #5003)
|
|
2821
2821
|
*
|
|
2822
2822
|
* Post the plan note and the `chant/plan` status from the report a plan job
|
|
2823
2823
|
* wrote with `pr-plan --no-status`, in a job that runs none of the change's
|
|
@@ -2835,6 +2835,8 @@ export async function runComponentsPrPost(ctx: CommandContext): Promise<number>
|
|
|
2835
2835
|
if (!args.env) return fail("pr-post needs the environment the plan was for: --env <env>");
|
|
2836
2836
|
if (!args.forge || !(FORGE_KINDS as readonly string[]).includes(args.forge)) return fail(`pr-post posts to a forge: --forge ${FORGE_KINDS.join("|")}`);
|
|
2837
2837
|
if (args.members && args.members.length > 1) return fail(`pr-post takes one --member, not ${args.members.join(", ")}`);
|
|
2838
|
+
if (args.statusContexts && args.statusContexts.length > 1) return fail(`pr-post takes one --context, not ${args.statusContexts.join(", ")}`);
|
|
2839
|
+
if (args.planJob) return fail("pr-post --plan-job names the GitLab plan job pr-post --open reads; a post for one pull request reads its report from --output");
|
|
2838
2840
|
let forge: PrForge;
|
|
2839
2841
|
try {
|
|
2840
2842
|
forge = forgeFromJobEnv(args.forge as ForgeKind);
|
|
@@ -2843,6 +2845,8 @@ export async function runComponentsPrPost(ctx: CommandContext): Promise<number>
|
|
|
2843
2845
|
}
|
|
2844
2846
|
const { postPlanReport } = await import("../../pr-post");
|
|
2845
2847
|
const member = args.members?.[0];
|
|
2848
|
+
// #5003: the product plan's own status context.
|
|
2849
|
+
const context = args.statusContexts?.[0];
|
|
2846
2850
|
const description = await descriptionCheckOf(ctx, forge);
|
|
2847
2851
|
if (typeof description === "number") return description;
|
|
2848
2852
|
const posted = await postPlanReport({
|
|
@@ -2852,6 +2856,7 @@ export async function runComponentsPrPost(ctx: CommandContext): Promise<number>
|
|
|
2852
2856
|
head: args.head,
|
|
2853
2857
|
env: args.env,
|
|
2854
2858
|
...(member ? { member } : {}),
|
|
2859
|
+
...(context ? { context } : {}),
|
|
2855
2860
|
...(args.planResult ? { result: args.planResult } : {}),
|
|
2856
2861
|
// #4289: the plan job could not ask the forge, so the note job does, from the Ops at the commit it checked out.
|
|
2857
2862
|
overdue: () => overdueOps(forge, member),
|
|
@@ -2866,7 +2871,7 @@ export async function runComponentsPrPost(ctx: CommandContext): Promise<number>
|
|
|
2866
2871
|
});
|
|
2867
2872
|
for (const message of posted.warnings) console.error(formatWarning({ message }));
|
|
2868
2873
|
if (posted.refused) console.error(formatWarning({ message: `the plan report was not used: ${posted.refused}` }));
|
|
2869
|
-
console.error(formatInfo(`pr-post: ${prStatusContext("plan", member)} ${posted.state}: ${posted.description}${posted.noted ? "; note posted" : ""}${posted.recorded ? `; run ${posted.recorded} recorded` : ""}`));
|
|
2874
|
+
console.error(formatInfo(`pr-post: ${context ?? prStatusContext("plan", member)} ${posted.state}: ${posted.description}${posted.noted ? "; note posted" : ""}${posted.recorded ? `; run ${posted.recorded} recorded` : ""}`));
|
|
2870
2875
|
return 0;
|
|
2871
2876
|
}
|
|
2872
2877
|
|
|
@@ -2935,7 +2940,8 @@ async function descriptionCheckOf(ctx: CommandContext, forge: PrForge): Promise<
|
|
|
2935
2940
|
* `--preview-comment`, and set its plan status back to pending
|
|
2936
2941
|
* (`markStaleNotes`, ../../pr-post.ts). The branch is `--branch`, else the
|
|
2937
2942
|
* job's (`GITHUB_REF_NAME`, `CI_COMMIT_BRANCH`). It exits 0 once it has
|
|
2938
|
-
* marked, as `pr-post` does.
|
|
2943
|
+
* marked, as `pr-post` does. `--member` given more than once (#4987, a
|
|
2944
|
+
* product plan's targets) marks each member's note in turn.
|
|
2939
2945
|
*/
|
|
2940
2946
|
async function runComponentsPrPostStale(ctx: CommandContext): Promise<number> {
|
|
2941
2947
|
const { args } = ctx;
|
|
@@ -2943,7 +2949,6 @@ async function runComponentsPrPostStale(ctx: CommandContext): Promise<number> {
|
|
|
2943
2949
|
if (!args.tip) return fail("pr-post --stale needs the target branch's commit now: --tip <sha>");
|
|
2944
2950
|
if (!args.env) return fail("pr-post needs the environment the plan was for: --env <env>");
|
|
2945
2951
|
if (!args.forge || !(FORGE_KINDS as readonly string[]).includes(args.forge)) return fail(`pr-post posts to a forge: --forge ${FORGE_KINDS.join("|")}`);
|
|
2946
|
-
if (args.members && args.members.length > 1) return fail(`pr-post takes one --member, not ${args.members.join(", ")}`);
|
|
2947
2952
|
const branch = args.branch ?? process.env.CI_COMMIT_BRANCH ?? process.env.GITHUB_REF_NAME;
|
|
2948
2953
|
if (!branch) return fail("pr-post --stale marks the notes of the pull requests into a branch: run it in a job of a push, or pass --branch <branch>");
|
|
2949
2954
|
let forge: PrForge;
|
|
@@ -2952,17 +2957,24 @@ async function runComponentsPrPostStale(ctx: CommandContext): Promise<number> {
|
|
|
2952
2957
|
} catch (err) {
|
|
2953
2958
|
return fail(err instanceof Error ? err.message : String(err));
|
|
2954
2959
|
}
|
|
2955
|
-
|
|
2960
|
+
// #4987: a product plan's targets each have their note, so --member may be given once per target.
|
|
2961
|
+
// #5003: a product plan's own status contexts, one a --member in the same order (one with none).
|
|
2962
|
+
const contexts = args.statusContexts;
|
|
2963
|
+
const members: Array<string | undefined> = args.members?.length ? (contexts ? [...args.members] : [...new Set(args.members)]) : [undefined];
|
|
2964
|
+
if (contexts && contexts.length !== members.length) return fail(`pr-post --stale takes one --context a --member (one with none), and got ${contexts.length} for ${members.length}`);
|
|
2965
|
+
if (args.planJob) return fail("pr-post --plan-job names the GitLab plan job pr-post --open reads; --stale reads no plan job");
|
|
2956
2966
|
const { markStaleNotes } = await import("../../pr-post");
|
|
2957
|
-
|
|
2958
|
-
|
|
2959
|
-
|
|
2960
|
-
|
|
2961
|
-
|
|
2967
|
+
for (const [i, member] of members.entries()) {
|
|
2968
|
+
let done: Awaited<ReturnType<typeof markStaleNotes>>;
|
|
2969
|
+
try {
|
|
2970
|
+
done = await markStaleNotes({ forge, branch, tip: args.tip, env: args.env, ...(member ? { member } : {}), ...(contexts ? { context: contexts[i]! } : {}), ...(args.previewComment ? { previewComment: true } : {}) });
|
|
2971
|
+
} catch (err) {
|
|
2972
|
+
return fail(err instanceof Error ? err.message : String(err));
|
|
2973
|
+
}
|
|
2974
|
+
for (const message of done.warnings) console.error(formatWarning({ message }));
|
|
2975
|
+
const marked = done.marks.filter((m) => m.marked).map((m) => `#${m.pr}`);
|
|
2976
|
+
console.error(formatInfo(`pr-post --stale${member ? ` (${member})` : ""}: ${marked.length > 0 ? `marked ${marked.join(", ")} stale` : "no note to mark"} after ${branch} moved to ${args.tip.slice(0, 12)}`));
|
|
2962
2977
|
}
|
|
2963
|
-
for (const message of done.warnings) console.error(formatWarning({ message }));
|
|
2964
|
-
const marked = done.marks.filter((m) => m.marked).map((m) => `#${m.pr}`);
|
|
2965
|
-
console.error(formatInfo(`pr-post --stale: ${marked.length > 0 ? `marked ${marked.join(", ")} stale` : "no note to mark"} after ${branch} moved to ${args.tip.slice(0, 12)}`));
|
|
2966
2978
|
return 0;
|
|
2967
2979
|
}
|
|
2968
2980
|
|
|
@@ -2995,20 +3007,25 @@ async function runComponentsPrPostOpen(ctx: CommandContext): Promise<number> {
|
|
|
2995
3007
|
const top = spawnSync("git", ["rev-parse", "--show-toplevel"], { encoding: "utf-8" });
|
|
2996
3008
|
if (top.status !== 0) return fail("pr-post --open reads the plan report's path from the repository root, and this directory is not in a git repository");
|
|
2997
3009
|
const member = args.members?.[0];
|
|
3010
|
+
if (args.statusContexts && args.statusContexts.length > 1) return fail(`pr-post --open takes one --context, not ${args.statusContexts.join(", ")}`);
|
|
3011
|
+
// #5003: the product plan's own status context and plan job.
|
|
3012
|
+
const context = args.statusContexts?.[0];
|
|
2998
3013
|
const description = await descriptionCheckOf(ctx, forge);
|
|
2999
3014
|
if (typeof description === "number") return description;
|
|
3000
3015
|
const artifactDir = relative(realpathSync(top.stdout.trim()), resolve(args.output ?? PR_REPORT_DIR)).split(sep).join("/");
|
|
3001
3016
|
const { postOpenPlanReports } = await import("../../pr-post");
|
|
3002
3017
|
const { gitlabPlanJobName } = await import("../../components/pr-pipeline");
|
|
3018
|
+
const planJob = args.planJob ?? gitlabPlanJobName(member);
|
|
3003
3019
|
let done: Awaited<ReturnType<typeof postOpenPlanReports>>;
|
|
3004
3020
|
try {
|
|
3005
3021
|
done = await postOpenPlanReports({
|
|
3006
3022
|
forge,
|
|
3007
3023
|
branch,
|
|
3008
|
-
job:
|
|
3024
|
+
job: planJob,
|
|
3009
3025
|
artifactDir,
|
|
3010
3026
|
env: args.env,
|
|
3011
3027
|
...(member ? { member } : {}),
|
|
3028
|
+
...(context ? { context } : {}),
|
|
3012
3029
|
// #4289: the Ops at the commit this pipeline checked out, the target branch's.
|
|
3013
3030
|
overdue: () => overdueOps(forge, member),
|
|
3014
3031
|
...(description ? { description } : {}),
|
|
@@ -3031,8 +3048,8 @@ async function runComponentsPrPostOpen(ctx: CommandContext): Promise<number> {
|
|
|
3031
3048
|
const posted = p.posted!;
|
|
3032
3049
|
for (const message of posted.warnings) console.error(formatWarning({ message: `!${p.pr}: ${message}` }));
|
|
3033
3050
|
if (posted.refused) console.error(formatWarning({ message: `!${p.pr}: the plan report was not used: ${posted.refused}` }));
|
|
3034
|
-
console.error(formatInfo(`pr-post: !${p.pr} ${prStatusContext("plan", member)} ${posted.state}: ${posted.description}${posted.noted ? "; note posted" : ""}${posted.recorded ? `; run ${posted.recorded} recorded` : ""}`));
|
|
3051
|
+
console.error(formatInfo(`pr-post: !${p.pr} ${context ?? prStatusContext("plan", member)} ${posted.state}: ${posted.description}${posted.noted ? "; note posted" : ""}${posted.recorded ? `; run ${posted.recorded} recorded` : ""}`));
|
|
3035
3052
|
}
|
|
3036
|
-
if (done.posts.length === 0) console.error(formatInfo(`pr-post: no open merge request into ${branch} has a ${
|
|
3053
|
+
if (done.posts.length === 0) console.error(formatInfo(`pr-post: no open merge request into ${branch} has a ${planJob} job`));
|
|
3037
3054
|
return 0;
|
|
3038
3055
|
}
|
|
@@ -14,6 +14,8 @@ import { formatError, formatWarning } from "../format";
|
|
|
14
14
|
import { ledgerRecordingOff, NO_RECORD_ENV, noRecordEndNote, noRecordStartNote, resetNoRecordLedger } from "../../lifecycle/no-record";
|
|
15
15
|
import type { CommandContext } from "../registry";
|
|
16
16
|
import { waveStopLine } from "../../op/wave-stop";
|
|
17
|
+
import { OP_WAVE_PHASES, type OpWavePhase } from "../../op/op-waves-split";
|
|
18
|
+
import { beforeMergeRunFromEnv } from "../../op/before-merge";
|
|
17
19
|
import { CHANT_EXIT } from "../../exit-codes";
|
|
18
20
|
|
|
19
21
|
/**
|
|
@@ -46,6 +48,10 @@ export async function runOpWaveCommand(ctx: CommandContext): Promise<number> {
|
|
|
46
48
|
|
|
47
49
|
async function runOpWaveJobCommand(ctx: CommandContext): Promise<number> {
|
|
48
50
|
const { args } = ctx;
|
|
51
|
+
// #4984: the job after a before-merge run's last wave merges the pull request, or says it is ready.
|
|
52
|
+
if (args.merge !== undefined) return runBeforeMergeDone(ctx);
|
|
53
|
+
// #4987: the job after a wave posts its apply status, at the default branch's commit.
|
|
54
|
+
if (args.applyStatus !== undefined) return runApplyStatus(ctx);
|
|
49
55
|
const specFile = args.opsSpec;
|
|
50
56
|
if (specFile && args.recordPlans) {
|
|
51
57
|
try {
|
|
@@ -67,7 +73,16 @@ async function runOpWaveJobCommand(ctx: CommandContext): Promise<number> {
|
|
|
67
73
|
const { opWaveOutcomeDir } = await import("../../op/op-waves");
|
|
68
74
|
const { earlierWaveOutcomes } = await import("../../wave-blocked");
|
|
69
75
|
const { applyOutcomeOf } = await import("../../control/applied");
|
|
70
|
-
|
|
76
|
+
// #4992: a run that started a follow-on is not the last; the follow-on's control job tells the control repo.
|
|
77
|
+
const { readOpWaveRestNote } = await import("../../op/op-waves-follow-on");
|
|
78
|
+
const note = readOpWaveRestNote([resolve(opWaveOutcomeDir(spec))]);
|
|
79
|
+
if (note?.next !== undefined) {
|
|
80
|
+
console.error(`${spec.name}: wave ${note.wave} started a follow-on run for wave ${note.next}, so this run's outcome is not the waves'; that run sends it`);
|
|
81
|
+
return 0;
|
|
82
|
+
}
|
|
83
|
+
// #4998: the last run of a chain adds up the earlier runs' outcomes, which its note carries.
|
|
84
|
+
const { withChainOutcomes } = await import("../../op/op-waves-follow-on");
|
|
85
|
+
const summary = applyOutcomeOf(withChainOutcomes(earlierWaveOutcomes([resolve(opWaveOutcomeDir(spec))], Number.MAX_SAFE_INTEGER).members, note));
|
|
71
86
|
if (args.json) console.log(JSON.stringify(summary, null, 2));
|
|
72
87
|
else {
|
|
73
88
|
console.log(summary.outcome);
|
|
@@ -95,6 +110,14 @@ async function runOpWaveJobCommand(ctx: CommandContext): Promise<number> {
|
|
|
95
110
|
console.error(formatError({ message: `--policy-only runs a wave's policy in its own or its deciding job; a --${args.share !== undefined ? "share" : "group"} job has none of its own` }));
|
|
96
111
|
return 1;
|
|
97
112
|
}
|
|
113
|
+
// #4987: one of a split wave's four jobs before merge.
|
|
114
|
+
const phase = args.phase as OpWavePhase | undefined;
|
|
115
|
+
if (phase !== undefined && !OP_WAVE_PHASES.includes(phase)) {
|
|
116
|
+
console.error(formatError({ message: `--phase is one of ${OP_WAVE_PHASES.join(", ")}: a split wave's plan, gate, apply or record job`, hint: `got ${JSON.stringify(args.phase ?? "")}` }));
|
|
117
|
+
return 1;
|
|
118
|
+
}
|
|
119
|
+
// The gate and record jobs run at the default branch; a before-merge run's applied commit is its decided head.
|
|
120
|
+
const decidedHead = phase === "gate" || phase === "record" ? beforeMergeRunFromEnv().head : undefined;
|
|
98
121
|
let spec: OpWavesSpec | undefined;
|
|
99
122
|
const job = { ...(args.share !== undefined ? { share: args.share } : {}), ...(args.group !== undefined ? { group: args.group } : {}) };
|
|
100
123
|
if (args.eventsJson && args.json) {
|
|
@@ -119,8 +142,9 @@ async function runOpWaveJobCommand(ctx: CommandContext): Promise<number> {
|
|
|
119
142
|
spec = parseOpWavesSpec(readFileSync(path, "utf-8"), `--spec ${specFile}`);
|
|
120
143
|
}
|
|
121
144
|
// #4979: a comment that ran the apply again through wave n leaves the waves after it waiting, as a gate does.
|
|
122
|
-
|
|
123
|
-
|
|
145
|
+
// #4987: in a split wave the gate job reads the stop, with the token, at the decided head.
|
|
146
|
+
if (!args.policyOnly && (phase === undefined || phase === "gate")) {
|
|
147
|
+
const stopped = await waveStopLine(spec.name, args.wave, decidedHead ? { sha: decidedHead } : {});
|
|
124
148
|
if (stopped) {
|
|
125
149
|
console.error(stopped);
|
|
126
150
|
return CHANT_EXIT.waiting;
|
|
@@ -138,6 +162,8 @@ async function runOpWaveJobCommand(ctx: CommandContext): Promise<number> {
|
|
|
138
162
|
...(product?.capabilities ? { capabilities: product.capabilities } : {}),
|
|
139
163
|
...(product?.hookExec ? { hookExec: product.hookExec } : {}),
|
|
140
164
|
...(product?.runHooks ? { runHooks: product.runHooks } : {}),
|
|
165
|
+
// #4994: the spec's hooks the product serves in this process, in whichever job of a split wave runs them.
|
|
166
|
+
...(product?.hooks ? { inProcessHooks: product.hooks } : {}),
|
|
141
167
|
spec,
|
|
142
168
|
specFile: relative(process.cwd(), path),
|
|
143
169
|
wave: args.wave,
|
|
@@ -147,10 +173,17 @@ async function runOpWaveJobCommand(ctx: CommandContext): Promise<number> {
|
|
|
147
173
|
...(args.group !== undefined ? { group: args.group } : {}),
|
|
148
174
|
...(args.base ? { base: args.base } : {}),
|
|
149
175
|
...(show ? { show } : {}),
|
|
176
|
+
...(phase ? { phase } : {}),
|
|
177
|
+
...(decidedHead ? { head: decidedHead } : {}),
|
|
150
178
|
});
|
|
179
|
+
// #4992: the rest wave's record job starts the follow-on run for the next wave its plan found.
|
|
180
|
+
if (phase === "record") result.exitCode = await (await import("../../op/op-waves-follow-on")).followOnAfterRecord({ spec, wave: args.wave, exitCode: result.exitCode });
|
|
151
181
|
if (args.json) console.log(JSON.stringify(result, null, 2));
|
|
152
182
|
// #4926: the policy step applied nothing; the wave's own step tells people how it went.
|
|
153
183
|
if (args.policyOnly) return result.exitCode;
|
|
184
|
+
// #4987: the plan and apply jobs run the change's code and hold no token; the gate job tells people when the wave stops
|
|
185
|
+
// there, and the record job how it applied.
|
|
186
|
+
if (phase === "plan" || phase === "apply" || (phase === "gate" && result.exitCode === CHANT_EXIT.done)) return result.exitCode;
|
|
154
187
|
// #3761: tell people, when the spec says where. Delivery never changes the exit code.
|
|
155
188
|
await notifyOpWave(spec, args.wave, { result }, job);
|
|
156
189
|
// #4629: a refused wave's diff and a failed apply's triage, on the pull request or a tracking issue.
|
|
@@ -159,7 +192,7 @@ async function runOpWaveJobCommand(ctx: CommandContext): Promise<number> {
|
|
|
159
192
|
} catch (err) {
|
|
160
193
|
const message = err instanceof Error ? err.message : String(err);
|
|
161
194
|
console.error(formatError({ message }));
|
|
162
|
-
if (spec) {
|
|
195
|
+
if (spec && phase !== "plan" && phase !== "apply") {
|
|
163
196
|
await notifyOpWave(spec, args.wave, { error: message }, job);
|
|
164
197
|
await respondWave(spec, args.wave, { error: message });
|
|
165
198
|
}
|
|
@@ -167,6 +200,113 @@ async function runOpWaveJobCommand(ctx: CommandContext): Promise<number> {
|
|
|
167
200
|
}
|
|
168
201
|
}
|
|
169
202
|
|
|
203
|
+
/**
|
|
204
|
+
* `chant run wave --op <op> --wave <last> --merge auto|manual --forge <kind>
|
|
205
|
+
* [--gate <name>] [--merge-token-env <VAR>]` (#4984): the job after a
|
|
206
|
+
* before-merge run's last wave (`../../op/before-merge-done.ts`). A push run
|
|
207
|
+
* names no decided head, and the job does nothing.
|
|
208
|
+
*/
|
|
209
|
+
async function runBeforeMergeDone(ctx: CommandContext): Promise<number> {
|
|
210
|
+
const { args } = ctx;
|
|
211
|
+
const fail = (message: string): number => {
|
|
212
|
+
console.error(formatError({ message }));
|
|
213
|
+
return 1;
|
|
214
|
+
};
|
|
215
|
+
if (args.merge !== "auto" && args.merge !== "manual") return fail("--merge is auto or manual: auto merges the pull request once every wave applied its decided head, manual says it is ready");
|
|
216
|
+
const op = args.op;
|
|
217
|
+
if (!op || args.wave === undefined) return fail("--merge closes a before-merge run: --op <name> --wave <last wave> --merge auto|manual --forge <kind>");
|
|
218
|
+
const { FORGE_KINDS } = await import("../../pr-forge");
|
|
219
|
+
if (!args.forge || !(FORGE_KINDS as readonly string[]).includes(args.forge)) return fail(`--merge replies on the pull request: --forge ${FORGE_KINDS.join("|")}`);
|
|
220
|
+
const kind = args.forge as (typeof FORGE_KINDS)[number];
|
|
221
|
+
const { beforeMergeRunFromEnv, isBeforeMergeRun } = await import("../../op/before-merge");
|
|
222
|
+
const run = beforeMergeRunFromEnv();
|
|
223
|
+
if (!isBeforeMergeRun(run)) {
|
|
224
|
+
console.error("this run names no decided head: a push applies on its own, so nothing is merged here");
|
|
225
|
+
return 0;
|
|
226
|
+
}
|
|
227
|
+
try {
|
|
228
|
+
const { beforeMergeRecordAt } = await import("../../op/before-merge-store");
|
|
229
|
+
const { beforeMergeDone } = await import("../../op/before-merge-done");
|
|
230
|
+
const { opWaveOutcomeDir } = await import("../../op/op-waves");
|
|
231
|
+
const { earlierWaveOutcomes } = await import("../../wave-blocked");
|
|
232
|
+
const { applyOutcomeOf } = await import("../../control/applied");
|
|
233
|
+
const { forgeFromJobEnv } = await import("../../pr-forge-job");
|
|
234
|
+
const { mergeTokenEnv } = await import("../../pr-merge");
|
|
235
|
+
const { releaseTargetLocks } = await import("../../lifecycle/target-lock");
|
|
236
|
+
const { PR_APPLY_GATE } = await import("../../pr-loop");
|
|
237
|
+
const { activeProductWords } = await import("../../ci-product-words");
|
|
238
|
+
const record = run.head ? await beforeMergeRecordAt(op, run.head) : undefined;
|
|
239
|
+
// #4992: a run whose rest wave started a follow-on leaves the merge to that run.
|
|
240
|
+
const { readOpWaveRestNote, withChainOutcomes } = await import("../../op/op-waves-follow-on");
|
|
241
|
+
const note = readOpWaveRestNote([resolve(opWaveOutcomeDir({ name: op }))]);
|
|
242
|
+
// #4998: the last run of a chain adds up the earlier runs' outcomes, which its note carries.
|
|
243
|
+
const outcome = applyOutcomeOf(withChainOutcomes(earlierWaveOutcomes([resolve(opWaveOutcomeDir({ name: op }))], Number.MAX_SAFE_INTEGER).members, note));
|
|
244
|
+
let merger;
|
|
245
|
+
if (args.merge === "auto" && args.mergeTokenEnv) {
|
|
246
|
+
const env = mergeTokenEnv(args.mergeTokenEnv);
|
|
247
|
+
if ("error" in env) return fail(String(env.error));
|
|
248
|
+
merger = forgeFromJobEnv(kind, env);
|
|
249
|
+
}
|
|
250
|
+
const gate = args.gate ?? PR_APPLY_GATE;
|
|
251
|
+
const done = await beforeMergeDone({
|
|
252
|
+
op,
|
|
253
|
+
waves: args.wave,
|
|
254
|
+
run,
|
|
255
|
+
record,
|
|
256
|
+
outcome,
|
|
257
|
+
...(note?.next !== undefined ? { followOn: { wave: note.wave, next: note.next, found: note.found } } : {}),
|
|
258
|
+
merge: args.merge,
|
|
259
|
+
forge: forgeFromJobEnv(kind),
|
|
260
|
+
...(merger ? { merger } : {}),
|
|
261
|
+
release: async (pr) => (await releaseTargetLocks(gate, pr)).released,
|
|
262
|
+
words: activeProductWords(),
|
|
263
|
+
});
|
|
264
|
+
console.error(done.text);
|
|
265
|
+
return done.code;
|
|
266
|
+
} catch (err) {
|
|
267
|
+
return fail(err instanceof Error ? err.message : String(err));
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* `chant run wave --op <op> --wave <n> --of <count> --apply-status <context>
|
|
273
|
+
* --at <sha> --forge <kind>` (#4987): the job after wave n posts its apply
|
|
274
|
+
* status on the commit the waves applied, from every outcome file the job
|
|
275
|
+
* downloaded (`../../op/apply-status.ts`). It runs at the default branch's
|
|
276
|
+
* commit and none of the change's code. A refused post fails the job.
|
|
277
|
+
*/
|
|
278
|
+
async function runApplyStatus(ctx: CommandContext): Promise<number> {
|
|
279
|
+
const { args } = ctx;
|
|
280
|
+
const fail = (message: string): number => {
|
|
281
|
+
console.error(formatError({ message }));
|
|
282
|
+
return 1;
|
|
283
|
+
};
|
|
284
|
+
const op = args.op;
|
|
285
|
+
if (!op || args.wave === undefined || args.of === undefined || !args.at) return fail("--apply-status posts one wave's apply status: --op <name> --wave <n> --of <count> --apply-status <context> --at <sha> --forge <kind>");
|
|
286
|
+
const { FORGE_KINDS } = await import("../../pr-forge");
|
|
287
|
+
if (!args.forge || !(FORGE_KINDS as readonly string[]).includes(args.forge)) return fail(`--apply-status posts on a forge: --forge ${FORGE_KINDS.join("|")}`);
|
|
288
|
+
const kind = args.forge as (typeof FORGE_KINDS)[number];
|
|
289
|
+
try {
|
|
290
|
+
const { postOpWaveApplyStatus } = await import("../../op/apply-status");
|
|
291
|
+
const { opWaveOutcomeDir } = await import("../../op/op-waves");
|
|
292
|
+
const { forgeFromJobEnv } = await import("../../pr-forge-job");
|
|
293
|
+
const pipeline = kind === "gitlab" && args.at === process.env.CI_COMMIT_SHA && /^[0-9]+$/.test(process.env.CI_PIPELINE_ID ?? "") ? Number(process.env.CI_PIPELINE_ID) : undefined;
|
|
294
|
+
const line = await postOpWaveApplyStatus({
|
|
295
|
+
forge: forgeFromJobEnv(kind),
|
|
296
|
+
dirs: [resolve(opWaveOutcomeDir({ name: op }))],
|
|
297
|
+
wave: args.wave,
|
|
298
|
+
of: args.of,
|
|
299
|
+
context: args.applyStatus!,
|
|
300
|
+
at: args.at,
|
|
301
|
+
...(pipeline !== undefined ? { pipelineId: pipeline } : {}),
|
|
302
|
+
});
|
|
303
|
+
console.error(line);
|
|
304
|
+
return 0;
|
|
305
|
+
} catch (err) {
|
|
306
|
+
return fail(`the apply status was not posted: ${err instanceof Error ? err.message : String(err)}`);
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
|
|
170
310
|
/**
|
|
171
311
|
* The wave job's responses (#4629), through the forge the job's variables
|
|
172
312
|
* name. A job with no forge token posts nothing. Never throws.
|
package/src/cli/main.ts
CHANGED
|
@@ -619,6 +619,23 @@ Ops:
|
|
|
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
621
|
reads the rules at base from it (#4982).
|
|
622
|
+
--phase plan|gate|apply|record: one of a wave's four
|
|
623
|
+
jobs before merge (#4987). plan saves the plan and
|
|
624
|
+
writes nothing to chant/lifecycle; gate decides the
|
|
625
|
+
gate on the saved plan at the default branch; apply
|
|
626
|
+
applies the saved plans the decision holds; record
|
|
627
|
+
writes the applying jobs' run records.
|
|
628
|
+
--op <name> --wave <last> --merge auto|manual
|
|
629
|
+
--forge <kind> [--gate <name>] [--merge-token-env
|
|
630
|
+
<VAR>]: the job after a before-merge run's last wave
|
|
631
|
+
(#4984): checks the decided head and that every wave
|
|
632
|
+
applied, then merges the pull request at that head
|
|
633
|
+
and releases its locks (auto), or says it is ready.
|
|
634
|
+
--op <name> --wave <n> --of <count> --apply-status
|
|
635
|
+
<context> --at <sha> --forge <kind>: the job after
|
|
636
|
+
wave n posts <context> on the commit the waves
|
|
637
|
+
applied, from the outcome files: pending until the
|
|
638
|
+
last wave's success, failed for a failed run (#4987).
|
|
622
639
|
--record-plans (no --wave), in a pull request's
|
|
623
640
|
pipeline: plan every wave at its head and record the
|
|
624
641
|
digests a pr-review approval mode compares.
|
package/src/cli/parse-args.ts
CHANGED
|
@@ -505,6 +505,16 @@ export function parseArgs(args: string[]): ParsedArgs {
|
|
|
505
505
|
result.approvalStatus = true;
|
|
506
506
|
} else if (arg === "--waves-outcome") {
|
|
507
507
|
result.wavesOutcome = true;
|
|
508
|
+
} else if (arg === "--apply-status") {
|
|
509
|
+
// `chant run wave --op <op> --wave <n> --of <count> --apply-status <context> --at <sha>` (#4987): post wave n's apply status.
|
|
510
|
+
const value = args[++i];
|
|
511
|
+
if (!value || value.startsWith("-")) throw new Error("--apply-status needs the status's name: --apply-status <context>");
|
|
512
|
+
result.applyStatus = value;
|
|
513
|
+
} else if (arg === "--of") {
|
|
514
|
+
const raw = args[++i];
|
|
515
|
+
const of = Number(raw);
|
|
516
|
+
if (!Number.isInteger(of) || of < 1) throw new Error(`--of needs the number of waves: got "${raw ?? ""}"`);
|
|
517
|
+
result.of = of;
|
|
508
518
|
} else if (arg === "--group") {
|
|
509
519
|
const raw = args[++i];
|
|
510
520
|
if (!raw || raw.startsWith("-")) throw new Error("--group needs a job group's name: --group <name>");
|
|
@@ -976,6 +986,15 @@ export function parseArgs(args: string[]): ParsedArgs {
|
|
|
976
986
|
// `chant components pr-post --not-affected <argument>` (#4963): the re-plan's argument, which may be empty; pr-post checks it.
|
|
977
987
|
if (i + 1 >= args.length) throw new Error('--not-affected needs the re-plan\'s argument, empty for none: --not-affected "$CHANT_PLAN_ARGUMENT"');
|
|
978
988
|
result.notAffected = args[++i];
|
|
989
|
+
} else if (arg === "--context") {
|
|
990
|
+
// `chant components pr-post --context <context>` (#5003): the product plan's own plan status context; with --stale, one a --member.
|
|
991
|
+
const value = args[++i];
|
|
992
|
+
if (!value || !/^[A-Za-z0-9][A-Za-z0-9_.\/:-]*$/.test(value)) throw new Error(`--context needs the plan status's context, letters, digits and _./:-: got "${value ?? ""}"`);
|
|
993
|
+
result.statusContexts = [...(result.statusContexts ?? []), value];
|
|
994
|
+
} else if (arg === "--plan-job") {
|
|
995
|
+
// `chant components pr-post --open --plan-job <name>` (#5003): the product plan's own GitLab plan job, whose artifacts hold the report.
|
|
996
|
+
result.planJob = args[++i];
|
|
997
|
+
if (!result.planJob || !/^[A-Za-z0-9_][A-Za-z0-9_-]*$/.test(result.planJob)) throw new Error(`--plan-job needs the plan job's name: got "${result.planJob ?? ""}"`);
|
|
979
998
|
} else if (arg === "--evidence-dir") {
|
|
980
999
|
// `chant components pr-post --open --evidence-dir <dir>` (#4914): each merge request's evidence.json, from the GitLab signing job.
|
|
981
1000
|
result.evidenceDir = args[++i];
|
|
@@ -1381,6 +1400,7 @@ export function parseArgs(args: string[]): ParsedArgs {
|
|
|
1381
1400
|
result.quarantineOnly = true;
|
|
1382
1401
|
} else if (arg === "--phase") {
|
|
1383
1402
|
// `chant ci base --phase <name>` (#4643): the ci.green phase whose base to find.
|
|
1403
|
+
// `chant run wave --phase plan|gate|apply|record` (#4987): one job of a split wave; the handler checks the word.
|
|
1384
1404
|
result.phase = args[++i];
|
|
1385
1405
|
} else if (arg === "--audit-log") {
|
|
1386
1406
|
// `chant audit-log attribute|unrecorded --audit-log aws[:<region>]` (#4632).
|
package/src/cli/registry.ts
CHANGED
|
@@ -344,6 +344,10 @@ export interface ParsedArgs {
|
|
|
344
344
|
approvalStatus?: boolean;
|
|
345
345
|
/** `chant run wave --waves-outcome` (#4617) — print how every wave job's outcome file adds up: the outcome a control dispatch carries. */
|
|
346
346
|
wavesOutcome?: boolean;
|
|
347
|
+
/** `chant run wave --op <op> --wave <n> --of <count> --apply-status <context> --at <sha> --forge <kind>` (#4987) — post wave n's apply status from the outcome files. */
|
|
348
|
+
applyStatus?: string;
|
|
349
|
+
/** `chant run wave --of <count>` (#4987) — how many waves the run has, with `--apply-status`. */
|
|
350
|
+
of?: number;
|
|
347
351
|
/** `chant run wave --share <i>` (#3679) — apply share `i` of a decided wide wave. */
|
|
348
352
|
share?: number;
|
|
349
353
|
/** `chant run wave --group <name>` (#3914) — apply one job group's runs of a decided wave. */
|
|
@@ -611,6 +615,10 @@ export interface ParsedArgs {
|
|
|
611
615
|
recordRun?: string;
|
|
612
616
|
/** `chant components pr-post --not-affected <argument>` (#4963): the argument a re-plan was narrowed to, which gets a "not affected" reply when the change reaches nothing. */
|
|
613
617
|
notAffected?: string;
|
|
618
|
+
/** `chant components pr-post --context <context>` (#5003): the product plan's own plan status context; with `--stale`, one a `--member`. */
|
|
619
|
+
statusContexts?: string[];
|
|
620
|
+
/** `chant components pr-post --open --plan-job <name>` (#5003): the product plan's own GitLab plan job, whose artifacts hold the report. */
|
|
621
|
+
planJob?: string;
|
|
614
622
|
/** `chant components pr-post --open --evidence-dir <dir>` (#4914): where the GitLab signing job kept each merge request's `evidence.json`, for the note's checks line. */
|
|
615
623
|
evidenceDir?: string;
|
|
616
624
|
/** `chant ci evidence sign --open --no-forks` (#4914): sign for no merge request from a fork. */
|
|
@@ -1012,7 +1020,10 @@ export interface ParsedArgs {
|
|
|
1012
1020
|
ciTimeoutMinutes?: number;
|
|
1013
1021
|
/** `chant ci last-green --lane <name>` and `chant ci base --lane <name>` (#4662) — a ci.green lane. `chant release cut --lane <name>` and `chant release candidates --lane <name>` (#4692) — check that lane's green tags. */
|
|
1014
1022
|
lane?: string;
|
|
1015
|
-
/**
|
|
1023
|
+
/**
|
|
1024
|
+
* `chant ci base --phase <name>` (#4643) — the ci.green phase whose base to find. `chant ci quarantine filter --phase <name>` (#4677) — the phase whose runner takes the filter.
|
|
1025
|
+
* `chant run wave --phase plan|gate|apply|record` (#4987) — one of a split wave's four jobs before merge.
|
|
1026
|
+
*/
|
|
1016
1027
|
phase?: string;
|
|
1017
1028
|
/** `chant ci quarantine filter --runner nextest|playwright|list` (#4677). */
|
|
1018
1029
|
quarantineRunner?: string;
|
|
@@ -42,6 +42,10 @@
|
|
|
42
42
|
* variables, lines and report directory come with `PrCheckJobOptions`, and
|
|
43
43
|
* a product's own workflow renders the jobs through the lexicons'
|
|
44
44
|
* `productCheckJobs`.
|
|
45
|
+
*
|
|
46
|
+
* #4988: on GitLab the check job keeps a product's own files beside the
|
|
47
|
+
* report (`artifacts: { paths, reports }`), such as a lint hook's code
|
|
48
|
+
* quality report, so a product's lint job can move onto chant's.
|
|
45
49
|
*/
|
|
46
50
|
|
|
47
51
|
import type { ForgeKind } from "../pr-forge";
|
|
@@ -95,6 +99,28 @@ export interface PrCheckJobOptions {
|
|
|
95
99
|
dir?: string;
|
|
96
100
|
/** Arguments after `--base` (and `--output`), each one word, quoted where the shell needs it: `--summary <file>` and the targets a `perRun` hook runs for. */
|
|
97
101
|
args?: string[];
|
|
102
|
+
/**
|
|
103
|
+
* GitLab only (#4988): files the check job keeps beside its report, such
|
|
104
|
+
* as a hook's code quality report. See {@link PrCheckArtifacts}.
|
|
105
|
+
*/
|
|
106
|
+
artifacts?: PrCheckArtifacts;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* What a GitLab check job keeps besides its report directory (#4988),
|
|
111
|
+
* relative to the job's directory as `dir` is: `paths`, more files or
|
|
112
|
+
* directories for `artifacts:paths`, and `reports`, GitLab's
|
|
113
|
+
* `artifacts:reports` by report type, such as `{ codequality:
|
|
114
|
+
* "gl-code-quality-report.json" }`, so a merge request shows a hook's
|
|
115
|
+
* findings. Kept when the check fails too, as the report is.
|
|
116
|
+
*
|
|
117
|
+
* GitHub and Forgejo take none: the check step is the job's last step
|
|
118
|
+
* (#4295), so no upload step can follow it, and a hook there shows its
|
|
119
|
+
* findings as annotations in the log (`--format forge`).
|
|
120
|
+
*/
|
|
121
|
+
export interface PrCheckArtifacts {
|
|
122
|
+
paths?: string[];
|
|
123
|
+
reports?: Record<string, string | string[]>;
|
|
98
124
|
}
|
|
99
125
|
|
|
100
126
|
/** One shell word: as it is when it needs no quoting, else in single quotes. */
|
|
@@ -115,6 +141,8 @@ export interface PrCheckJob {
|
|
|
115
141
|
services?: PrCheckService[];
|
|
116
142
|
/** The lines before the command (#4964). */
|
|
117
143
|
before?: string[];
|
|
144
|
+
/** GitLab: the files kept beside the report (#4988). */
|
|
145
|
+
artifacts?: PrCheckArtifacts;
|
|
118
146
|
/**
|
|
119
147
|
* With `evidence`: the signing job's lines and variables. GitHub and
|
|
120
148
|
* Forgejo run them in `check-evidence` after taking the report back;
|
|
@@ -130,9 +158,43 @@ export interface PrCheckJob {
|
|
|
130
158
|
/** The variables a check job's own `env` may not set: the ones the job and its handover read, and the credentials it drops. */
|
|
131
159
|
const CHECK_RESERVED_ENV = /^(BASE_SHA|HEAD_SHA|CHECK_RESULT|CHANT_RUNNER_KEY|CHANT_RUNNER_IDENTITY|CHANT_LOCAL_EVIDENCE_KEY|CHANT_CHECKOUT_TOKEN|GITHUB_TOKEN|GH_TOKEN|FORGEJO_TOKEN|GITLAB_TOKEN|CI_JOB_TOKEN|CHANT_FORGE_TOKEN|ACTIONS_ID_TOKEN_REQUEST_(URL|TOKEN))$/;
|
|
132
160
|
|
|
161
|
+
/** A relative path inside the checkout: no leading `/`, no `..`, and with `glob` GitLab's `*` wildcards. */
|
|
162
|
+
function insideCheckout(path: string, glob = false): boolean {
|
|
163
|
+
return (glob ? /^[A-Za-z0-9._*][A-Za-z0-9._*\/-]*$/ : /^[A-Za-z0-9._][A-Za-z0-9._\/-]*$/).test(path) && !path.split("/").includes("..");
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/** The check job's extra artifacts (#4988), or undefined when they name nothing; refused off GitLab and for a path outside the checkout. */
|
|
167
|
+
function checkArtifacts(forge: ForgeKind, artifacts: PrCheckArtifacts | undefined): PrCheckArtifacts | undefined {
|
|
168
|
+
return gitlabJobArtifacts(forge, artifacts, { job: "the check job", last: "the check is the job's last step" });
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* A GitLab job's extra artifacts (#4988; #5004, the product plan's plan
|
|
173
|
+
* job), or undefined when they name nothing. Refused off GitLab, where
|
|
174
|
+
* `who.last` says why no upload can follow, for a path outside the
|
|
175
|
+
* checkout, a report type that is not a lower-case word, and
|
|
176
|
+
* `coverage_report`, which takes a format besides a path.
|
|
177
|
+
*/
|
|
178
|
+
export function gitlabJobArtifacts(forge: ForgeKind, artifacts: PrCheckArtifacts | undefined, who: { job: string; last: string }): PrCheckArtifacts | undefined {
|
|
179
|
+
const paths = artifacts?.paths ?? [];
|
|
180
|
+
const reports = Object.entries(artifacts?.reports ?? {});
|
|
181
|
+
if (paths.length === 0 && reports.length === 0) return undefined;
|
|
182
|
+
if (forge !== "gitlab") throw new Error(`${who.job}'s artifacts are GitLab's artifacts:paths and artifacts:reports; on GitHub and Forgejo ${who.last}, so leave artifacts out there`);
|
|
183
|
+
for (const p of paths) {
|
|
184
|
+
if (!insideCheckout(p, true)) throw new Error(`${who.job}'s artifact path ${JSON.stringify(p)} is not a relative path inside the checkout`);
|
|
185
|
+
}
|
|
186
|
+
for (const [type, value] of reports) {
|
|
187
|
+
if (!/^[a-z][a-z_]*$/.test(type)) throw new Error(`${who.job}'s artifact report ${JSON.stringify(type)} is not a GitLab report type`);
|
|
188
|
+
if (type === "coverage_report") throw new Error(`${who.job}'s artifact reports take a path for each report type, and GitLab's coverage_report takes a format besides; keep it in a job of the product's own`);
|
|
189
|
+
const list = Array.isArray(value) ? value : [value];
|
|
190
|
+
if (list.length === 0 || list.some((p) => !insideCheckout(p, true))) throw new Error(`${who.job}'s ${type} report ${JSON.stringify(value)} is not a relative path inside the checkout`);
|
|
191
|
+
}
|
|
192
|
+
return { ...(paths.length > 0 ? { paths } : {}), ...(reports.length > 0 ? { reports: Object.fromEntries(reports) } : {}) };
|
|
193
|
+
}
|
|
194
|
+
|
|
133
195
|
/** Refuse check job settings no job could hold (#4964). */
|
|
134
196
|
function assertCheckJobOptions(opts: PrCheckJobOptions): void {
|
|
135
|
-
if (opts.dir !== undefined && (
|
|
197
|
+
if (opts.dir !== undefined && !insideCheckout(opts.dir)) {
|
|
136
198
|
throw new Error(`the check job's report directory ${JSON.stringify(opts.dir)} is not a relative path inside the checkout`);
|
|
137
199
|
}
|
|
138
200
|
for (const a of opts.args ?? []) {
|
|
@@ -164,6 +226,7 @@ function assertCheckJobOptions(opts: PrCheckJobOptions): void {
|
|
|
164
226
|
export function prCheckJob(forge: ForgeKind, opts: { bin?: string; evidence?: PipelineEvidence; noForks?: boolean; member?: { name: string; reportPath: string } } & PrCheckJobOptions = {}): PrCheckJob {
|
|
165
227
|
assertPipelineEvidence(opts.evidence);
|
|
166
228
|
assertCheckJobOptions(opts);
|
|
229
|
+
const artifacts = checkArtifacts(forge, opts.artifacts);
|
|
167
230
|
const gitlab = forge === "gitlab";
|
|
168
231
|
const base = gitlab ? "$CI_MERGE_REQUEST_DIFF_BASE_SHA" : "${{ github.event.pull_request.base.sha }}";
|
|
169
232
|
const dir = opts.dir ?? PR_CHECK_REPORT_DIR;
|
|
@@ -175,6 +238,7 @@ export function prCheckJob(forge: ForgeKind, opts: { bin?: string; evidence?: Pi
|
|
|
175
238
|
dir,
|
|
176
239
|
...(opts.services?.length ? { services: opts.services } : {}),
|
|
177
240
|
...(opts.before?.length ? { before: opts.before } : {}),
|
|
241
|
+
...(artifacts ? { artifacts } : {}),
|
|
178
242
|
};
|
|
179
243
|
const evidence = opts.evidence;
|
|
180
244
|
if (!evidence) return job;
|
|
@@ -251,4 +315,4 @@ export function prRefGateJob(forge: ForgeKind, opts: { bin?: string; branch?: st
|
|
|
251
315
|
};
|
|
252
316
|
}
|
|
253
317
|
|
|
254
|
-
export { CHECK_JOB_FLOOR, GITLAB_OPEN_EVIDENCE_FLOOR, MEMBER_SIGNED_CHECKS_FLOOR, PR_LOOP_EVIDENCE_FLOOR, PRODUCT_CHECK_JOBS_FLOOR, REF_GATE_STATUS_JOB_FLOOR } from "../release-floors";
|
|
318
|
+
export { CHECK_JOB_ARTIFACTS_FLOOR, CHECK_JOB_FLOOR, GITLAB_OPEN_EVIDENCE_FLOOR, MEMBER_SIGNED_CHECKS_FLOOR, PR_LOOP_EVIDENCE_FLOOR, PRODUCT_CHECK_JOBS_FLOOR, REF_GATE_STATUS_JOB_FLOOR } from "../release-floors";
|