@intentius/chant 0.124.88 → 0.124.89
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 +36 -1
- package/dist/actor.d.ts.map +1 -1
- package/dist/actor.js +39 -1
- package/dist/chant-install.d.ts.map +1 -1
- package/dist/chant-install.js +1 -2
- package/dist/ci-base.d.ts +30 -0
- package/dist/ci-base.d.ts.map +1 -0
- package/dist/ci-base.js +33 -0
- package/dist/ci-comment-commands.d.ts +177 -0
- package/dist/ci-comment-commands.d.ts.map +1 -0
- package/dist/ci-comment-commands.js +325 -0
- package/dist/ci-comment-replies.d.ts +40 -0
- package/dist/ci-comment-replies.d.ts.map +1 -0
- package/dist/ci-comment-replies.js +59 -0
- package/dist/ci-evidence-from-job.d.ts +25 -0
- package/dist/ci-evidence-from-job.d.ts.map +1 -1
- package/dist/ci-evidence-from-job.js +43 -2
- package/dist/ci-evidence-jobs.d.ts +30 -1
- package/dist/ci-evidence-jobs.d.ts.map +1 -1
- package/dist/ci-evidence-jobs.js +46 -3
- package/dist/ci-image.d.ts +21 -4
- package/dist/ci-image.d.ts.map +1 -1
- package/dist/ci-image.js +62 -10
- package/dist/ci-note-commands.d.ts +63 -3
- package/dist/ci-note-commands.d.ts.map +1 -1
- package/dist/ci-note-commands.js +69 -35
- package/dist/ci-product-words.d.ts +42 -0
- package/dist/ci-product-words.d.ts.map +1 -1
- package/dist/ci-product-words.js +25 -0
- package/dist/ci-product.d.ts +31 -0
- package/dist/ci-product.d.ts.map +1 -1
- package/dist/ci-product.js +34 -4
- package/dist/cli/commands/build.d.ts.map +1 -1
- package/dist/cli/commands/build.js +29 -2
- package/dist/cli/handlers/approve.d.ts.map +1 -1
- package/dist/cli/handlers/approve.js +2 -1
- package/dist/cli/handlers/ci-check.d.ts +1 -1
- package/dist/cli/handlers/ci-check.d.ts.map +1 -1
- package/dist/cli/handlers/ci-check.js +17 -7
- package/dist/cli/handlers/ci-evidence.d.ts.map +1 -1
- package/dist/cli/handlers/ci-evidence.js +33 -7
- package/dist/cli/handlers/components.d.ts.map +1 -1
- package/dist/cli/handlers/components.js +3 -1
- package/dist/cli/handlers/generated-check.d.ts +8 -0
- package/dist/cli/handlers/generated-check.d.ts.map +1 -1
- package/dist/cli/handlers/generated-check.js +31 -1
- package/dist/cli/handlers/lock.d.ts.map +1 -1
- package/dist/cli/handlers/lock.js +121 -4
- package/dist/cli/handlers/pr-comment.d.ts +21 -0
- package/dist/cli/handlers/pr-comment.d.ts.map +1 -0
- package/dist/cli/handlers/pr-comment.js +112 -0
- package/dist/cli/handlers/pr-env.d.ts.map +1 -1
- package/dist/cli/handlers/pr-env.js +6 -3
- package/dist/cli/handlers/pr.d.ts +23 -1
- package/dist/cli/handlers/pr.d.ts.map +1 -1
- package/dist/cli/handlers/pr.js +55 -9
- package/dist/cli/handlers/promote.d.ts.map +1 -1
- package/dist/cli/handlers/promote.js +2 -1
- package/dist/cli/handlers/release.d.ts.map +1 -1
- package/dist/cli/handlers/release.js +11 -2
- package/dist/cli/handlers/run-wave.d.ts.map +1 -1
- package/dist/cli/handlers/run-wave.js +28 -2
- package/dist/cli/handlers/run.d.ts.map +1 -1
- package/dist/cli/handlers/run.js +2 -1
- package/dist/cli/main.d.ts.map +1 -1
- package/dist/cli/main.js +24 -2
- package/dist/cli/parse-args.d.ts.map +1 -1
- package/dist/cli/parse-args.js +16 -0
- package/dist/cli/registry.d.ts +11 -0
- package/dist/cli/registry.d.ts.map +1 -1
- package/dist/components/auto-release.d.ts.map +1 -1
- package/dist/components/auto-release.js +2 -1
- package/dist/components/pr-checks.d.ts +70 -6
- package/dist/components/pr-checks.d.ts.map +1 -1
- package/dist/components/pr-checks.js +74 -13
- package/dist/components/pr-pipeline.d.ts +16 -12
- package/dist/components/pr-pipeline.d.ts.map +1 -1
- package/dist/components/pr-pipeline.js +3 -11
- package/dist/components/product-pipeline.d.ts +42 -1
- package/dist/components/product-pipeline.d.ts.map +1 -1
- package/dist/components/product-pipeline.js +64 -12
- package/dist/components/product-plan.d.ts +190 -5
- package/dist/components/product-plan.d.ts.map +1 -1
- package/dist/components/product-plan.js +220 -39
- package/dist/drift-record.d.ts +7 -0
- package/dist/drift-record.d.ts.map +1 -1
- package/dist/drift-record.js +19 -0
- package/dist/floor-table.data.d.ts.map +1 -1
- package/dist/floor-table.data.js +54 -31
- package/dist/forge-check/contract.d.ts +11 -1
- package/dist/forge-check/contract.d.ts.map +1 -1
- package/dist/forge-check/contract.js +4 -1
- package/dist/forge-check/index.d.ts +2 -0
- package/dist/forge-check/index.d.ts.map +1 -1
- package/dist/forge-check/index.js +2 -0
- package/dist/gate-resume-run.d.ts +9 -1
- package/dist/gate-resume-run.d.ts.map +1 -1
- package/dist/gate-resume-run.js +26 -3
- package/dist/generated-check.d.ts +18 -4
- package/dist/generated-check.d.ts.map +1 -1
- package/dist/generated-check.js +37 -5
- package/dist/image-pins.d.ts +26 -0
- package/dist/image-pins.d.ts.map +1 -0
- package/dist/image-pins.js +19 -0
- package/dist/lexicon.d.ts +11 -0
- package/dist/lexicon.d.ts.map +1 -1
- package/dist/lifecycle/git.d.ts +11 -0
- package/dist/lifecycle/git.d.ts.map +1 -1
- package/dist/lifecycle/git.js +30 -3
- package/dist/lifecycle/publish-npm.d.ts +11 -0
- package/dist/lifecycle/publish-npm.d.ts.map +1 -1
- package/dist/lifecycle/publish-npm.js +27 -1
- package/dist/lifecycle/reach-locks.d.ts +131 -0
- package/dist/lifecycle/reach-locks.d.ts.map +1 -0
- package/dist/lifecycle/reach-locks.js +118 -0
- package/dist/lifecycle/release-cut.d.ts +3 -1
- package/dist/lifecycle/release-cut.d.ts.map +1 -1
- package/dist/lifecycle/release-cut.js +15 -0
- package/dist/lifecycle/release-images.d.ts.map +1 -1
- package/dist/lifecycle/release-images.js +1 -2
- package/dist/notify-product.d.ts +12 -3
- package/dist/notify-product.d.ts.map +1 -1
- package/dist/notify-product.js +10 -6
- package/dist/op/activities/source-release.d.ts.map +1 -1
- package/dist/op/activities/source-release.js +2 -1
- package/dist/op/activities/source-rollback.d.ts.map +1 -1
- package/dist/op/activities/source-rollback.js +2 -1
- package/dist/op/index.d.ts +2 -0
- package/dist/op/index.d.ts.map +1 -1
- package/dist/op/index.js +1 -0
- package/dist/op/op-waves-evidence-jobs.d.ts +6 -1
- package/dist/op/op-waves-evidence-jobs.d.ts.map +1 -1
- package/dist/op/op-waves-evidence-jobs.js +9 -3
- package/dist/op/op-waves-render-spec.d.ts +100 -0
- package/dist/op/op-waves-render-spec.d.ts.map +1 -0
- package/dist/op/op-waves-render-spec.js +162 -0
- package/dist/op/op-waves-run.d.ts +2 -0
- package/dist/op/op-waves-run.d.ts.map +1 -1
- package/dist/op/op-waves-run.js +2 -1
- package/dist/op/op-waves.d.ts +4 -0
- package/dist/op/op-waves.d.ts.map +1 -1
- package/dist/op/op-waves.js +4 -1
- package/dist/op/schedule-overdue.d.ts.map +1 -1
- package/dist/op/schedule-overdue.js +59 -3
- package/dist/op/wave-stop.d.ts +64 -0
- package/dist/op/wave-stop.d.ts.map +1 -0
- package/dist/op/wave-stop.js +127 -0
- package/dist/planned-files.d.ts +76 -0
- package/dist/planned-files.d.ts.map +1 -0
- package/dist/planned-files.js +108 -0
- package/dist/pr-forge-job.d.ts +22 -0
- package/dist/pr-forge-job.d.ts.map +1 -0
- package/dist/pr-forge-job.js +46 -0
- package/dist/pr-loop.d.ts +3 -6
- package/dist/pr-loop.d.ts.map +1 -1
- package/dist/pr-loop.js +4 -81
- package/dist/pr-plan-note.d.ts +97 -0
- package/dist/pr-plan-note.d.ts.map +1 -1
- package/dist/pr-plan-note.js +94 -1
- package/dist/pr-post.d.ts +28 -3
- package/dist/pr-post.d.ts.map +1 -1
- package/dist/pr-post.js +145 -13
- package/dist/pr-status.d.ts +16 -0
- package/dist/pr-status.d.ts.map +1 -0
- package/dist/pr-status.js +90 -0
- package/dist/ref-gate-init.d.ts +16 -2
- package/dist/ref-gate-init.d.ts.map +1 -1
- package/dist/ref-gate-init.js +24 -13
- package/dist/release-floors.d.ts +37 -1
- package/dist/release-floors.d.ts.map +1 -1
- package/dist/release-floors.js +61 -25
- package/dist/render-module.d.ts +15 -0
- package/dist/render-module.d.ts.map +1 -0
- package/dist/render-module.js +73 -0
- package/dist/state-migration.d.ts.map +1 -1
- package/dist/state-migration.js +1 -2
- package/dist/wave-runtime.mjs +304 -301
- package/dist/workspace/ci-green-cli.d.ts.map +1 -1
- package/dist/workspace/ci-green-cli.js +3 -2
- package/dist/workspace/release-train.d.ts.map +1 -1
- package/dist/workspace/release-train.js +2 -1
- package/dist/workspace/release-workflow.d.ts +4 -3
- package/dist/workspace/release-workflow.d.ts.map +1 -1
- package/dist/workspace/release-workflow.js +10 -7
- package/dist/workspace/trust/check-evidence-report.d.ts +7 -2
- package/dist/workspace/trust/check-evidence-report.d.ts.map +1 -1
- package/dist/workspace/trust/check-evidence-report.js +15 -8
- package/dist/workspace/trust/ref-gate-cli.d.ts +10 -1
- package/dist/workspace/trust/ref-gate-cli.d.ts.map +1 -1
- package/dist/workspace/trust/ref-gate-cli.js +30 -10
- package/dist/workspace/workspace-run.d.ts.map +1 -1
- package/dist/workspace/workspace-run.js +2 -1
- package/package.json +1 -1
- package/src/actor.test.ts +68 -2
- package/src/actor.ts +61 -1
- package/src/chant-install.test.ts +2 -3
- package/src/chant-install.ts +1 -2
- package/src/ci-base.test.ts +41 -0
- package/src/ci-base.ts +43 -0
- package/src/ci-comment-commands.test.ts +376 -0
- package/src/ci-comment-commands.ts +389 -0
- package/src/ci-comment-replies.ts +78 -0
- package/src/ci-commit.test.ts +2 -3
- package/src/ci-evidence-from-job.test.ts +18 -0
- package/src/ci-evidence-from-job.ts +58 -2
- package/src/ci-evidence-jobs.ts +50 -5
- package/src/ci-image.test.ts +130 -9
- package/src/ci-image.ts +85 -12
- package/src/ci-note-commands.ts +104 -41
- package/src/ci-product-words.ts +59 -0
- package/src/ci-product.ts +40 -4
- package/src/cli/commands/build.test.ts +41 -0
- package/src/cli/commands/build.ts +27 -2
- package/src/cli/handlers/approve.ts +2 -1
- package/src/cli/handlers/ci-check.ts +19 -7
- package/src/cli/handlers/ci-evidence.ts +29 -8
- package/src/cli/handlers/components.ts +3 -1
- package/src/cli/handlers/generated-check.ts +31 -1
- package/src/cli/handlers/lock-reach.test.ts +103 -0
- package/src/cli/handlers/lock.ts +100 -4
- package/src/cli/handlers/pr-comment.ts +104 -0
- package/src/cli/handlers/pr-env.ts +6 -3
- package/src/cli/handlers/pr-record.test.ts +1 -1
- package/src/cli/handlers/pr.ts +50 -10
- package/src/cli/handlers/promote.ts +2 -1
- package/src/cli/handlers/release.e2e.test.ts +35 -0
- package/src/cli/handlers/release.ts +14 -2
- package/src/cli/handlers/run-wave.ts +28 -2
- package/src/cli/handlers/run.ts +2 -1
- package/src/cli/main.ts +24 -2
- package/src/cli/parse-args.ts +12 -0
- package/src/cli/registry.ts +11 -0
- package/src/components/auto-release.ts +2 -1
- package/src/components/pr-checks.ts +112 -17
- package/src/components/pr-pipeline.ts +17 -15
- package/src/components/product-pipeline.ts +93 -11
- package/src/components/product-plan.test.ts +40 -2
- package/src/components/product-plan.ts +331 -45
- package/src/drift-record.test.ts +20 -0
- package/src/drift-record.ts +16 -0
- package/src/floor-table.data.ts +54 -31
- package/src/forge-check/contract.ts +12 -1
- package/src/forge-check/forge-check.test.ts +17 -0
- package/src/forge-check/index.ts +2 -0
- package/src/gate-resume-run.ts +27 -3
- package/src/generated-check.e2e.test.ts +21 -1
- package/src/generated-check.test.ts +66 -0
- package/src/generated-check.ts +51 -10
- package/src/image-pins.ts +31 -0
- package/src/lexicon.ts +11 -0
- package/src/lifecycle/git.test.ts +48 -0
- package/src/lifecycle/git.ts +27 -4
- package/src/lifecycle/publish-npm.ts +31 -1
- package/src/lifecycle/reach-locks.test.ts +87 -0
- package/src/lifecycle/reach-locks.ts +169 -0
- package/src/lifecycle/release-cut.ts +17 -1
- package/src/lifecycle/release-images.test.ts +56 -0
- package/src/lifecycle/release-images.ts +1 -2
- package/src/notify-product.ts +19 -8
- package/src/op/activities/source-release.ts +2 -1
- package/src/op/activities/source-rollback.ts +2 -1
- package/src/op/gate-resume.test.ts +27 -0
- package/src/op/index.ts +10 -0
- package/src/op/op-waves-evidence-jobs.ts +10 -4
- package/src/op/op-waves-notify-words.test.ts +18 -0
- package/src/op/op-waves-render-spec.test.ts +160 -0
- package/src/op/op-waves-render-spec.ts +171 -0
- package/src/op/op-waves-run.ts +2 -1
- package/src/op/op-waves.ts +5 -2
- package/src/op/schedule-overdue.test.ts +43 -0
- package/src/op/schedule-overdue.ts +57 -3
- package/src/op/wave-stop.test.ts +72 -0
- package/src/op/wave-stop.ts +137 -0
- package/src/planned-files.test.ts +80 -0
- package/src/planned-files.ts +134 -0
- package/src/pr-forge-job.test.ts +53 -0
- package/src/pr-forge-job.ts +46 -0
- package/src/pr-loop-narrowed.test.ts +2 -1
- package/src/pr-loop-words.test.ts +2 -1
- package/src/pr-loop.test.ts +1 -2
- package/src/pr-loop.ts +4 -80
- package/src/pr-plan-note.ts +155 -3
- package/src/pr-post-replan.test.ts +144 -0
- package/src/pr-post-subject.test.ts +230 -0
- package/src/pr-post.test.ts +2 -1
- package/src/pr-post.ts +150 -15
- package/src/pr-status.ts +91 -0
- package/src/ref-gate-init.ts +30 -11
- package/src/release-floors.ts +78 -25
- package/src/render-module.ts +73 -0
- package/src/state-migration-record.test.ts +2 -3
- package/src/state-migration.ts +1 -2
- package/src/workspace/ci-green-cli.ts +3 -2
- package/src/workspace/ci-green-workflow.test.ts +32 -1
- package/src/workspace/release-train.ts +2 -1
- package/src/workspace/release-workflow.test.ts +36 -5
- package/src/workspace/release-workflow.ts +10 -7
- package/src/workspace/trust/check-evidence-report.ts +15 -8
- package/src/workspace/trust/check-evidence.test.ts +5 -0
- package/src/workspace/trust/ref-gate-cli.ts +30 -8
- package/src/workspace/trust/ref-gate-pieces.test.ts +46 -1
- package/src/workspace/trust/ref-gate.test.ts +10 -0
- package/src/workspace/workspace-run.ts +2 -1
package/src/ci-evidence-jobs.ts
CHANGED
|
@@ -54,7 +54,7 @@ export const EVIDENCE_ID_TOKEN_VAR = "CHANT_ID_TOKEN_SIGSTORE";
|
|
|
54
54
|
/** The audience a keyless signing job's token is requested for unless told: sigstore's. */
|
|
55
55
|
export const EVIDENCE_DEFAULT_AUDIENCE = "sigstore";
|
|
56
56
|
|
|
57
|
-
export { CHECK_EVIDENCE_FLOOR, CHECK_JOB_FLOOR, GITLAB_OPEN_EVIDENCE_FLOOR, KEYLESS_EVIDENCE_FLOOR, LOCAL_EVIDENCE_FLOOR, PR_LOOP_EVIDENCE_FLOOR, REF_GATE_STATUS_JOB_FLOOR, WAVE_EVIDENCE_JOB_FLOOR } from "./release-floors";
|
|
57
|
+
export { CHECK_EVIDENCE_FLOOR, CHECK_JOB_FLOOR, GITLAB_OPEN_EVIDENCE_FLOOR, GITLAB_WAVE_EVIDENCE_RETRY_FLOOR, GITLAB_WAVE_KEY_SCOPE_FLOOR, KEYLESS_EVIDENCE_FLOOR, LOCAL_EVIDENCE_FLOOR, MEMBER_SIGNED_CHECKS_FLOOR, PR_LOOP_EVIDENCE_FLOOR, REF_GATE_STATUS_JOB_FLOOR, TARGET_SIGNED_CHECKS_FLOOR, WAVE_EVIDENCE_JOB_FLOOR } from "./release-floors";
|
|
58
58
|
|
|
59
59
|
/**
|
|
60
60
|
* The GitLab environment every signing job names (#4914), with `action:
|
|
@@ -79,9 +79,54 @@ export function gitlabOpenEvidenceDir(job: string): string {
|
|
|
79
79
|
* With `noForks`, a merge request from a fork is not signed for, as a
|
|
80
80
|
* product plan with `forks: "skip"` plans none.
|
|
81
81
|
*/
|
|
82
|
-
export function openEvidenceLines(opts: { job: string; dir: string; out: string; bin?: string; noForks?: boolean }): string[] {
|
|
82
|
+
export function openEvidenceLines(opts: { job: string; dir: string; out: string; bin?: string; noForks?: boolean; member?: string }): string[] {
|
|
83
83
|
const chant = opts.bin ?? "chant";
|
|
84
|
-
return [`${chant} ci evidence sign --open --job ${opts.job} --from-report ${opts.dir} --base "$CI_COMMIT_SHA" --output ${opts.out}${opts.noForks ? " --no-forks" : ""}`];
|
|
84
|
+
return [`${chant} ci evidence sign --open --job ${opts.job} --from-report ${opts.dir}${memberFlag(opts.member)} --base "$CI_COMMIT_SHA" --output ${opts.out}${opts.noForks ? " --no-forks" : ""}`];
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* The check a workspace member's pipeline signs for one of the plan job's
|
|
89
|
+
* two (#4964): `plan:<member>`, `policy:<member>`. A member's plan job plans
|
|
90
|
+
* that member alone, so its pass says nothing of another member's plan; a
|
|
91
|
+
* `refs` rule names each member's checks. The root pipeline's are `plan`
|
|
92
|
+
* and `policy`.
|
|
93
|
+
*/
|
|
94
|
+
export function memberEvidenceCheck(check: "plan" | "policy", member?: string): string {
|
|
95
|
+
return member ? `${check}:${member}` : check;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* The check a product plan target's note job signs for one of its plan
|
|
100
|
+
* job's two (#4978): `plan:<target>`, `policy:<target>`. Each target has a
|
|
101
|
+
* plan job of its own, so its pass says nothing of another target's plan,
|
|
102
|
+
* and a `refs` rule names each target's checks. A product plan without
|
|
103
|
+
* targets signs `plan` and `policy`.
|
|
104
|
+
*/
|
|
105
|
+
export function targetEvidenceCheck(check: "plan" | "policy", target?: string): string {
|
|
106
|
+
return memberEvidenceCheck(check, target);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* The checks a product plan's note jobs sign (#4978), in the order a `refs`
|
|
111
|
+
* rule lists them: `plan` and `policy`, or with `targets` each target's
|
|
112
|
+
* `plan:<target>` and `policy:<target>`.
|
|
113
|
+
*/
|
|
114
|
+
export function productPlanEvidenceChecks(targets?: readonly string[]): string[] {
|
|
115
|
+
if (!targets || targets.length === 0) return ["plan", "policy"];
|
|
116
|
+
return targets.flatMap((t) => [targetEvidenceCheck("plan", t), targetEvidenceCheck("policy", t)]);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* The name `--member` takes (#4964): a workspace member's or (#4978) a
|
|
121
|
+
* product plan target's, which a check name carries after `plan:`.
|
|
122
|
+
*/
|
|
123
|
+
export const EVIDENCE_MEMBER_NAME = /^[A-Za-z0-9][A-Za-z0-9_-]*$/;
|
|
124
|
+
|
|
125
|
+
/** ` --member <name>` on a signing line of a member's or a target's plan evidence (#4964, #4978), or nothing. */
|
|
126
|
+
function memberFlag(member: string | undefined): string {
|
|
127
|
+
if (member === undefined) return "";
|
|
128
|
+
if (!EVIDENCE_MEMBER_NAME.test(member)) throw new Error(`the name ${JSON.stringify(member)} is not one a check name can carry: letters, digits, - and _`);
|
|
129
|
+
return ` --member ${member}`;
|
|
85
130
|
}
|
|
86
131
|
|
|
87
132
|
/**
|
|
@@ -133,10 +178,10 @@ export function evidenceKeyEnv(forge: ForgeKind, evidence: PipelineEvidence): Re
|
|
|
133
178
|
* the report directory. `result` is the plan job's result as the shell
|
|
134
179
|
* reads it.
|
|
135
180
|
*/
|
|
136
|
-
export function planEvidenceLines(opts: { dir: string; at: string; base: string; result: string; bin?: string }): string[] {
|
|
181
|
+
export function planEvidenceLines(opts: { dir: string; at: string; base: string; result: string; bin?: string; member?: string }): string[] {
|
|
137
182
|
const chant = opts.bin ?? "chant";
|
|
138
183
|
return [
|
|
139
184
|
`git fetch --quiet --no-tags --depth=1 origin ${opts.at} || true`,
|
|
140
|
-
`${chant} ci evidence sign --from-report ${opts.dir} --result ${opts.result} --at ${opts.at} --base ${opts.base}`,
|
|
185
|
+
`${chant} ci evidence sign --from-report ${opts.dir}${memberFlag(opts.member)} --result ${opts.result} --at ${opts.at} --base ${opts.base}`,
|
|
141
186
|
];
|
|
142
187
|
}
|
package/src/ci-image.test.ts
CHANGED
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
CI_IMAGE_DOCKER_STAGES_FLOOR,
|
|
11
11
|
CI_IMAGE_FLOOR,
|
|
12
12
|
CI_IMAGE_NON_ROOT_FLOOR,
|
|
13
|
+
CI_TOOL_NODE_DOWNLOAD_FLOOR,
|
|
13
14
|
CI_TOOL_DOCKER_ARCH,
|
|
14
15
|
CI_TOOL_SHA256,
|
|
15
16
|
CI_TOOLS,
|
|
@@ -57,8 +58,8 @@ function tarGz(files: Record<string, string>): Uint8Array {
|
|
|
57
58
|
return gzipSync(Buffer.concat(blocks));
|
|
58
59
|
}
|
|
59
60
|
|
|
60
|
-
/** A zip of `files`, deflated, with a central directory, as a release's `.zip` holds them. */
|
|
61
|
-
function zip(files: Record<string, string>): Uint8Array {
|
|
61
|
+
/** A zip of `files`, deflated, with a central directory, as a release's `.zip` holds them; `modes` gives an entry its Unix mode, as the AWS CLI's installer has. */
|
|
62
|
+
function zip(files: Record<string, string>, modes: Record<string, number> = {}): Uint8Array {
|
|
62
63
|
const locals: Buffer[] = [];
|
|
63
64
|
const centrals: Buffer[] = [];
|
|
64
65
|
let offset = 0;
|
|
@@ -83,6 +84,11 @@ function zip(files: Record<string, string>): Uint8Array {
|
|
|
83
84
|
central.writeUInt32LE(data.length, 20);
|
|
84
85
|
central.writeUInt32LE(raw.length, 24);
|
|
85
86
|
central.writeUInt16LE(n.length, 28);
|
|
87
|
+
if (modes[name] !== undefined) {
|
|
88
|
+
// Made by Unix (3), with the mode in the external attributes' high half.
|
|
89
|
+
central.writeUInt16LE((3 << 8) | 20, 4);
|
|
90
|
+
central.writeUInt32LE(((0o100000 | modes[name]!) << 16) >>> 0, 38);
|
|
91
|
+
}
|
|
86
92
|
central.writeUInt32LE(offset, 42);
|
|
87
93
|
locals.push(local, n, data);
|
|
88
94
|
centrals.push(central, n);
|
|
@@ -134,6 +140,40 @@ function runShell(script: string, fixtures: Record<string, Uint8Array | string>,
|
|
|
134
140
|
return { status: r.status ?? -1, stderr: r.stderr, urls: existsSync(log) ? readFileSync(log, "utf-8").trim().split("\n") : [] };
|
|
135
141
|
}
|
|
136
142
|
|
|
143
|
+
/**
|
|
144
|
+
* Runs a fetch script as a job with no curl and no unzip would (#4952):
|
|
145
|
+
* both are on PATH as commands that fail, and node's `fetch` is replaced,
|
|
146
|
+
* through `NODE_OPTIONS=--import`, by one that serves the fixtures by the
|
|
147
|
+
* URL's last segment.
|
|
148
|
+
*/
|
|
149
|
+
function runNodeShell(script: string, fixtures: Record<string, Uint8Array | string>, env: Record<string, string> = {}): { status: number; stderr: string; urls: string[] } {
|
|
150
|
+
const dir = tmp();
|
|
151
|
+
const serve = join(dir, "serve");
|
|
152
|
+
const bin = join(dir, "bin");
|
|
153
|
+
mkdirSync(serve);
|
|
154
|
+
mkdirSync(bin);
|
|
155
|
+
for (const [name, body] of Object.entries(fixtures)) writeFileSync(join(serve, name), body);
|
|
156
|
+
const log = join(dir, "urls");
|
|
157
|
+
for (const missing of ["curl", "unzip"]) {
|
|
158
|
+
writeFileSync(join(bin, missing), `#!/bin/sh\necho "${missing}: not in this image" >&2\nexit 127\n`);
|
|
159
|
+
chmodSync(join(bin, missing), 0o755);
|
|
160
|
+
}
|
|
161
|
+
const preload = join(dir, "fetch.mjs");
|
|
162
|
+
writeFileSync(
|
|
163
|
+
preload,
|
|
164
|
+
[
|
|
165
|
+
'import { appendFileSync, existsSync, readFileSync } from "node:fs";',
|
|
166
|
+
"globalThis.fetch = async (url) => {",
|
|
167
|
+
` appendFileSync(${JSON.stringify(log)}, String(url) + "\\n");`,
|
|
168
|
+
` const f = ${JSON.stringify(serve)} + "/" + String(url).split("/").pop();`,
|
|
169
|
+
' return existsSync(f) ? new Response(readFileSync(f)) : new Response("not found", { status: 404 });',
|
|
170
|
+
"};",
|
|
171
|
+
].join("\n"),
|
|
172
|
+
);
|
|
173
|
+
const r = spawnSync("sh", ["-c", `set -e; ${script}`], { env: { ...process.env, PATH: `${bin}:${process.env.PATH}`, NODE_OPTIONS: `--import ${preload}`, ...env }, encoding: "utf-8" });
|
|
174
|
+
return { status: r.status ?? -1, stderr: r.stderr, urls: existsSync(log) ? readFileSync(log, "utf-8").trim().split("\n") : [] };
|
|
175
|
+
}
|
|
176
|
+
|
|
137
177
|
describe("ciToolRelease", () => {
|
|
138
178
|
test("names each release file and its checksums file per architecture", () => {
|
|
139
179
|
expect(ciToolRelease("tofu", "1.13.1", "arm64")).toMatchObject({
|
|
@@ -165,10 +205,11 @@ describe("ciToolRelease", () => {
|
|
|
165
205
|
expect(() => ciToolSha256("tofu", "1.13.1", { amd64: "nothex" })).toThrow(/64 lower-case hex/);
|
|
166
206
|
});
|
|
167
207
|
|
|
168
|
-
test("CI_IMAGE_FLOOR is the release that shipped it, and #4908's and #4932's floors
|
|
208
|
+
test("CI_IMAGE_FLOOR is the release that shipped it, and #4908's and #4932's floors theirs", () => {
|
|
169
209
|
expect(CI_IMAGE_FLOOR).toBe("0.124.86");
|
|
170
|
-
expect(CI_IMAGE_NON_ROOT_FLOOR).toBe(
|
|
171
|
-
expect(CI_IMAGE_DOCKER_STAGES_FLOOR).toBe(
|
|
210
|
+
expect(CI_IMAGE_NON_ROOT_FLOOR).toBe("0.124.88");
|
|
211
|
+
expect(CI_IMAGE_DOCKER_STAGES_FLOOR).toBe("0.124.88");
|
|
212
|
+
expect(CI_TOOL_NODE_DOWNLOAD_FLOOR).toBe(NEXT_RELEASE);
|
|
172
213
|
});
|
|
173
214
|
});
|
|
174
215
|
|
|
@@ -231,11 +272,12 @@ describe("ciToolFetchScript against local fixtures", () => {
|
|
|
231
272
|
const binary = Buffer.from("#!/bin/sh\necho just\n");
|
|
232
273
|
const archiveJust = tarGz({ just: binary.toString() });
|
|
233
274
|
const out = tmp();
|
|
234
|
-
|
|
275
|
+
// just publishes a checksums file from 1.35.0 (#4952), so an older release is checked on its recorded sha256.
|
|
276
|
+
const script = ciToolFetchScript("just", "1.34.0", { dir: `${out}/d`, arch: CI_TOOL_DOCKER_ARCH, sha256: { amd64: sha(archiveJust), arm64: "2".repeat(64) } });
|
|
235
277
|
expect(script).not.toContain("sums");
|
|
236
|
-
expect(runShell(script, { "just-1.
|
|
278
|
+
expect(runShell(script, { "just-1.34.0-x86_64-unknown-linux-musl.tar.gz": archiveJust }, { TARGETARCH: "amd64" }).status).toBe(0);
|
|
237
279
|
expect(readFileSync(`${out}/d/just`, "utf-8")).toContain("echo just");
|
|
238
|
-
const r = runShell(script, { "just-1.
|
|
280
|
+
const r = runShell(script, { "just-1.34.0-aarch64-unknown-linux-musl.tar.gz": archiveJust }, { TARGETARCH: "arm64" });
|
|
239
281
|
expect(r.status).not.toBe(0);
|
|
240
282
|
});
|
|
241
283
|
|
|
@@ -261,7 +303,7 @@ describe("ciToolFetchScript against local fixtures", () => {
|
|
|
261
303
|
});
|
|
262
304
|
|
|
263
305
|
test("refuses, before any shell, a release that needs a recorded sha256 it lacks", () => {
|
|
264
|
-
expect(() => ciToolFetchScript("
|
|
306
|
+
expect(() => ciToolFetchScript("just", "1.34.0", { dir: "/out/just" })).toThrow(/no recorded sha256 for just 1.34.0 on amd64 and arm64; just's release publishes no checksums file/);
|
|
265
307
|
expect(() => ciToolFetchScript("terragrunt", "1.1.0", { dir: "/out/tg", requirePin: true })).toThrow(/no recorded sha256 for terragrunt 1.1.0/);
|
|
266
308
|
expect(() => ciToolFetchScript("tofu", "1.13.1", { dir: "/out/x y" })).toThrow(/absolute path/);
|
|
267
309
|
});
|
|
@@ -335,6 +377,85 @@ describe("non-root job lines (#4908)", () => {
|
|
|
335
377
|
});
|
|
336
378
|
});
|
|
337
379
|
|
|
380
|
+
describe("a job with no curl or unzip (#4952)", () => {
|
|
381
|
+
test("download: node fetches and checks a release with node, and the line names neither tool", () => {
|
|
382
|
+
const a = tarGz({ tofu: "#!/bin/sh\necho node-fetched\n" });
|
|
383
|
+
const root = tmp();
|
|
384
|
+
const line = ciToolInstallLine("tofu", "1.13.1", { root, link: false, download: "node", sha256: { amd64: sha(a), arm64: sha(a) } });
|
|
385
|
+
expect(line).not.toMatch(/\bcurl\b|\bunzip\b/);
|
|
386
|
+
const files = { "tofu_1.13.1_linux_amd64.tar.gz": a, "tofu_1.13.1_linux_arm64.tar.gz": a, "tofu_1.13.1_SHA256SUMS": `${sha(a)} tofu_1.13.1_linux_amd64.tar.gz\n${sha(a)} tofu_1.13.1_linux_arm64.tar.gz\n` };
|
|
387
|
+
const r = runNodeShell(line, files);
|
|
388
|
+
expect(r.stderr).toBe("");
|
|
389
|
+
expect(r.status).toBe(0);
|
|
390
|
+
expect(readFileSync(`${root}/tofu-1.13.1/tofu`, "utf-8")).toContain("echo node-fetched");
|
|
391
|
+
expect(r.urls).toHaveLength(2);
|
|
392
|
+
});
|
|
393
|
+
|
|
394
|
+
test("download: node fails a tampered archive and a missing file, and installs nothing", () => {
|
|
395
|
+
const a = tarGz({ tofu: "#!/bin/sh\n" });
|
|
396
|
+
const out = tmp();
|
|
397
|
+
const script = ciToolFetchScript("tofu", "1.13.1", { dir: `${out}/d`, arch: CI_TOOL_DOCKER_ARCH, download: "node", sha256: { amd64: sha(a), arm64: sha(a) } });
|
|
398
|
+
const sums = `${sha(a)} tofu_1.13.1_linux_amd64.tar.gz\n`;
|
|
399
|
+
expect(runNodeShell(script, { "tofu_1.13.1_linux_amd64.tar.gz": tarGz({ tofu: "evil" }), "tofu_1.13.1_SHA256SUMS": sums }, { TARGETARCH: "amd64" }).status).not.toBe(0);
|
|
400
|
+
const missing = runNodeShell(script, { "tofu_1.13.1_SHA256SUMS": sums }, { TARGETARCH: "amd64" });
|
|
401
|
+
expect(missing.status).not.toBe(0);
|
|
402
|
+
expect(missing.stderr).toContain("tofu_1.13.1_linux_amd64.tar.gz: HTTP 404");
|
|
403
|
+
expect(existsSync(`${out}/d/tofu`)).toBe(false);
|
|
404
|
+
});
|
|
405
|
+
|
|
406
|
+
test("download: node unpacks a zip's member, and the AWS CLI's whole zip for its installer", () => {
|
|
407
|
+
const out = tmp();
|
|
408
|
+
const z = zip({ terraform: "#!/bin/sh\necho terraform\n", "LICENSE.txt": "x" });
|
|
409
|
+
const s1 = ciToolFetchScript("terraform", "1.14.8", { dir: `${out}/tf`, arch: CI_TOOL_DOCKER_ARCH, download: "node" });
|
|
410
|
+
const r1 = runNodeShell(s1, { "terraform_1.14.8_linux_amd64.zip": z, "terraform_1.14.8_SHA256SUMS": `${sha(z)} terraform_1.14.8_linux_amd64.zip\n` }, { TARGETARCH: "amd64" });
|
|
411
|
+
expect(r1.stderr).toBe("");
|
|
412
|
+
expect(readFileSync(`${out}/tf/terraform`, "utf-8")).toContain("echo terraform");
|
|
413
|
+
|
|
414
|
+
// The installer writes the binary where `-i` points, as the AWS CLI's does.
|
|
415
|
+
const installer = '#!/bin/sh\nmkdir -p "$2/v2/current/bin"\ncp "$(dirname "$0")/dist/aws" "$2/v2/current/bin/aws"\n';
|
|
416
|
+
const aws = zip({ "aws/": "", "aws/install": installer, "aws/dist/aws": "#!/bin/sh\necho aws-cli\n" }, { "aws/install": 0o755, "aws/dist/aws": 0o755 });
|
|
417
|
+
const root = tmp();
|
|
418
|
+
const line = ciToolInstallLine("aws-cli", "2.37.9", { root, link: false, download: "node", sha256: { amd64: sha(aws), arm64: sha(aws) } });
|
|
419
|
+
expect(line).not.toMatch(/\bcurl\b|\bunzip\b/);
|
|
420
|
+
const r2 = runNodeShell(line, { "awscli-exe-linux-x86_64-2.37.9.zip": aws, "awscli-exe-linux-aarch64-2.37.9.zip": aws });
|
|
421
|
+
expect(r2.stderr).toBe("");
|
|
422
|
+
expect(r2.status).toBe(0);
|
|
423
|
+
expect(spawnSync(`${root}/aws-cli-2.37.9/v2/current/bin/aws`, { encoding: "utf-8" }).stdout).toBe("aws-cli\n");
|
|
424
|
+
});
|
|
425
|
+
|
|
426
|
+
test("curl stays the default, and download names curl or node only", () => {
|
|
427
|
+
expect(ciToolInstallLine("tofu", "1.13.1")).toContain("curl -fsSLo");
|
|
428
|
+
expect(() => ciToolFetchScript("tofu", "1.13.1", { dir: "/out/t", download: "wget" as never })).toThrow(/download is curl or node/);
|
|
429
|
+
});
|
|
430
|
+
});
|
|
431
|
+
|
|
432
|
+
describe("just's and act's checksums files and recorded sums (#4952)", () => {
|
|
433
|
+
test("just 1.36.0 and act 0.2.89 are recorded, copied from the releases' checksums files", () => {
|
|
434
|
+
expect(ciToolSha256("just", "1.36.0")).toEqual({ amd64: "bc7c9f377944f8de9cd0418b11d2955adebfa25a488c0b5e3dd2d2c0e9d732da", arm64: "bb3886b15e2cbcb9c0eb19956297d36de4eaef45b89d3f5fa5d1fc4ed3b5b51d" });
|
|
435
|
+
expect(ciToolSha256("act", "0.2.89")).toEqual({ amd64: "0191d6f1f3b716b5c55820032605d05fc3c1cdbf581ebeff655019e5dd1524c0", arm64: "daa8679ba9615a74d2d0cec321dc593f21948a2a11bb65862b063d8b930f4bcb" });
|
|
436
|
+
expect(() => ciToolInstallLine("just", "1.36.0", { requirePin: true })).not.toThrow();
|
|
437
|
+
expect(() => ciToolInstallLine("act", "0.2.89", { requirePin: true })).not.toThrow();
|
|
438
|
+
});
|
|
439
|
+
|
|
440
|
+
test("each is checked against its release's checksums file: just's per file to 1.36.0, SHA256SUMS from 1.37.0, act's checksums.txt", () => {
|
|
441
|
+
expect(ciToolRelease("just", "1.36.0", "amd64").checksumsUrl).toBe("https://github.com/casey/just/releases/download/1.36.0/just-1.36.0-x86_64-unknown-linux-musl.tar.gz.sha256sum");
|
|
442
|
+
expect(ciToolRelease("just", "1.35.0", "arm64").checksums).toBe("just-1.35.0-aarch64-unknown-linux-musl.tar.gz.sha256sum");
|
|
443
|
+
expect(ciToolRelease("just", "1.37.0", "amd64").checksumsUrl).toBe("https://github.com/casey/just/releases/download/1.37.0/SHA256SUMS");
|
|
444
|
+
expect(ciToolRelease("just", "1.34.0", "amd64").checksumsUrl).toBeUndefined();
|
|
445
|
+
expect(ciToolRelease("act", "0.2.89", "arm64").checksumsUrl).toBe("https://github.com/nektos/act/releases/download/v0.2.89/checksums.txt");
|
|
446
|
+
});
|
|
447
|
+
|
|
448
|
+
test("the shell reads just's per-file checksums file", () => {
|
|
449
|
+
const a = tarGz({ just: "#!/bin/sh\necho just\n" });
|
|
450
|
+
const out = tmp();
|
|
451
|
+
const s = ciToolFetchScript("just", "1.36.0", { dir: `${out}/j`, arch: CI_TOOL_DOCKER_ARCH, sha256: { amd64: sha(a), arm64: sha(a) } });
|
|
452
|
+
const r = runShell(s, { "just-1.36.0-x86_64-unknown-linux-musl.tar.gz": a, "just-1.36.0-x86_64-unknown-linux-musl.tar.gz.sha256sum": `${sha(a)} just-1.36.0-x86_64-unknown-linux-musl.tar.gz\n` }, { TARGETARCH: "amd64" });
|
|
453
|
+
expect(r.stderr).toBe("");
|
|
454
|
+
expect(r.urls[1]).toBe("https://github.com/casey/just/releases/download/1.36.0/just-1.36.0-x86_64-unknown-linux-musl.tar.gz.sha256sum");
|
|
455
|
+
expect(readFileSync(`${out}/j/just`, "utf-8")).toContain("echo just");
|
|
456
|
+
});
|
|
457
|
+
});
|
|
458
|
+
|
|
338
459
|
describe("installCiTool", () => {
|
|
339
460
|
const a = tarGz({ tofu: "#!/bin/sh\necho node-install\n" });
|
|
340
461
|
const base = "https://github.com/opentofu/opentofu/releases/download/v1.13.1";
|
package/src/ci-image.ts
CHANGED
|
@@ -18,7 +18,8 @@
|
|
|
18
18
|
* checks it, for an image's fetch stage; {@link ciToolInstallLine} is the
|
|
19
19
|
* job line that runs it unless the binary is there (with `sudo`, or under
|
|
20
20
|
* a root such as `$RUNNER_TEMP/chant-tools`, for a job that is not root,
|
|
21
|
-
* #4908)
|
|
21
|
+
* #4908). With `download: "node"` both fetch and unpack with node, for
|
|
22
|
+
* an image with no curl or unzip (#4952). {@link installCiTool} does the same from Node, for a product
|
|
22
23
|
* that installs a pinned release at run time.
|
|
23
24
|
* - {@link productImageStages} is a product's image as stages a Dockerfile
|
|
24
25
|
* takes (the docker lexicon's `new Dockerfile({ stages })`), and
|
|
@@ -31,7 +32,7 @@
|
|
|
31
32
|
* project publishes a checksums file is checked against that file's line
|
|
32
33
|
* for the archive, and against the recorded sha256 when there is one, so a
|
|
33
34
|
* tampered checksums file fails as a tampered archive does. A release with
|
|
34
|
-
* no checksums file (the AWS CLI, just
|
|
35
|
+
* no checksums file (the AWS CLI, just before 1.35.0) needs a recorded sha256. An
|
|
35
36
|
* image always needs a recorded sha256 for both architectures, and a caller
|
|
36
37
|
* passes `requirePin` to ask the same of a job line or a run-time install.
|
|
37
38
|
*
|
|
@@ -47,9 +48,9 @@ import { tmpdir } from "node:os";
|
|
|
47
48
|
import { join } from "node:path";
|
|
48
49
|
import { gunzipSync, inflateRawSync } from "node:zlib";
|
|
49
50
|
import { tarEntry } from "./policy-engine";
|
|
50
|
-
import { CI_IMAGE_DOCKER_STAGES_FLOOR, CI_IMAGE_FLOOR, CI_IMAGE_NON_ROOT_FLOOR } from "./release-floors";
|
|
51
|
+
import { CI_IMAGE_DOCKER_STAGES_FLOOR, CI_IMAGE_FLOOR, CI_IMAGE_NON_ROOT_FLOOR, CI_TOOL_NODE_DOWNLOAD_FLOOR } from "./release-floors";
|
|
51
52
|
|
|
52
|
-
export { CI_IMAGE_DOCKER_STAGES_FLOOR, CI_IMAGE_FLOOR, CI_IMAGE_NON_ROOT_FLOOR };
|
|
53
|
+
export { CI_IMAGE_DOCKER_STAGES_FLOOR, CI_IMAGE_FLOOR, CI_IMAGE_NON_ROOT_FLOOR, CI_TOOL_NODE_DOWNLOAD_FLOOR };
|
|
53
54
|
|
|
54
55
|
// ---------------------------------------------------------------------------
|
|
55
56
|
// Engine releases
|
|
@@ -88,8 +89,8 @@ interface ToolSpec {
|
|
|
88
89
|
words: Record<CiToolArch, string>;
|
|
89
90
|
base(version: string): string;
|
|
90
91
|
asset(version: string, word: string): string;
|
|
91
|
-
/** The checksums file, beside the asset under `base`; absent when the release publishes none. */
|
|
92
|
-
checksums?(version: string, asset: string): string;
|
|
92
|
+
/** The checksums file, beside the asset under `base`; absent, or undefined for a version, when the release publishes none. */
|
|
93
|
+
checksums?(version: string, asset: string): string | undefined;
|
|
93
94
|
layout: CiToolLayout;
|
|
94
95
|
/** The binary inside the archive, for `tar.gz` and `zip`. Default `bin`. */
|
|
95
96
|
member?(word: string): string;
|
|
@@ -97,6 +98,12 @@ interface ToolSpec {
|
|
|
97
98
|
path?: string;
|
|
98
99
|
}
|
|
99
100
|
|
|
101
|
+
/** Whether a release version is at least `major.minor`. */
|
|
102
|
+
function atLeast(version: string, major: number, minor: number): boolean {
|
|
103
|
+
const [a = 0, b = 0] = version.split(".").map((n) => Number.parseInt(n, 10));
|
|
104
|
+
return a > major || (a === major && b >= minor);
|
|
105
|
+
}
|
|
106
|
+
|
|
100
107
|
const STD = { amd64: "amd64", arm64: "arm64" };
|
|
101
108
|
const GNU = { amd64: "x86_64", arm64: "aarch64" };
|
|
102
109
|
const NODE_WORDS = { amd64: "x64", arm64: "arm64" };
|
|
@@ -197,6 +204,8 @@ const TOOLS: Record<CiTool, ToolSpec> = {
|
|
|
197
204
|
words: GNU,
|
|
198
205
|
base: (v) => `https://github.com/casey/just/releases/download/${v}`,
|
|
199
206
|
asset: (v, w) => `just-${v}-${w}-unknown-linux-musl.tar.gz`,
|
|
207
|
+
// #4952: just publishes `SHA256SUMS` from 1.37.0, one `<file>.sha256sum` per file in 1.35.0 and 1.36.0, and none before.
|
|
208
|
+
checksums: (v, asset) => (atLeast(v, 1, 37) ? "SHA256SUMS" : atLeast(v, 1, 35) ? `${asset}.sha256sum` : undefined),
|
|
200
209
|
layout: "tar.gz",
|
|
201
210
|
},
|
|
202
211
|
act: {
|
|
@@ -204,6 +213,7 @@ const TOOLS: Record<CiTool, ToolSpec> = {
|
|
|
204
213
|
words: { amd64: "x86_64", arm64: "arm64" },
|
|
205
214
|
base: (v) => `https://github.com/nektos/act/releases/download/v${v}`,
|
|
206
215
|
asset: (_v, w) => `act_Linux_${w}.tar.gz`,
|
|
216
|
+
checksums: () => "checksums.txt",
|
|
207
217
|
layout: "tar.gz",
|
|
208
218
|
},
|
|
209
219
|
};
|
|
@@ -239,6 +249,14 @@ export const CI_TOOL_SHA256: Readonly<Record<string, string>> = {
|
|
|
239
249
|
"terragrunt-1.2.0-linux-arm64": "b069ce4310572bc46ee6f057057acc4bc6a9077ef8687e157a64b0551290a371",
|
|
240
250
|
"aws-cli-2.37.9-linux-amd64": "6b3a6a3d7bb3997928f0bdf7b866914224abf242c2e54e1dcebbe84bee64f356",
|
|
241
251
|
"aws-cli-2.37.9-linux-arm64": "e7d2cca3622af4765871fe9ce7eeed03acd09dca10a99ebc46e92f79d78765c0",
|
|
252
|
+
// #4952: terragucci's just and act pins (its workflows/shared.ts), read on 2026-11-10 from
|
|
253
|
+
// https://github.com/casey/just/releases/download/1.36.0/just-1.36.0-{x86_64,aarch64}-unknown-linux-musl.tar.gz.sha256sum
|
|
254
|
+
// and https://github.com/nektos/act/releases/download/v0.2.89/checksums.txt.
|
|
255
|
+
// squawk is not here: its releases publish no checksums file, only bare binaries, and no product pins a release.
|
|
256
|
+
"just-1.36.0-linux-amd64": "bc7c9f377944f8de9cd0418b11d2955adebfa25a488c0b5e3dd2d2c0e9d732da",
|
|
257
|
+
"just-1.36.0-linux-arm64": "bb3886b15e2cbcb9c0eb19956297d36de4eaef45b89d3f5fa5d1fc4ed3b5b51d",
|
|
258
|
+
"act-0.2.89-linux-amd64": "0191d6f1f3b716b5c55820032605d05fc3c1cdbf581ebeff655019e5dd1524c0",
|
|
259
|
+
"act-0.2.89-linux-arm64": "daa8679ba9615a74d2d0cec321dc593f21948a2a11bb65862b063d8b930f4bcb",
|
|
242
260
|
};
|
|
243
261
|
|
|
244
262
|
/** One release file of one tool for one architecture. */
|
|
@@ -349,6 +367,48 @@ export interface CiToolCheckOptions {
|
|
|
349
367
|
requirePin?: boolean;
|
|
350
368
|
}
|
|
351
369
|
|
|
370
|
+
/**
|
|
371
|
+
* How a fetch line downloads and unpacks a release (#4952): `curl` (the
|
|
372
|
+
* default) with `unzip` for a zip, or `node`, which downloads with node's
|
|
373
|
+
* `fetch` and unpacks a zip with node, for a job whose image carries node
|
|
374
|
+
* but neither curl nor unzip. The check is the same either way; tar,
|
|
375
|
+
* sha256sum and sed are still the image's.
|
|
376
|
+
*/
|
|
377
|
+
export type CiToolDownload = "curl" | "node";
|
|
378
|
+
|
|
379
|
+
/** The download line's script for `download: "node"`: `node -e <it> <url> <file>`. A failed answer exits 1 naming the URL and the status. */
|
|
380
|
+
const NODE_FETCH_JS =
|
|
381
|
+
'const [u,o]=process.argv.slice(1);fetch(u).then(async(r)=>{if(!r.ok)throw new Error(u+": HTTP "+r.status);require("fs").writeFileSync(o,Buffer.from(await r.arrayBuffer()))}).catch((e)=>{console.error(e.message);process.exit(1)})';
|
|
382
|
+
|
|
383
|
+
/**
|
|
384
|
+
* The unpack line's script for `download: "node"`: `node -e <it> <zip>
|
|
385
|
+
* <dir> [member]`, every entry (or the one member) written under `dir`
|
|
386
|
+
* with its executable bit and symbolic links kept, as the AWS CLI's
|
|
387
|
+
* installer needs. Stored and deflated entries only, as {@link unzipEntry}
|
|
388
|
+
* reads them; an entry whose path leaves `dir` fails the line. Written with
|
|
389
|
+
* no single quote or `$`, so it goes inside the shell's single quotes as it is.
|
|
390
|
+
*/
|
|
391
|
+
const NODE_UNZIP_JS = [
|
|
392
|
+
'const fs=require("fs"),p=require("path"),z=require("zlib");const [f,d,m]=process.argv.slice(1);const b=fs.readFileSync(f);',
|
|
393
|
+
'let e=b.length-22;while(e>=0&&b.readUInt32LE(e)!==0x06054b50)e--;if(e<0)throw new Error(f+" is not a zip archive");',
|
|
394
|
+
"const top=p.resolve(d);let o=b.readUInt32LE(e+16),hit=false;",
|
|
395
|
+
"for(let i=b.readUInt16LE(e+10);i>0;i--){",
|
|
396
|
+
'const meth=b.readUInt16LE(o+10),size=b.readUInt32LE(o+20),nl=b.readUInt16LE(o+28),xl=b.readUInt16LE(o+30),cl=b.readUInt16LE(o+32),mode=b.readUInt32LE(o+38)>>>16,l=b.readUInt32LE(o+42),n=b.toString("utf8",o+46,o+46+nl);',
|
|
397
|
+
"o+=46+nl+xl+cl;if(m&&n!==m)continue;hit=true;",
|
|
398
|
+
'const t=p.resolve(top,n);if(t!==top&&!t.startsWith(top+p.sep))throw new Error(n+" is outside "+d);',
|
|
399
|
+
'if(n.endsWith("/")){fs.mkdirSync(t,{recursive:true});continue}',
|
|
400
|
+
"const s=l+30+b.readUInt16LE(l+26)+b.readUInt16LE(l+28),raw=b.subarray(s,s+size),data=meth===0?raw:meth===8?z.inflateRawSync(raw):null;",
|
|
401
|
+
'if(!data)throw new Error(n+" uses compression method "+meth);fs.mkdirSync(p.dirname(t),{recursive:true});',
|
|
402
|
+
"if((mode&0o170000)===0o120000)fs.symlinkSync(data.toString(),t);else fs.writeFileSync(t,data,{mode:mode&0o111?0o755:0o644})}",
|
|
403
|
+
'if(m&&!hit)throw new Error(m+" is not in "+f)',
|
|
404
|
+
].join("");
|
|
405
|
+
|
|
406
|
+
function checkDownload(download: unknown): CiToolDownload {
|
|
407
|
+
if (download === undefined || download === "curl") return "curl";
|
|
408
|
+
if (download === "node") return "node";
|
|
409
|
+
throw new Error(`download is curl or node, not ${JSON.stringify(download)}`);
|
|
410
|
+
}
|
|
411
|
+
|
|
352
412
|
export interface CiToolFetchOptions extends CiToolCheckOptions {
|
|
353
413
|
/** The directory the tool installs into, an absolute path: {@link ciToolDir} under the image's tool root. */
|
|
354
414
|
dir: string;
|
|
@@ -362,10 +422,12 @@ export interface CiToolFetchOptions extends CiToolCheckOptions {
|
|
|
362
422
|
* /opt. The download and the check run as the job's user. Default false.
|
|
363
423
|
*/
|
|
364
424
|
sudo?: boolean;
|
|
425
|
+
/** Download with curl (the default) or with node, for an image with no curl or unzip (#4952). */
|
|
426
|
+
download?: CiToolDownload;
|
|
365
427
|
}
|
|
366
428
|
|
|
367
429
|
function needPins(tool: CiTool, version: string, sums: Partial<Record<CiToolArch, string>>, requirePin: boolean): void {
|
|
368
|
-
const hasSums = spec(tool).checksums !== undefined;
|
|
430
|
+
const hasSums = spec(tool).checksums?.(version, "") !== undefined;
|
|
369
431
|
const missing = CI_TOOL_ARCHES.filter((a) => !sums[a]);
|
|
370
432
|
if (missing.length && (requirePin || !hasSums)) {
|
|
371
433
|
const why = hasSums ? "" : `; ${tool}'s release publishes no checksums file, so chant needs one`;
|
|
@@ -385,6 +447,11 @@ export function ciToolFetchScript(tool: CiTool, version: string, options: CiTool
|
|
|
385
447
|
const s = spec(tool);
|
|
386
448
|
const sums = ciToolSha256(tool, version, options.sha256);
|
|
387
449
|
needPins(tool, version, sums, options.requirePin === true);
|
|
450
|
+
const node = checkDownload(options.download) === "node";
|
|
451
|
+
// #4952: `get <url word> <file>` and `unzipTo <zip> <dir> [member]`, with curl and unzip or with node.
|
|
452
|
+
const get = (url: string, out: string): string => (node ? `node -e '${NODE_FETCH_JS}' ${url} "${out}"` : `curl -fsSLo "${out}" ${url}`);
|
|
453
|
+
const unzipTo = (zipFile: string, into: string, member?: string): string =>
|
|
454
|
+
node ? `node -e '${NODE_UNZIP_JS}' "${zipFile}" "${into}"${member ? ` "${member}"` : ""}` : `unzip -q${member ? " -o" : ""} "${zipFile}"${member ? ` "${member}"` : ""} -d "${into}"`;
|
|
388
455
|
const name = `${tool} ${version}`;
|
|
389
456
|
const base = s.base(version);
|
|
390
457
|
const file = s.asset(version, "$w");
|
|
@@ -394,13 +461,13 @@ export function ciToolFetchScript(tool: CiTool, version: string, options: CiTool
|
|
|
394
461
|
`case "$a" in ${CI_TOOL_ARCHES.map((a) => `(${a}) w=${s.words[a]} ;;`).join(" ")} (*) echo "${name}: chant fetches it for ${CI_TOOL_ARCHES.join(" and ")}, not $a" >&2; exit 1 ;; esac`,
|
|
395
462
|
`f="${file}"`,
|
|
396
463
|
`t="$(mktemp -d)"`,
|
|
397
|
-
`
|
|
464
|
+
get(`"${base}/$f"`, "$t/$f"),
|
|
398
465
|
`case "$a" in ${CI_TOOL_ARCHES.filter((a) => sums[a]).map((a) => `(${a}) want=${sums[a]} ;;`).join(" ")} (*) want= ;; esac`,
|
|
399
466
|
];
|
|
400
467
|
const checksums = s.checksums?.(version, file);
|
|
401
468
|
if (checksums) {
|
|
402
469
|
lines.push(
|
|
403
|
-
|
|
470
|
+
get(options.checksumsUrl ?? `"${base}/${checksums}"`, "$t/sums"),
|
|
404
471
|
// The archive's line, with any ./ or * before the name taken off.
|
|
405
472
|
`line="$(sed -n "s#^\\([0-9a-f]\\{64\\}\\) *[*.]*/*$f\\$#\\1#p" "$t/sums")"`,
|
|
406
473
|
`{ [ -n "$line" ] || { echo "${name}: $f is not in ${checksums}" >&2; exit 1; }; }`,
|
|
@@ -420,13 +487,13 @@ export function ciToolFetchScript(tool: CiTool, version: string, options: CiTool
|
|
|
420
487
|
lines.push(`tar -xzf "$t/$f" -C "$t" "${member}"`, `${su}install -m 0755 "$t/${member}" "${dir}/${s.bin}"`);
|
|
421
488
|
break;
|
|
422
489
|
case "zip":
|
|
423
|
-
lines.push(
|
|
490
|
+
lines.push(unzipTo("$t/$f", "$t", member), `${su}install -m 0755 "$t/${member}" "${dir}/${s.bin}"`);
|
|
424
491
|
break;
|
|
425
492
|
case "tree":
|
|
426
493
|
lines.push(`${su}tar -xzf "$t/$f" -C "${dir}" --strip-components=1`);
|
|
427
494
|
break;
|
|
428
495
|
case "aws-cli":
|
|
429
|
-
lines.push(
|
|
496
|
+
lines.push(unzipTo("$t/$f", "$t"), `${su}"$t/aws/install" -i "${dir}" -b "${dir}/bin"`);
|
|
430
497
|
break;
|
|
431
498
|
}
|
|
432
499
|
return lines.join(" && ");
|
|
@@ -455,6 +522,12 @@ export interface CiToolInstallOptions extends CiToolCheckOptions {
|
|
|
455
522
|
sudo?: boolean;
|
|
456
523
|
/** Skip the install when any `<bin>` is on PATH, whatever its version. Default false: only the versioned directory counts. */
|
|
457
524
|
onPath?: boolean;
|
|
525
|
+
/**
|
|
526
|
+
* Download with curl (the default) or with node (#4952), for a job whose
|
|
527
|
+
* image carries node but neither curl nor unzip, such as terragucci's
|
|
528
|
+
* images installing the AWS CLI for drift attribution.
|
|
529
|
+
*/
|
|
530
|
+
download?: CiToolDownload;
|
|
458
531
|
}
|
|
459
532
|
|
|
460
533
|
/** Where a job line installs each release by default. */
|
|
@@ -475,7 +548,7 @@ export function ciToolInstallLine(tool: CiTool, version: string, options: CiTool
|
|
|
475
548
|
const binDir = (options.binDir ?? "/usr/local/bin").replace(/(.)\/+$/, "$1");
|
|
476
549
|
if (!SHELL_DIR.test(binDir)) throw new Error(`binDir is an absolute path of letters, digits and ._/-, or one under a variable such as $HOME, not ${JSON.stringify(options.binDir)}`);
|
|
477
550
|
const su = options.sudo ? "sudo " : "";
|
|
478
|
-
const install = `(set -e; ${ciToolFetchScript(tool, version, { dir, sha256: options.sha256, requirePin: options.requirePin, sudo: options.sudo })})`;
|
|
551
|
+
const install = `(set -e; ${ciToolFetchScript(tool, version, { dir, sha256: options.sha256, requirePin: options.requirePin, sudo: options.sudo, download: options.download })})`;
|
|
479
552
|
const inDir = `[ -x "${bin}" ]`;
|
|
480
553
|
// A plain path is written as it always was; one under a variable is quoted, so the shell expands it as one word.
|
|
481
554
|
const target = DIR.test(binDir) ? `${binDir}/${s.bin}` : `"${binDir}/${s.bin}"`;
|