@intentius/chant 0.124.96 → 0.124.98
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/audit/core.d.ts +29 -0
- package/dist/audit/core.d.ts.map +1 -1
- package/dist/audit/core.js +48 -11
- package/dist/audit/identity.d.ts +27 -0
- package/dist/audit/identity.d.ts.map +1 -0
- package/dist/audit/identity.js +36 -0
- package/dist/audit/report-html.d.ts +3 -1
- package/dist/audit/report-html.d.ts.map +1 -1
- package/dist/audit/report-html.js +1 -1
- package/dist/audit/report-model.d.ts +16 -0
- package/dist/audit/report-model.d.ts.map +1 -1
- package/dist/audit/report-model.js +5 -1
- package/dist/change-set-graph.d.ts +3 -1
- package/dist/change-set-graph.d.ts.map +1 -1
- package/dist/change-set-graph.js +7 -1
- package/dist/change-set.d.ts +5 -2
- package/dist/change-set.d.ts.map +1 -1
- package/dist/change-set.js +6 -3
- package/dist/ci-agent.d.ts +17 -0
- package/dist/ci-agent.d.ts.map +1 -1
- package/dist/ci-agent.js +32 -0
- package/dist/ci-comment-allow.d.ts +88 -0
- package/dist/ci-comment-allow.d.ts.map +1 -0
- package/dist/ci-comment-allow.js +178 -0
- package/dist/ci-comment-commands.d.ts +12 -0
- package/dist/ci-comment-commands.d.ts.map +1 -1
- package/dist/ci-comment-commands.js +22 -0
- package/dist/ci-control.d.ts +6 -1
- package/dist/ci-control.d.ts.map +1 -1
- package/dist/ci-control.js +6 -1
- package/dist/ci-product.d.ts +3 -0
- package/dist/ci-product.d.ts.map +1 -1
- package/dist/ci-product.js +3 -0
- package/dist/cli/commands/audit.d.ts +3 -1
- package/dist/cli/commands/audit.d.ts.map +1 -1
- package/dist/cli/commands/audit.js +23 -6
- package/dist/cli/commands/import.d.ts +8 -1
- package/dist/cli/commands/import.d.ts.map +1 -1
- package/dist/cli/commands/import.js +31 -6
- package/dist/cli/handlers/agent.d.ts.map +1 -1
- package/dist/cli/handlers/agent.js +12 -2
- package/dist/cli/handlers/pr-comment.d.ts +6 -0
- package/dist/cli/handlers/pr-comment.d.ts.map +1 -1
- package/dist/cli/handlers/pr-comment.js +12 -0
- package/dist/cli/handlers/promote.d.ts.map +1 -1
- package/dist/cli/handlers/promote.js +53 -6
- package/dist/cli/main.d.ts.map +1 -1
- package/dist/cli/main.js +29 -6
- package/dist/cli/parse-args.d.ts.map +1 -1
- package/dist/cli/parse-args.js +23 -0
- package/dist/cli/registry.d.ts +8 -0
- package/dist/cli/registry.d.ts.map +1 -1
- package/dist/cloud-lister/mask.d.ts +30 -1
- package/dist/cloud-lister/mask.d.ts.map +1 -1
- package/dist/cloud-lister/mask.js +66 -3
- package/dist/components/driver.d.ts +8 -1
- package/dist/components/driver.d.ts.map +1 -1
- package/dist/components/driver.js +1 -0
- package/dist/components/product-pipeline.d.ts +23 -1
- package/dist/components/product-pipeline.d.ts.map +1 -1
- package/dist/components/product-pipeline.js +40 -7
- package/dist/components/product-plan.d.ts +20 -0
- package/dist/components/product-plan.d.ts.map +1 -1
- package/dist/components/product-plan.js +11 -1
- package/dist/control/applied.d.ts +8 -1
- package/dist/control/applied.d.ts.map +1 -1
- package/dist/control/applied.js +18 -2
- package/dist/control/dispatch.d.ts +52 -0
- package/dist/control/dispatch.d.ts.map +1 -1
- package/dist/control/dispatch.js +140 -4
- package/dist/control/train.d.ts +198 -0
- package/dist/control/train.d.ts.map +1 -0
- package/dist/control/train.js +294 -0
- package/dist/deep-observation.js +2 -2
- package/dist/floor-table.data.d.ts.map +1 -1
- package/dist/floor-table.data.js +7 -1
- package/dist/graph-detail.d.ts +9 -0
- package/dist/graph-detail.d.ts.map +1 -1
- package/dist/graph-detail.js +38 -13
- package/dist/graph-refs.d.ts +233 -3
- package/dist/graph-refs.d.ts.map +1 -1
- package/dist/graph-refs.js +106 -15
- package/dist/lint/post-synth.d.ts +22 -0
- package/dist/lint/post-synth.d.ts.map +1 -1
- package/dist/lint/rules/declarable-naming-convention.d.ts +12 -0
- package/dist/lint/rules/declarable-naming-convention.d.ts.map +1 -1
- package/dist/lint/rules/declarable-naming-convention.js +38 -8
- package/dist/lint/rules/imported-source.d.ts +20 -0
- package/dist/lint/rules/imported-source.d.ts.map +1 -0
- package/dist/lint/rules/imported-source.js +27 -0
- package/dist/lint/rules/no-unused-declarable.d.ts.map +1 -1
- package/dist/lint/rules/no-unused-declarable.js +3 -0
- package/dist/op/gate.d.ts +2 -0
- package/dist/op/gate.d.ts.map +1 -1
- package/dist/op/gate.js +8 -1
- package/dist/pr-forge-reads.d.ts +17 -0
- package/dist/pr-forge-reads.d.ts.map +1 -1
- package/dist/pr-forge-reads.js +55 -0
- package/dist/reconcile.d.ts +9 -0
- package/dist/reconcile.d.ts.map +1 -1
- package/dist/release-floors.d.ts +9 -1
- package/dist/release-floors.d.ts.map +1 -1
- package/dist/release-floors.js +10 -2
- package/dist/repo-path.d.ts +29 -0
- package/dist/repo-path.d.ts.map +1 -0
- package/dist/repo-path.js +81 -0
- package/dist/sensitive-key.d.ts +23 -0
- package/dist/sensitive-key.d.ts.map +1 -1
- package/dist/sensitive-key.js +37 -0
- package/dist/terraform/hcl2json.d.ts +7 -0
- package/dist/terraform/hcl2json.d.ts.map +1 -1
- package/dist/terraform/hcl2json.js +7 -0
- package/dist/wave-runtime.mjs +352 -345
- package/dist/workspace/catalog-edges.d.ts +147 -0
- package/dist/workspace/catalog-edges.d.ts.map +1 -0
- package/dist/workspace/catalog-edges.js +461 -0
- package/dist/workspace/compose-graph.d.ts +73 -3
- package/dist/workspace/compose-graph.d.ts.map +1 -1
- package/dist/workspace/declaration.d.ts +2 -0
- package/dist/workspace/declaration.d.ts.map +1 -1
- package/dist/workspace/declaration.js +1 -0
- package/dist/workspace/declaration.schema.json +6 -0
- package/dist/workspace/discover.d.ts +134 -0
- package/dist/workspace/discover.d.ts.map +1 -0
- package/dist/workspace/discover.js +372 -0
- package/dist/workspace/graph-cli.d.ts +20 -0
- package/dist/workspace/graph-cli.d.ts.map +1 -1
- package/dist/workspace/graph-cli.js +178 -20
- package/dist/workspace/graph.schema.json +195 -2
- package/dist/workspace/release-train.d.ts +214 -3
- package/dist/workspace/release-train.d.ts.map +1 -1
- package/dist/workspace/release-train.js +552 -16
- package/dist/workspace/repo-ref.d.ts +14 -0
- package/dist/workspace/repo-ref.d.ts.map +1 -1
- package/dist/workspace/repo-ref.js +26 -1
- package/dist/workspace/workspace-gates.d.ts +24 -0
- package/dist/workspace/workspace-gates.d.ts.map +1 -1
- package/dist/workspace/workspace-gates.js +29 -5
- package/dist/workspace/workspace-ledger.d.ts +31 -5
- package/dist/workspace/workspace-ledger.d.ts.map +1 -1
- package/dist/workspace/workspace-ledger.js +2 -1
- package/dist/workspace/workspace-run.d.ts +14 -0
- package/dist/workspace/workspace-run.d.ts.map +1 -1
- package/dist/workspace/workspace-run.js +2 -2
- package/dist/yaml.d.ts.map +1 -1
- package/dist/yaml.js +33 -8
- package/package.json +1 -1
- package/src/audit/core.test.ts +64 -1
- package/src/audit/core.ts +75 -10
- package/src/audit/identity.test.ts +31 -0
- package/src/audit/identity.ts +43 -0
- package/src/audit/report-html.ts +4 -2
- package/src/audit/report-model.ts +21 -1
- package/src/change-set-graph.test.ts +33 -1
- package/src/change-set-graph.ts +7 -1
- package/src/change-set.ts +6 -3
- package/src/ci-agent.test.ts +32 -0
- package/src/ci-agent.ts +42 -0
- package/src/ci-comment-allow.test.ts +380 -0
- package/src/ci-comment-allow.ts +184 -0
- package/src/ci-comment-commands.ts +25 -0
- package/src/ci-control.ts +42 -0
- package/src/ci-product.ts +3 -0
- package/src/cli/commands/audit-parser-notice.test.ts +74 -0
- package/src/cli/commands/audit.test.ts +12 -0
- package/src/cli/commands/audit.ts +25 -7
- package/src/cli/commands/import-layout.test.ts +2 -1
- package/src/cli/commands/import.ts +29 -6
- package/src/cli/handlers/agent.ts +13 -2
- package/src/cli/handlers/pr-before-merge.test.ts +18 -0
- package/src/cli/handlers/pr-comment.ts +12 -0
- package/src/cli/handlers/promote.test.ts +68 -0
- package/src/cli/handlers/promote.ts +52 -6
- package/src/cli/main.test.ts +5 -0
- package/src/cli/main.ts +29 -6
- package/src/cli/parse-args.ts +18 -0
- package/src/cli/registry.ts +8 -0
- package/src/cloud-lister/kubernetes.k3d.e2e.test.ts +104 -0
- package/src/cloud-lister/mask-references.test.ts +132 -0
- package/src/cloud-lister/mask.ts +68 -3
- package/src/components/driver.ts +9 -1
- package/src/components/product-pipeline.ts +57 -7
- package/src/components/product-plan.ts +27 -2
- package/src/control/applied.ts +33 -3
- package/src/control/dispatch.ts +156 -5
- package/src/control/train.test.ts +215 -0
- package/src/control/train.ts +413 -0
- package/src/deep-observation.ts +2 -2
- package/src/floor-table.data.ts +7 -1
- package/src/graph-detail.ts +37 -12
- package/src/graph-refs.test.ts +45 -1
- package/src/graph-refs.ts +321 -14
- package/src/lint/post-synth.ts +20 -0
- package/src/lint/rules/declarable-naming-convention.test.ts +35 -1
- package/src/lint/rules/declarable-naming-convention.ts +35 -8
- package/src/lint/rules/imported-source.test.ts +22 -0
- package/src/lint/rules/imported-source.ts +31 -0
- package/src/lint/rules/no-unused-declarable.test.ts +16 -0
- package/src/lint/rules/no-unused-declarable.ts +7 -0
- package/src/op/gate.ts +10 -2
- package/src/pr-forge-reads.ts +62 -0
- package/src/reconcile.ts +9 -0
- package/src/release-floors.ts +14 -2
- package/src/repo-path.test.ts +72 -0
- package/src/repo-path.ts +103 -0
- package/src/sensitive-key.ts +38 -0
- package/src/terraform/hcl2json.ts +8 -0
- package/src/workspace/application-set.e2e.test.ts +405 -0
- package/src/workspace/catalog-edges.ts +507 -0
- package/src/workspace/ci-green-workflow.test.ts +2 -2
- package/src/workspace/cluster-join.e2e.test.ts +150 -0
- package/src/workspace/compose-graph.ts +74 -5
- package/src/workspace/declaration.schema.json +6 -0
- package/src/workspace/declaration.ts +3 -0
- package/src/workspace/discover.e2e.test.ts +122 -0
- package/src/workspace/discover.test.ts +225 -0
- package/src/workspace/discover.ts +406 -0
- package/src/workspace/drift-reader.test.ts +3 -3
- package/src/workspace/external-secret-catalog.e2e.test.ts +98 -0
- package/src/workspace/external-secret-catalog.test.ts +142 -0
- package/src/workspace/graph-cli.ts +207 -21
- package/src/workspace/graph-contract.test.ts +92 -0
- package/src/workspace/graph.schema.json +195 -2
- package/src/workspace/helm-references.e2e.test.ts +135 -0
- package/src/workspace/identity-annotation-catalog.e2e.test.ts +91 -0
- package/src/workspace/identity-annotation-catalog.test.ts +139 -0
- package/src/workspace/release-train-repos.test.ts +304 -0
- package/src/workspace/release-train.test.ts +296 -0
- package/src/workspace/release-train.ts +631 -16
- package/src/workspace/repo-ref.ts +26 -1
- package/src/workspace/runs-on.test.ts +45 -0
- package/src/workspace/workspace-gates.ts +48 -5
- package/src/workspace/workspace-ledger.ts +28 -5
- package/src/workspace/workspace-run.test.ts +1 -1
- package/src/workspace/workspace-run.ts +2 -2
- package/src/yaml.test.ts +96 -8
- package/src/yaml.ts +36 -8
|
@@ -44,6 +44,7 @@ import { PLAN_WATCHES_ENV, scheduledWatchProblem } from "../op/schedule-overdue.
|
|
|
44
44
|
import { PLAN_RUN_OP, PLAN_RUN_RECORD_FILE } from "../pr-plan-record.js";
|
|
45
45
|
import { idTokenVar, tradedClouds } from "../ci-identity.js";
|
|
46
46
|
import { prNoteMarker } from "../pr-loop.js";
|
|
47
|
+
import { COMMENT_ALLOW_GATE_JS, commentAllowList } from "../ci-comment-allow.js";
|
|
47
48
|
import { PRODUCT_MARKER_NAME } from "../pr-plan-note.js";
|
|
48
49
|
import { gitlabJobArtifacts } from "./pr-checks.js";
|
|
49
50
|
/** The variable the plan-note job reads the product's note words from (#4799), as JSON. Set from the pipeline, never from the report. */
|
|
@@ -342,6 +343,7 @@ export function productPlanJobs(forge, env, loop, words, evidence) {
|
|
|
342
343
|
...(github && dispatchArg !== undefined ? { dispatch: { argument: dispatchArg } } : {}),
|
|
343
344
|
...(replies ? { reply: { prefix: `/${words.product}`, others } } : {}),
|
|
344
345
|
...(replanOpts.notAffected ? { notAffected: true } : {}),
|
|
346
|
+
...(github && replanOpts.commentAllow && commentAllowList(replanOpts.commentAllow, "plan") ? { allow: { list: replanOpts.commentAllow, ...(replanOpts.commentAllowTokenSecret ? { tokenSecret: replanOpts.commentAllowTokenSecret } : {}) } } : {}),
|
|
345
347
|
}
|
|
346
348
|
: undefined;
|
|
347
349
|
const replan = replan0 && plan.record ? { ...replan0, post: { ...replan0.post, command: `${replan0.post.command} --record-run ${replan0.jobName}` } } : replan0;
|
|
@@ -522,7 +524,12 @@ export const REPLAN_DECIDE_JS = replanDecideJs();
|
|
|
522
524
|
* is known (Forgejo). A dispatch's reason goes to the log alone.
|
|
523
525
|
*/
|
|
524
526
|
export function replanDecideJs(opts = {}) {
|
|
525
|
-
const { dispatch = false, reply = false } = opts;
|
|
527
|
+
const { dispatch = false, reply = false, allow = false } = opts;
|
|
528
|
+
// INTENTIUS/terragucci#1461: the pipeline's list for the plan comment, after the permission check; a dispatch asks none.
|
|
529
|
+
// With `reply` the re-plan speaks for itself (the comment job cannot be there beside it); without, it says nothing and the comment job replies.
|
|
530
|
+
const allowLine = allow
|
|
531
|
+
? `${dispatch ? "if(!dispatch)" : ""}{const asker=e.comment&&e.comment.user&&e.comment.user.login;if(!asker){say("the comment has no author, so nothing is planned again");return}const no=await commentAllowRefusal(asker,"plan");if(no){${reply ? 'await post(no+", so nothing is planned again")' : 'say(no+", so nothing is planned again")'};return}}`
|
|
532
|
+
: undefined;
|
|
526
533
|
const replyLine = reply
|
|
527
534
|
? [
|
|
528
535
|
// The reply, as the product: on a dispatch the log alone.
|
|
@@ -564,6 +571,7 @@ export function replanDecideJs(opts = {}) {
|
|
|
564
571
|
: 'const n=e.issue&&e.issue.number;if(!Number.isInteger(n)||!(e.issue.pull_request||e.is_pull)){say("the comment is not on a pull request");process.exit(0)}',
|
|
565
572
|
'const api=String(process.env.GITHUB_API_URL||"").replace(/\\/+$/,""),repo=process.env.GITHUB_REPOSITORY;',
|
|
566
573
|
'const get=async(p)=>{const r=await fetch(api+"/repos/"+repo+p,{headers:{authorization:"token "+process.env.CHANT_REPLAN_TOKEN,accept:"application/json"}});if(!r.ok)throw new Error(p+" answered "+r.status);return r.json()};',
|
|
574
|
+
...(allow ? [COMMENT_ALLOW_GATE_JS] : []),
|
|
567
575
|
...replyLine,
|
|
568
576
|
"(async()=>{",
|
|
569
577
|
...(reply
|
|
@@ -571,6 +579,7 @@ export function replanDecideJs(opts = {}) {
|
|
|
571
579
|
// Who asked comes first: a commenter who cannot write gets no reply.
|
|
572
580
|
`if(process.env.CHANT_REPLAN_PERMISSION${dispatch ? "&&!dispatch" : ""}){const who=e.comment&&e.comment.user&&e.comment.user.login;const p=who?await get("/collaborators/"+encodeURIComponent(who)+"/permission"):{};`,
|
|
573
581
|
'if(!["owner","admin","maintain","write"].includes(p.permission)){say((who||"the commenter")+" cannot write to "+repo+", so nothing is planned again");return}}',
|
|
582
|
+
...(allowLine ? [`if(!refusal)${allowLine}`] : []),
|
|
574
583
|
"if(refusal){await post(refusal);return}",
|
|
575
584
|
'const pr=await get("/pulls/"+n);',
|
|
576
585
|
'if(pr.state!=="open"){say("pull request "+n+" is not open, so it is not planned again");return}',
|
|
@@ -584,6 +593,7 @@ export function replanDecideJs(opts = {}) {
|
|
|
584
593
|
'if(!same&&process.env.CHANT_REPLAN_FORKS==="skip"){say("pull request "+n+" is from a fork, and its code never runs with this repository\\u0027s credentials");return}',
|
|
585
594
|
`if(process.env.CHANT_REPLAN_PERMISSION${dispatch ? "&&!dispatch" : ""}){const who=e.comment&&e.comment.user&&e.comment.user.login;const p=who?await get("/collaborators/"+encodeURIComponent(who)+"/permission"):{};`,
|
|
586
595
|
'if(!["owner","admin","maintain","write"].includes(p.permission)){say((who||"the commenter")+" cannot write to "+repo+", so nothing is planned again");return}}',
|
|
596
|
+
...(allowLine ? [allowLine] : []),
|
|
587
597
|
]),
|
|
588
598
|
'const sha=/^[0-9a-f]{40}$/;if(!sha.test(String(pr.head&&pr.head.sha))||!sha.test(String(pr.base&&pr.base.sha)))throw new Error("the pull request names no head or base commit");',
|
|
589
599
|
'out("go","1");out("pr",String(n));out("head",pr.head.sha);out("base",pr.base.sha);out("argument",arg);',
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
*/
|
|
17
17
|
import { type WaveMemberOutcome } from "../wave-blocked.js";
|
|
18
18
|
import { type ControlLedgerPort } from "./records.js";
|
|
19
|
-
import { CONTROL_APPLY_OUTCOMES, CONTROL_OUTCOME_VAR, CONTROL_RUNS_DEPENDENTS, type ControlApplyOutcome } from "./dispatch.js";
|
|
19
|
+
import { CONTROL_APPLY_OUTCOMES, CONTROL_OUTCOME_VAR, CONTROL_RUNS_DEPENDENTS, type ControlApplyOutcome, type ControlTrainAnswer } from "./dispatch.js";
|
|
20
20
|
export { CONTROL_APPLY_OUTCOMES, CONTROL_OUTCOME_VAR, CONTROL_RUNS_DEPENDENTS, type ControlApplyOutcome };
|
|
21
21
|
/** The outcome, and the counts behind it. */
|
|
22
22
|
export interface ApplyOutcomeSummary {
|
|
@@ -43,6 +43,12 @@ export interface ControlAppliedRecord {
|
|
|
43
43
|
outcome: ControlApplyOutcome;
|
|
44
44
|
/** When the control repo took the dispatch, ISO 8601. */
|
|
45
45
|
at: string;
|
|
46
|
+
/**
|
|
47
|
+
* The release train the apply answers (#5119): the train, the control
|
|
48
|
+
* repo's run of its promote, the environment and the release the member
|
|
49
|
+
* ran. Absent on every other dispatch; a record without it hashes as it did before.
|
|
50
|
+
*/
|
|
51
|
+
train?: ControlTrainAnswer;
|
|
46
52
|
/** sha256 over the canonical JSON of every other field. */
|
|
47
53
|
digest: string;
|
|
48
54
|
}
|
|
@@ -65,6 +71,7 @@ export declare function recordControlApplied(port: ControlLedgerPort, d: {
|
|
|
65
71
|
op: string;
|
|
66
72
|
sha: string;
|
|
67
73
|
outcome: ControlApplyOutcome;
|
|
74
|
+
train?: ControlTrainAnswer;
|
|
68
75
|
}, opts?: {
|
|
69
76
|
now?: () => Date;
|
|
70
77
|
}): Promise<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"applied.d.ts","sourceRoot":"","sources":["../../src/control/applied.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,EAAiB,KAAK,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACxE,OAAO,EAAsB,KAAK,iBAAiB,EAAE,MAAM,WAAW,CAAC;AACvE,OAAO,
|
|
1
|
+
{"version":3,"file":"applied.d.ts","sourceRoot":"","sources":["../../src/control/applied.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,EAAiB,KAAK,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACxE,OAAO,EAAsB,KAAK,iBAAiB,EAAE,MAAM,WAAW,CAAC;AACvE,OAAO,EACL,sBAAsB,EAEtB,mBAAmB,EAGnB,uBAAuB,EAGvB,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,EACxB,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,uBAAuB,EAAE,KAAK,mBAAmB,EAAE,CAAC;AAE1G,6CAA6C;AAC7C,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,mBAAmB,CAAC;IAC7B,qCAAqC;IACrC,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,kDAAkD;IAClD,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAChC;AAED,4GAA4G;AAC5G,wBAAgB,cAAc,CAAC,OAAO,EAAE,WAAW,CAAC,MAAM,EAAE,iBAAiB,CAAC,GAAG,mBAAmB,CAmBnG;AAED,kEAAkE;AAClE,eAAO,MAAM,oBAAoB,kBAAkB,CAAC;AACpD,eAAO,MAAM,oBAAoB,oBAAoB,CAAC;AAEtD,gFAAgF;AAChF,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,CAAC,CAAC;IACX,IAAI,EAAE,OAAO,oBAAoB,CAAC;IAClC,yDAA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,wBAAsB,2BAA2B,CAC/C,IAAI,GAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,IAAI,CAAA;CAAO,GACtF,OAAO,CAAC;IAAE,QAAQ,CAAC,EAAE,oBAAoB,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CAqBtF"}
|
package/dist/control/applied.js
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
import { createHash } from "node:crypto";
|
|
18
18
|
import { passesThrough } from "../wave-blocked.js";
|
|
19
19
|
import { CONTROL_LEDGER_DIR } from "./records.js";
|
|
20
|
-
import { CONTROL_APPLY_OUTCOMES, CONTROL_OUTCOME_VAR, CONTROL_RUNS_DEPENDENTS } from "./dispatch.js";
|
|
20
|
+
import { CONTROL_APPLY_OUTCOMES, CONTROL_ENV_VAR, CONTROL_OUTCOME_VAR, CONTROL_RELEASE_VAR, CONTROL_RUN_VAR, CONTROL_RUNS_DEPENDENTS, CONTROL_TRAIN_VAR, controlTrainProblems, } from "./dispatch.js";
|
|
21
21
|
export { CONTROL_APPLY_OUTCOMES, CONTROL_OUTCOME_VAR, CONTROL_RUNS_DEPENDENTS };
|
|
22
22
|
/** The outcome of a set of runs, from each one's newest outcome (`earlierWaveOutcomes` over every wave). */
|
|
23
23
|
export function applyOutcomeOf(members) {
|
|
@@ -76,6 +76,12 @@ export function controlAppliedProblems(v) {
|
|
|
76
76
|
out.push(`outcome must be one of ${CONTROL_APPLY_OUTCOMES.join(", ")}`);
|
|
77
77
|
if (!(typeof r.at === "string" && !Number.isNaN(Date.parse(r.at))))
|
|
78
78
|
out.push("at must be a time");
|
|
79
|
+
if (r.train !== undefined) {
|
|
80
|
+
if (typeof r.train !== "object" || r.train === null || Array.isArray(r.train))
|
|
81
|
+
out.push("train must be a train's answer");
|
|
82
|
+
else
|
|
83
|
+
out.push(...controlTrainProblems(r.train).map((p) => `train.${p}`));
|
|
84
|
+
}
|
|
79
85
|
if (typeof r.digest !== "string")
|
|
80
86
|
out.push("digest is missing");
|
|
81
87
|
else if (out.length === 0) {
|
|
@@ -142,6 +148,7 @@ export async function recordControlApplied(port, d, opts = {}) {
|
|
|
142
148
|
sha: d.sha,
|
|
143
149
|
outcome: d.outcome,
|
|
144
150
|
at: (opts.now ?? (() => new Date()))().toISOString(),
|
|
151
|
+
...(d.train ? { train: { train: d.train.train, run: d.train.run, env: d.train.env, releaseDigest: d.train.releaseDigest } } : {}),
|
|
145
152
|
};
|
|
146
153
|
const record = { ...fields, digest: digestOf(fields) };
|
|
147
154
|
const problems = controlAppliedProblems(record);
|
|
@@ -168,7 +175,16 @@ export async function recordControlAppliedFromEnv(opts = {}) {
|
|
|
168
175
|
return { skipped: `the dispatch's outcome "${outcome}" is not one chant knows` };
|
|
169
176
|
if (!SHA.test(sha))
|
|
170
177
|
return { skipped: "the dispatch names no commit sha" };
|
|
171
|
-
|
|
178
|
+
// #5119: a train's answer is kept with the train it answers, or not at all.
|
|
179
|
+
let train;
|
|
180
|
+
if (env[CONTROL_TRAIN_VAR]) {
|
|
181
|
+
const t = { train: env[CONTROL_TRAIN_VAR], run: env[CONTROL_RUN_VAR] ?? "", env: env[CONTROL_ENV_VAR] ?? "", releaseDigest: env[CONTROL_RELEASE_VAR] ?? "" };
|
|
182
|
+
const problems = controlTrainProblems(t);
|
|
183
|
+
if (problems.length > 0)
|
|
184
|
+
return { skipped: `the dispatch's train fields are not usable: ${problems.join(", ")}` };
|
|
185
|
+
train = t;
|
|
186
|
+
}
|
|
187
|
+
const { record } = await recordControlApplied(gitControlAppliedLedger({ cwd: opts.cwd }), { member, op, sha, outcome: outcome, ...(train ? { train } : {}) }, opts.now ? { now: opts.now } : {});
|
|
172
188
|
const { pushLifecycleReport } = await import("../lifecycle/git.js");
|
|
173
189
|
const pushed = await pushLifecycleReport({ ...(opts.cwd ? { cwd: opts.cwd } : {}) });
|
|
174
190
|
return { recorded: record, ...(pushed.pushWarning ? { pushWarning: pushed.pushWarning } : {}) };
|
|
@@ -58,6 +58,31 @@ export declare const CONTROL_OP_VAR = "CHANT_CONTROL_OP";
|
|
|
58
58
|
export declare const CONTROL_SHA_VAR = "CHANT_CONTROL_SHA";
|
|
59
59
|
/** The variable the apply outcome travels in (#4617): the member's dispatch step reads it, a GitLab trigger sets it, the control repo's step reads it. */
|
|
60
60
|
export declare const CONTROL_OUTCOME_VAR = "CHANT_CONTROL_OUTCOME";
|
|
61
|
+
/**
|
|
62
|
+
* The variables a train's answer travels in (#5119): the release train and
|
|
63
|
+
* the control repo's run of its promote, the environment, and the release
|
|
64
|
+
* the member ran. A member's train job sets them; its dispatch step reads
|
|
65
|
+
* them; the control repo's step reads them back.
|
|
66
|
+
*/
|
|
67
|
+
export declare const CONTROL_TRAIN_VAR = "CHANT_CONTROL_TRAIN";
|
|
68
|
+
export declare const CONTROL_RUN_VAR = "CHANT_CONTROL_RUN";
|
|
69
|
+
export declare const CONTROL_ENV_VAR = "CHANT_CONTROL_ENV";
|
|
70
|
+
export declare const CONTROL_RELEASE_VAR = "CHANT_CONTROL_RELEASE";
|
|
71
|
+
/** A release train's id, as `chant workspace train` writes it. */
|
|
72
|
+
export declare const CONTROL_TRAIN_ID: RegExp;
|
|
73
|
+
/** A workspace run's id, as `chant workspace train promote` writes it. */
|
|
74
|
+
export declare const CONTROL_RUN_ID: RegExp;
|
|
75
|
+
/** A release digest: `<scheme>:<64 hex digits>`, such as `jcs1-sha256:...`. */
|
|
76
|
+
export declare const CONTROL_RELEASE_DIGEST: RegExp;
|
|
77
|
+
/** What a member's answer to a train's dispatch carries besides the apply (#5119). */
|
|
78
|
+
export interface ControlTrainAnswer {
|
|
79
|
+
train: string;
|
|
80
|
+
run: string;
|
|
81
|
+
env: string;
|
|
82
|
+
releaseDigest: string;
|
|
83
|
+
}
|
|
84
|
+
/** The problems with a train's answer, or [] when it is usable. */
|
|
85
|
+
export declare function controlTrainProblems(t: Partial<Record<keyof ControlTrainAnswer, unknown>>): string[];
|
|
61
86
|
/**
|
|
62
87
|
* What a member's op waves did, as its dispatch says it (#4617, `applyOutcomeOf` in ./applied.ts):
|
|
63
88
|
* - `applied`: at least one run applied, and every other run applied or had nothing to apply.
|
|
@@ -145,6 +170,8 @@ export interface ControlDispatch {
|
|
|
145
170
|
sha: string;
|
|
146
171
|
/** What the member's op waves did (#4617). Absent from the pull request loop's dispatch, which is sent on green only. */
|
|
147
172
|
outcome?: ControlApplyOutcome;
|
|
173
|
+
/** The train the apply answers (#5119), when the member ran for one. */
|
|
174
|
+
train?: ControlTrainAnswer;
|
|
148
175
|
}
|
|
149
176
|
/** Where the token goes in a {@link ControlDispatchRequest}. */
|
|
150
177
|
export type ControlTokenPlace = {
|
|
@@ -198,6 +225,13 @@ export interface DispatchControlOptions {
|
|
|
198
225
|
export declare function dispatchControl(target: ControlTarget, d: ControlDispatch, opts?: DispatchControlOptions): Promise<{
|
|
199
226
|
status: number;
|
|
200
227
|
}>;
|
|
228
|
+
/**
|
|
229
|
+
* Shell lines that set each pattern into a variable, `<name>_re`. Bash's
|
|
230
|
+
* `=~` matches a quoted pattern as a plain string, so a script quotes it
|
|
231
|
+
* once here and matches against the variable unquoted. The patterns here
|
|
232
|
+
* hold no quote.
|
|
233
|
+
*/
|
|
234
|
+
export declare function shellPatterns(patterns: Record<string, RegExp>): string[];
|
|
201
235
|
/** What {@link controlDispatchScript} takes besides the target. */
|
|
202
236
|
export interface ControlDispatchScriptOptions {
|
|
203
237
|
words?: CiProductWordsInput | CiProductWords;
|
|
@@ -219,6 +253,14 @@ export interface ControlDispatchScriptOptions {
|
|
|
219
253
|
* repo records it and runs the dependents only when something applied.
|
|
220
254
|
*/
|
|
221
255
|
outcome?: boolean;
|
|
256
|
+
/**
|
|
257
|
+
* Carry a train's answer (#5119): the step reads the train, the run, the
|
|
258
|
+
* environment and the release from {@link CONTROL_TRAIN_VAR},
|
|
259
|
+
* {@link CONTROL_RUN_VAR}, {@link CONTROL_ENV_VAR} and
|
|
260
|
+
* {@link CONTROL_RELEASE_VAR}, refuses any that is not usable, and sends
|
|
261
|
+
* them with the outcome. Needs `outcome`.
|
|
262
|
+
*/
|
|
263
|
+
train?: boolean;
|
|
222
264
|
}
|
|
223
265
|
/**
|
|
224
266
|
* The member's step: one request to the control repo's forge with the
|
|
@@ -235,6 +277,11 @@ export declare function controlDispatchScript(target: ControlTarget, opts?: Cont
|
|
|
235
277
|
* and {@link CONTROL_APPLY_OUTCOMES} before they reach a command line. A
|
|
236
278
|
* dispatch that carries an outcome is recorded first (#4617), and its
|
|
237
279
|
* dependents run only when something applied ({@link CONTROL_RUNS_DEPENDENTS}).
|
|
280
|
+
*
|
|
281
|
+
* A dispatch that answers a release train (#5119) runs no dependents: once
|
|
282
|
+
* it is recorded, the train's promote continues from it (`chant workspace
|
|
283
|
+
* train promote <env> <train> --continue`), which dispatches the next member
|
|
284
|
+
* or stops the train, and the job pushes what that wrote.
|
|
238
285
|
*/
|
|
239
286
|
export declare function controlDependentsScript(opts?: {
|
|
240
287
|
command?: string;
|
|
@@ -266,11 +313,16 @@ export interface ControlPipelineSpec {
|
|
|
266
313
|
/** What a person still sets up on the forge. */
|
|
267
314
|
notes: string[];
|
|
268
315
|
}
|
|
316
|
+
/** The variable a train's promote reads one member repository's dispatch token from, and the secret it is kept in (#5119): `CHANT_TRAIN_TOKEN_<MEMBER>`. */
|
|
317
|
+
export declare function trainTokenEnv(member: string): string;
|
|
318
|
+
/** Each member's dispatch token variable mapped from the secret of the same name, refusing two members that would share one. */
|
|
319
|
+
export declare function trainTokenEnvOf(members: readonly string[]): Record<string, string>;
|
|
269
320
|
/** The first chant with `chant workspace run --dependents-of`, which the control repo's package.json pins. terragucci's `CONTROL_CHANT_FLOOR`. */
|
|
270
321
|
export declare const CONTROL_DEPENDENTS_FLOOR = "0.124.47";
|
|
271
322
|
/** The control repo's pipeline for `forge`, in the product's words. */
|
|
272
323
|
export declare function controlPipelineSpec(forge: ForgeKind, wordsIn?: CiProductWordsInput | CiProductWords, opts?: {
|
|
273
324
|
command?: string;
|
|
325
|
+
trainMembers?: readonly string[];
|
|
274
326
|
}): ControlPipelineSpec;
|
|
275
327
|
/** The dispatch job a member's pipeline adds after its last apply on the default branch, forge-neutral. */
|
|
276
328
|
export interface ControlDispatchJobSpec {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dispatch.d.ts","sourceRoot":"","sources":["../../src/control/dispatch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACzD,OAAO,EAA6C,KAAK,cAAc,EAAE,KAAK,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAE/H,sIAAsI;AACtI,eAAO,MAAM,YAAY,QAAwC,CAAC;AAClE,wEAAwE;AACxE,eAAO,MAAM,WAAW,QAAwC,CAAC;AACjE,+DAA+D;AAC/D,eAAO,MAAM,mBAAmB,QAAmC,CAAC;AAEpE,gHAAgH;AAChH,eAAO,MAAM,iBAAiB,wBAAwB,CAAC;AACvD,kIAAkI;AAClI,eAAO,MAAM,sBAAsB,6BAA6B,CAAC;AACjE;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,8DAAuD,CAAC;AAEvF,mFAAmF;AACnF,eAAO,MAAM,oBAAoB,wBAAwB,CAAC;AAC1D,6EAA6E;AAC7E,eAAO,MAAM,yBAAyB,6BAA6B,CAAC;AAEpE,8FAA8F;AAC9F,eAAO,MAAM,kBAAkB,yBAAyB,CAAC;AACzD,eAAO,MAAM,cAAc,qBAAqB,CAAC;AACjD,eAAO,MAAM,eAAe,sBAAsB,CAAC;AAEnD,0JAA0J;AAC1J,eAAO,MAAM,mBAAmB,0BAA0B,CAAC;AAE3D;;;;;;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,EAAE,IAAI,GAAE;IAAE,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,YAAY,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;CAAO,GAAG,mBAAmB,CA6DhM;AAED,2GAA2G;AAC3G,MAAM,WAAW,sBAAsB;IACrC,sBAAsB;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,uBAAuB;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB;;;;;OAKG;IACH,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5B,yDAAyD;IACzD,MAAM,EAAE,MAAM,CAAC;IACf,uEAAuE;IACvE,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,8DAA8D;AAC9D,eAAO,MAAM,oBAAoB,qBAAqB,CAAC;AAEvD;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,aAAa,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,GAAE,4BAAiC,GAAG,sBAAsB,CAa9J;AAED,kGAAkG;AAClG,eAAO,MAAM,eAAe,sBAAsB,CAAC;AAKnD,sEAAsE;AACtE,MAAM,WAAW,mBAAmB;IAClC,uBAAuB;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB;;;;OAIG;IACH,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5B;;;;;;;OAOG;IACH,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,aAAa,EAAE,OAAO,GAAE,mBAAmB,GAAG,cAAmB,GAAG,mBAAmB,CAuC1J"}
|
package/dist/control/dispatch.js
CHANGED
|
@@ -57,6 +57,35 @@ export const CONTROL_OP_VAR = "CHANT_CONTROL_OP";
|
|
|
57
57
|
export const CONTROL_SHA_VAR = "CHANT_CONTROL_SHA";
|
|
58
58
|
/** The variable the apply outcome travels in (#4617): the member's dispatch step reads it, a GitLab trigger sets it, the control repo's step reads it. */
|
|
59
59
|
export const CONTROL_OUTCOME_VAR = "CHANT_CONTROL_OUTCOME";
|
|
60
|
+
/**
|
|
61
|
+
* The variables a train's answer travels in (#5119): the release train and
|
|
62
|
+
* the control repo's run of its promote, the environment, and the release
|
|
63
|
+
* the member ran. A member's train job sets them; its dispatch step reads
|
|
64
|
+
* them; the control repo's step reads them back.
|
|
65
|
+
*/
|
|
66
|
+
export const CONTROL_TRAIN_VAR = "CHANT_CONTROL_TRAIN";
|
|
67
|
+
export const CONTROL_RUN_VAR = "CHANT_CONTROL_RUN";
|
|
68
|
+
export const CONTROL_ENV_VAR = "CHANT_CONTROL_ENV";
|
|
69
|
+
export const CONTROL_RELEASE_VAR = "CHANT_CONTROL_RELEASE";
|
|
70
|
+
/** A release train's id, as `chant workspace train` writes it. */
|
|
71
|
+
export const CONTROL_TRAIN_ID = /^train-[A-Za-z0-9-]{1,64}$/;
|
|
72
|
+
/** A workspace run's id, as `chant workspace train promote` writes it. */
|
|
73
|
+
export const CONTROL_RUN_ID = /^ws-[A-Za-z0-9-]{1,64}$/;
|
|
74
|
+
/** A release digest: `<scheme>:<64 hex digits>`, such as `jcs1-sha256:...`. */
|
|
75
|
+
export const CONTROL_RELEASE_DIGEST = /^[a-z0-9]+(-[a-z0-9]+)*:[0-9a-f]{64}$/;
|
|
76
|
+
/** The problems with a train's answer, or [] when it is usable. */
|
|
77
|
+
export function controlTrainProblems(t) {
|
|
78
|
+
const out = [];
|
|
79
|
+
if (!(typeof t.train === "string" && CONTROL_TRAIN_ID.test(t.train)))
|
|
80
|
+
out.push("train must be a release train's id");
|
|
81
|
+
if (!(typeof t.run === "string" && CONTROL_RUN_ID.test(t.run)))
|
|
82
|
+
out.push("run must be a workspace run's id");
|
|
83
|
+
if (!(typeof t.env === "string" && CONTROL_NAME.test(t.env)))
|
|
84
|
+
out.push("env must be an environment's name");
|
|
85
|
+
if (!(typeof t.releaseDigest === "string" && CONTROL_RELEASE_DIGEST.test(t.releaseDigest)))
|
|
86
|
+
out.push("releaseDigest must be a release digest");
|
|
87
|
+
return out;
|
|
88
|
+
}
|
|
60
89
|
export const CONTROL_APPLY_OUTCOMES = ["applied", "partial", "unchanged", "waiting", "failed"];
|
|
61
90
|
/** The outcomes after which the control repo runs the member's dependents: something applied. A dispatch with no outcome (the pull request loop's, sent on green only) runs them too. */
|
|
62
91
|
export const CONTROL_RUNS_DEPENDENTS = ["applied", "partial"];
|
|
@@ -191,6 +220,17 @@ function checkDispatch(d) {
|
|
|
191
220
|
throw new ControlConfigError(`the dispatch names no commit sha ("${d.sha}")`);
|
|
192
221
|
if (d.outcome !== undefined && !CONTROL_APPLY_OUTCOMES.includes(d.outcome))
|
|
193
222
|
throw new ControlConfigError(`the dispatch's outcome "${d.outcome}" is not one of ${CONTROL_APPLY_OUTCOMES.join(", ")}`);
|
|
223
|
+
if (d.train !== undefined) {
|
|
224
|
+
if (d.outcome === undefined)
|
|
225
|
+
throw new ControlConfigError("a train's answer carries the outcome of the member's run");
|
|
226
|
+
const problems = controlTrainProblems(d.train);
|
|
227
|
+
if (problems.length > 0)
|
|
228
|
+
throw new ControlConfigError(`the dispatch's train fields: ${problems.join(", ")}`);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
/** A train's answer as payload fields (#5119): the same names in a GitHub `client_payload` and Forgejo `inputs`. */
|
|
232
|
+
function trainFields(d) {
|
|
233
|
+
return d.train ? { train: d.train.train, run: d.train.run, env: d.train.env, release: d.train.releaseDigest } : {};
|
|
194
234
|
}
|
|
195
235
|
/**
|
|
196
236
|
* The request that tells the control repo `d.member` applied: GitHub's
|
|
@@ -207,7 +247,7 @@ export function controlDispatchRequest(target, d, wordsIn = {}) {
|
|
|
207
247
|
url: `${target.apiBase}/repos/${target.path}/dispatches`,
|
|
208
248
|
method: "POST",
|
|
209
249
|
headers: { Accept: "application/vnd.github+json", "Content-Type": "application/json" },
|
|
210
|
-
body: { json: { event_type: controlDispatchEvent(wordsIn), client_payload: { member: d.member, op: d.op, sha: d.sha, ...(d.outcome ? { outcome: d.outcome } : {}) } } },
|
|
250
|
+
body: { json: { event_type: controlDispatchEvent(wordsIn), client_payload: { member: d.member, op: d.op, sha: d.sha, ...(d.outcome ? { outcome: d.outcome } : {}), ...trainFields(d) } } },
|
|
211
251
|
token: { in: "header", name: "Authorization", scheme: "Bearer" },
|
|
212
252
|
};
|
|
213
253
|
}
|
|
@@ -223,6 +263,14 @@ export function controlDispatchRequest(target, d, wordsIn = {}) {
|
|
|
223
263
|
[`variables[${CONTROL_OP_VAR}]`, d.op],
|
|
224
264
|
[`variables[${CONTROL_SHA_VAR}]`, d.sha],
|
|
225
265
|
...(d.outcome ? [[`variables[${CONTROL_OUTCOME_VAR}]`, d.outcome]] : []),
|
|
266
|
+
...(d.train
|
|
267
|
+
? [
|
|
268
|
+
[`variables[${CONTROL_TRAIN_VAR}]`, d.train.train],
|
|
269
|
+
[`variables[${CONTROL_RUN_VAR}]`, d.train.run],
|
|
270
|
+
[`variables[${CONTROL_ENV_VAR}]`, d.train.env],
|
|
271
|
+
[`variables[${CONTROL_RELEASE_VAR}]`, d.train.releaseDigest],
|
|
272
|
+
]
|
|
273
|
+
: []),
|
|
226
274
|
],
|
|
227
275
|
},
|
|
228
276
|
token: { in: "form", field: "token" },
|
|
@@ -232,7 +280,7 @@ export function controlDispatchRequest(target, d, wordsIn = {}) {
|
|
|
232
280
|
url: `${target.apiBase}/repos/${target.path}/actions/workflows/${controlPipelineFileName(wordsIn)}/dispatches`,
|
|
233
281
|
method: "POST",
|
|
234
282
|
headers: { Accept: "application/json", "Content-Type": "application/json" },
|
|
235
|
-
body: { json: { ref: target.ref, inputs: { member: d.member, op: d.op, sha: d.sha, ...(d.outcome ? { outcome: d.outcome } : {}) } } },
|
|
283
|
+
body: { json: { ref: target.ref, inputs: { member: d.member, op: d.op, sha: d.sha, ...(d.outcome ? { outcome: d.outcome } : {}), ...trainFields(d) } } },
|
|
236
284
|
token: { in: "header", name: "Authorization", scheme: "token" },
|
|
237
285
|
};
|
|
238
286
|
}
|
|
@@ -284,6 +332,19 @@ export async function dispatchControl(target, d, opts = {}) {
|
|
|
284
332
|
}
|
|
285
333
|
return { status: res.status };
|
|
286
334
|
}
|
|
335
|
+
/**
|
|
336
|
+
* Shell lines that set each pattern into a variable, `<name>_re`. Bash's
|
|
337
|
+
* `=~` matches a quoted pattern as a plain string, so a script quotes it
|
|
338
|
+
* once here and matches against the variable unquoted. The patterns here
|
|
339
|
+
* hold no quote.
|
|
340
|
+
*/
|
|
341
|
+
export function shellPatterns(patterns) {
|
|
342
|
+
return Object.entries(patterns).map(([name, re]) => {
|
|
343
|
+
if (re.source.includes("'"))
|
|
344
|
+
throw new ControlConfigError(`not a pattern a shell word can hold: ${re.source}`);
|
|
345
|
+
return `${name}_re='${re.source}'`;
|
|
346
|
+
});
|
|
347
|
+
}
|
|
287
348
|
/** A value that passed {@link CONTROL_NAME} or {@link CONTROL_REF} is safe in a single-quoted shell word. */
|
|
288
349
|
function sq(v, re) {
|
|
289
350
|
if (!re.test(v))
|
|
@@ -321,13 +382,25 @@ export function controlDispatchScript(target, opts = {}) {
|
|
|
321
382
|
`case "$outcome" in ${CONTROL_APPLY_OUTCOMES.join("|")}) ;; *) echo "${label}: the waves' outcome (\\"$outcome\\") is not one of ${CONTROL_APPLY_OUTCOMES.join(", ")}, so ${target.repo} was not told" >&2; exit 1 ;; esac`,
|
|
322
383
|
]
|
|
323
384
|
: []),
|
|
385
|
+
...(opts.train
|
|
386
|
+
? [
|
|
387
|
+
`train="\${${CONTROL_TRAIN_VAR}:-}"`,
|
|
388
|
+
`run="\${${CONTROL_RUN_VAR}:-}"`,
|
|
389
|
+
`tenv="\${${CONTROL_ENV_VAR}:-}"`,
|
|
390
|
+
`release="\${${CONTROL_RELEASE_VAR}:-}"`,
|
|
391
|
+
...shellPatterns({ train: CONTROL_TRAIN_ID, run: CONTROL_RUN_ID, name: CONTROL_NAME, release: CONTROL_RELEASE_DIGEST }),
|
|
392
|
+
`[[ $train =~ $train_re && $run =~ $run_re && $tenv =~ $name_re && $release =~ $release_re ]] || { echo "${label}: the train's fields are not usable (train=\\"$train\\", run=\\"$run\\", env=\\"$tenv\\", release=\\"$release\\"), so ${target.repo} was not told" >&2; exit 1; }`,
|
|
393
|
+
]
|
|
394
|
+
: []),
|
|
324
395
|
`[ -n "\${${tok}:-}" ] || { echo "${label}: ${tok} is empty; map the ${target.tokenSecret} secret into it, so ${target.repo} can be told" >&2; exit 1; }`,
|
|
325
396
|
...(opts.sentCheck ? [`if [ "$(${opts.sentCheck} 2>/dev/null)" = 1 ]; then echo "${label}: ${target.repo} was told about \${sha:0:8} already"; exit 0; fi`] : []),
|
|
326
397
|
'answer="$(mktemp)"',
|
|
327
398
|
];
|
|
328
399
|
let send;
|
|
400
|
+
if (opts.train && !opts.outcome)
|
|
401
|
+
throw new ControlConfigError("a train's answer carries the outcome of the member's run; set outcome too");
|
|
329
402
|
if ("json" in req.body) {
|
|
330
|
-
const carried = opts.outcome ? `,"outcome":"'"$outcome"'"` : ""
|
|
403
|
+
const carried = `${opts.outcome ? `,"outcome":"'"$outcome"'"` : ""}${opts.train ? `,"train":"'"$train"'","run":"'"$run"'","env":"'"$tenv"'","release":"'"$release"'"` : ""}`;
|
|
331
404
|
const json = target.forge === "github"
|
|
332
405
|
? `{"event_type":"${controlDispatchEvent(words)}","client_payload":{"member":"'"$member"'","op":"'"$op"'","sha":"'"$sha"'"${carried}}}`
|
|
333
406
|
: `{"ref":"${target.ref}","inputs":{"member":"'"$member"'","op":"'"$op"'","sha":"'"$sha"'"${carried}}}`;
|
|
@@ -343,6 +416,14 @@ export function controlDispatchScript(target, opts = {}) {
|
|
|
343
416
|
`--form "variables[${CONTROL_OP_VAR}]=$op"`,
|
|
344
417
|
`--form "variables[${CONTROL_SHA_VAR}]=$sha"`,
|
|
345
418
|
...(opts.outcome ? [`--form "variables[${CONTROL_OUTCOME_VAR}]=$outcome"`] : []),
|
|
419
|
+
...(opts.train
|
|
420
|
+
? [
|
|
421
|
+
`--form "variables[${CONTROL_TRAIN_VAR}]=$train"`,
|
|
422
|
+
`--form "variables[${CONTROL_RUN_VAR}]=$run"`,
|
|
423
|
+
`--form "variables[${CONTROL_ENV_VAR}]=$tenv"`,
|
|
424
|
+
`--form "variables[${CONTROL_RELEASE_VAR}]=$release"`,
|
|
425
|
+
]
|
|
426
|
+
: []),
|
|
346
427
|
];
|
|
347
428
|
send = `code="$(printf '%s' "$${tok}" | curl -sS -o "$answer" -w '%{http_code}' -X POST --form 'token=<-' ${fields.join(" ")} ${sqUrl(req.url)})"`;
|
|
348
429
|
}
|
|
@@ -377,6 +458,11 @@ function recordAppliedLine(label) {
|
|
|
377
458
|
* and {@link CONTROL_APPLY_OUTCOMES} before they reach a command line. A
|
|
378
459
|
* dispatch that carries an outcome is recorded first (#4617), and its
|
|
379
460
|
* dependents run only when something applied ({@link CONTROL_RUNS_DEPENDENTS}).
|
|
461
|
+
*
|
|
462
|
+
* A dispatch that answers a release train (#5119) runs no dependents: once
|
|
463
|
+
* it is recorded, the train's promote continues from it (`chant workspace
|
|
464
|
+
* train promote <env> <train> --continue`), which dispatches the next member
|
|
465
|
+
* or stops the train, and the job pushes what that wrote.
|
|
380
466
|
*/
|
|
381
467
|
export function controlDependentsScript(opts = {}) {
|
|
382
468
|
const label = opts.label ?? "chant";
|
|
@@ -389,12 +475,42 @@ export function controlDependentsScript(opts = {}) {
|
|
|
389
475
|
`re='${CONTROL_NAME.source}'`,
|
|
390
476
|
`[[ $member =~ $re && $op =~ $re ]] || { echo "${label}: the dispatch names no usable member and Op (member=\\"$member\\", op=\\"$op\\")" >&2; exit 2; }`,
|
|
391
477
|
`case "$outcome" in ""|${CONTROL_APPLY_OUTCOMES.join("|")}) ;; *) echo "${label}: the dispatch's outcome (\\"$outcome\\") is not one of ${CONTROL_APPLY_OUTCOMES.join(", ")}" >&2; exit 2 ;; esac`,
|
|
478
|
+
`train="\${${CONTROL_TRAIN_VAR}:-}"`,
|
|
479
|
+
`tenv="\${${CONTROL_ENV_VAR}:-}"`,
|
|
480
|
+
...shellPatterns({ train: CONTROL_TRAIN_ID }),
|
|
481
|
+
`[ -z "$train" ] || [[ $train =~ $train_re && $tenv =~ $re ]] || { echo "${label}: the dispatch names no usable train and environment (train=\\"$train\\", env=\\"$tenv\\")" >&2; exit 2; }`,
|
|
392
482
|
"npm ci",
|
|
393
483
|
recordAppliedLine(label),
|
|
484
|
+
// #5119: a train's answer moves the train on; the member's dependents are not this dispatch's to run.
|
|
485
|
+
`if [ -n "$train" ]; then`,
|
|
486
|
+
` code=0; ${chant} workspace train promote "$tenv" "$train" --continue --json || code=$?`,
|
|
487
|
+
` git push -q origin refs/heads/chant/lifecycle:refs/heads/chant/lifecycle || echo "${label}: the train's records were not pushed to chant/lifecycle" >&2`,
|
|
488
|
+
` exit "$code"`,
|
|
489
|
+
"fi",
|
|
394
490
|
`case "$outcome" in ""|${CONTROL_RUNS_DEPENDENTS.join("|")}) ;; *) echo "${label}: $member's waves ended $outcome and applied nothing, so its dependents do not run"; exit 0 ;; esac`,
|
|
395
491
|
`${chant} workspace run --dependents-of "$member" --op "$op" --json`,
|
|
396
492
|
].join("\n");
|
|
397
493
|
}
|
|
494
|
+
/** The variable a train's promote reads one member repository's dispatch token from, and the secret it is kept in (#5119): `CHANT_TRAIN_TOKEN_<MEMBER>`. */
|
|
495
|
+
export function trainTokenEnv(member) {
|
|
496
|
+
return `CHANT_TRAIN_TOKEN_${member.toUpperCase().replace(/[^A-Z0-9]/g, "_")}`;
|
|
497
|
+
}
|
|
498
|
+
/** Each member's dispatch token variable mapped from the secret of the same name, refusing two members that would share one. */
|
|
499
|
+
export function trainTokenEnvOf(members) {
|
|
500
|
+
const out = {};
|
|
501
|
+
const owner = new Map();
|
|
502
|
+
for (const m of members) {
|
|
503
|
+
if (!CONTROL_NAME.test(m))
|
|
504
|
+
throw new ControlConfigError(`train member "${m}" is not a name the control repo's workspace can hold`);
|
|
505
|
+
const name = trainTokenEnv(m);
|
|
506
|
+
const had = owner.get(name);
|
|
507
|
+
if (had !== undefined && had !== m)
|
|
508
|
+
throw new ControlConfigError(`members ${had} and ${m} would share the dispatch token ${name}; rename one`);
|
|
509
|
+
owner.set(name, m);
|
|
510
|
+
out[name] = `\${{ secrets.${name} }}`;
|
|
511
|
+
}
|
|
512
|
+
return out;
|
|
513
|
+
}
|
|
398
514
|
/** The first chant with `chant workspace run --dependents-of`, which the control repo's package.json pins. terragucci's `CONTROL_CHANT_FLOOR`. */
|
|
399
515
|
export const CONTROL_DEPENDENTS_FLOOR = "0.124.47";
|
|
400
516
|
/** The control repo's pipeline for `forge`, in the product's words. */
|
|
@@ -406,6 +522,7 @@ export function controlPipelineSpec(forge, wordsIn = {}, opts = {}) {
|
|
|
406
522
|
const op = gitlab ? `$${CONTROL_OP_VAR}` : "${{ github.event.client_payload.op || inputs.op }}";
|
|
407
523
|
const sha = gitlab ? `$${CONTROL_SHA_VAR}` : "${{ github.event.client_payload.sha || inputs.sha }}";
|
|
408
524
|
const outcome = "${{ github.event.client_payload.outcome || inputs.outcome }}";
|
|
525
|
+
const payload = (key) => `\${{ github.event.client_payload.${key} || inputs.${key} }}`;
|
|
409
526
|
const bin = words.bin ?? product;
|
|
410
527
|
const notes = [
|
|
411
528
|
`the repo's package.json must pin @intentius/chant at ${CONTROL_DEPENDENTS_FLOOR} or later, which has \`chant workspace run --dependents-of\``,
|
|
@@ -432,8 +549,27 @@ export function controlPipelineSpec(forge, wordsIn = {}, opts = {}) {
|
|
|
432
549
|
op: { description: "The Op to run on them", required: true, type: "string" },
|
|
433
550
|
sha: { description: "The member's commit that applied", required: false, type: "string" },
|
|
434
551
|
outcome: { description: `What the member's waves did: ${CONTROL_APPLY_OUTCOMES.join(", ")}`, required: false, type: "string" },
|
|
552
|
+
train: { description: "The release train the member's run answers, when it ran for one", required: false, type: "string" },
|
|
553
|
+
run: { description: "The run of the train's promote", required: false, type: "string" },
|
|
554
|
+
env: { description: "The environment the train promotes to", required: false, type: "string" },
|
|
555
|
+
release: { description: "The release digest the member ran", required: false, type: "string" },
|
|
556
|
+
},
|
|
557
|
+
env: {
|
|
558
|
+
...(gitlab
|
|
559
|
+
? {}
|
|
560
|
+
: {
|
|
561
|
+
[CONTROL_MEMBER_VAR]: member,
|
|
562
|
+
[CONTROL_OP_VAR]: op,
|
|
563
|
+
[CONTROL_SHA_VAR]: sha,
|
|
564
|
+
[CONTROL_OUTCOME_VAR]: outcome,
|
|
565
|
+
[CONTROL_TRAIN_VAR]: payload("train"),
|
|
566
|
+
[CONTROL_RUN_VAR]: payload("run"),
|
|
567
|
+
[CONTROL_ENV_VAR]: payload("env"),
|
|
568
|
+
[CONTROL_RELEASE_VAR]: payload("release"),
|
|
569
|
+
}),
|
|
570
|
+
// #5119: a train's promote dispatches the next member with that repository's dispatch token.
|
|
571
|
+
...(gitlab || !opts.trainMembers?.length ? {} : { CHANT_TRAIN_PRODUCT: product, ...trainTokenEnvOf(opts.trainMembers) }),
|
|
435
572
|
},
|
|
436
|
-
env: gitlab ? {} : { [CONTROL_MEMBER_VAR]: member, [CONTROL_OP_VAR]: op, [CONTROL_SHA_VAR]: sha, [CONTROL_OUTCOME_VAR]: outcome },
|
|
437
573
|
script: controlDependentsScript({ label: product, ...(opts.command ? { command: opts.command } : {}) }),
|
|
438
574
|
group: `${product}-dependents-${member}`,
|
|
439
575
|
rule: `$CI_PIPELINE_SOURCE == "trigger" && $${CONTROL_MEMBER_VAR} && $${CONTROL_OP_VAR}`,
|