Skip to content

Commit 3e2e437

Browse files
committed
ci(workflows): pin flux, yq and helm-unittest installs
Every flux install fetched fluxcd.io/install.sh and ran it as root, so whatever that host served at the moment executed on runners that later hold registry credentials. Use the upstream setup action instead, pinned by commit and given an explicit version: it checks the release tarball against that release's checksums file and runs no script fetched at run time. nightly and the fork e2e lane still took yq from the floating latest release. They now use the pinned, checksum-verified install the promotion steps already have. The helm-unittest plugin embeds its own Helm and was installed at whatever version was newest, so a plugin release could change chart test results on a PR that touched no chart. Pin it, and replace a different version a persistent runner may carry. A contract test scans every workflow for these three tools, so an unpinned flux, yq or helm-unittest install copied from an older step fails the unit lane. Assisted-by: LLM Signed-off-by: Aleksei Sviridkin <[email protected]>
1 parent 5415973 commit 3e2e437

12 files changed

Lines changed: 205 additions & 159 deletions

‎.github/workflows/build-main.yaml‎

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -61,17 +61,11 @@ jobs:
6161
persist-credentials: false
6262

6363
# Ephemeral runners lack the flux CLI the installer's image-packages step
64-
# shells out to; install the pinned version when it is not already present.
65-
- name: Set up build toolchain
66-
env:
67-
FLUX_VERSION: "2.8.6"
68-
run: |
69-
if ! flux version --client 2>/dev/null | grep -Fqx "flux: v${FLUX_VERSION}"; then
70-
install_script="$(mktemp)"
71-
curl -fsSL https://fluxcd.io/install.sh -o "$install_script"
72-
sudo env "FLUX_VERSION=$FLUX_VERSION" bash "$install_script"
73-
rm -f "$install_script"
74-
fi
64+
# shells out to.
65+
- name: Set up flux
66+
uses: fluxcd/flux2/action@04acaec6161ac4fb1a82ffafa88901c03271d34f # v2.8.6
67+
with:
68+
version: "2.8.6"
7569

7670
- name: Set up Docker config
7771
run: |

‎.github/workflows/build-release.yaml‎

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -107,17 +107,11 @@ jobs:
107107
persist-credentials: false
108108

109109
# Ephemeral runners lack the flux CLI the installer's image-packages step
110-
# shells out to; install the pinned version when it is not already present.
111-
- name: Set up build toolchain
112-
env:
113-
FLUX_VERSION: "2.8.6"
114-
run: |
115-
if ! flux version --client 2>/dev/null | grep -Fqx "flux: v${FLUX_VERSION}"; then
116-
install_script="$(mktemp)"
117-
curl -fsSL https://fluxcd.io/install.sh -o "$install_script"
118-
sudo env "FLUX_VERSION=$FLUX_VERSION" bash "$install_script"
119-
rm -f "$install_script"
120-
fi
110+
# shells out to.
111+
- name: Set up flux
112+
uses: fluxcd/flux2/action@04acaec6161ac4fb1a82ffafa88901c03271d34f # v2.8.6
113+
with:
114+
version: "2.8.6"
121115

122116
- name: Set up Docker config
123117
run: |

‎.github/workflows/e2e-fork.yaml‎

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -349,22 +349,13 @@ jobs:
349349
outputs:
350350
packages_digest: ${{ steps.push.outputs.packages_digest }}
351351
steps:
352-
- name: Set up toolchain (skopeo, flux)
353-
env:
354-
# Pin the flux CLI instead of install.sh's rolling latest. This is the
355-
# one privileged job that runs a remote installer as root right before
356-
# the OCIR token is loaded, where a pinned installer matters most;
357-
# keep it in step with the flux distro cozystack ships
358-
# (internal/fluxinstall/manifests/fluxcd.yaml, v2.8.0).
359-
FLUX_VERSION: "2.8.6"
352+
- name: Set up flux
353+
uses: fluxcd/flux2/action@04acaec6161ac4fb1a82ffafa88901c03271d34f # v2.8.6
354+
with:
355+
version: "2.8.6"
356+
- name: Set up toolchain (skopeo)
360357
run: |
361358
command -v skopeo >/dev/null || { sudo apt-get update -qq && sudo apt-get install -y -qq skopeo; }
362-
if ! flux version --client 2>/dev/null | grep -Fqx "flux: v${FLUX_VERSION}"; then
363-
s="$(mktemp)"
364-
curl -fsSL https://fluxcd.io/install.sh -o "$s"
365-
sudo env "FLUX_VERSION=$FLUX_VERSION" bash "$s"
366-
rm -f "$s"
367-
fi
368359
# The base repo's own merge ref — safe to fetch, not fork-controlled code
369360
# execution. pr.patch is applied as DATA below; nothing from the tree runs.
370361
- name: Checkout PR merge ref
@@ -581,8 +572,18 @@ jobs:
581572
got="$(git rev-parse HEAD^2)"
582573
[ "$got" = "$EXPECTED_SHA" ] || { echo "::error::merge ref moved: HEAD^2=$got != resolved $EXPECTED_SHA"; exit 1; }
583574
- name: Set up toolchain (yq)
575+
env:
576+
YQ_VERSION: "4.53.3"
577+
YQ_SHA256: "fa52a4e758c63d38299163fbdd1edfb4c4963247918bf9c1c5d31d84789eded4"
584578
run: |
585-
command -v yq >/dev/null || { sudo curl -sSL -o /usr/local/bin/yq https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 && sudo chmod +x /usr/local/bin/yq; }
579+
if ! yq --version 2>/dev/null | grep -q "mikefarah.* version v${YQ_VERSION}\$"; then
580+
yq_bin="$(mktemp)"
581+
curl -fsSL -o "$yq_bin" \
582+
"https://github.com/mikefarah/yq/releases/download/v${YQ_VERSION}/yq_linux_amd64"
583+
printf '%s %s\n' "$YQ_SHA256" "$yq_bin" | sha256sum -c -
584+
sudo install -m 0755 "$yq_bin" /usr/local/bin/yq
585+
rm -f "$yq_bin"
586+
fi
586587
- name: Download pr.patch
587588
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4
588589
with:

‎.github/workflows/nightly.yaml‎

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -52,18 +52,24 @@ jobs:
5252
packages_ref: ${{ steps.resolve.outputs.packages_ref }}
5353
packages_digest: ${{ steps.publish.outputs.packages_digest }}
5454
steps:
55-
- name: Set up toolchain (skopeo, flux, yq, helm)
55+
- name: Set up flux
56+
uses: fluxcd/flux2/action@04acaec6161ac4fb1a82ffafa88901c03271d34f # v2.8.6
57+
with:
58+
version: "2.8.6"
59+
- name: Set up toolchain (skopeo, yq, helm)
5660
env:
57-
FLUX_VERSION: "2.8.6"
61+
YQ_VERSION: "4.53.3"
62+
YQ_SHA256: "fa52a4e758c63d38299163fbdd1edfb4c4963247918bf9c1c5d31d84789eded4"
5863
run: |
5964
command -v skopeo >/dev/null || { sudo apt-get update -qq && sudo apt-get install -y -qq skopeo; }
60-
if ! flux version --client 2>/dev/null | grep -Fqx "flux: v${FLUX_VERSION}"; then
61-
install_script="$(mktemp)"
62-
curl -fsSL https://fluxcd.io/install.sh -o "$install_script"
63-
sudo env "FLUX_VERSION=$FLUX_VERSION" bash "$install_script"
64-
rm -f "$install_script"
65+
if ! yq --version 2>/dev/null | grep -q "mikefarah.* version v${YQ_VERSION}\$"; then
66+
yq_bin="$(mktemp)"
67+
curl -fsSL -o "$yq_bin" \
68+
"https://github.com/mikefarah/yq/releases/download/v${YQ_VERSION}/yq_linux_amd64"
69+
printf '%s %s\n' "$YQ_SHA256" "$yq_bin" | sha256sum -c -
70+
sudo install -m 0755 "$yq_bin" /usr/local/bin/yq
71+
rm -f "$yq_bin"
6572
fi
66-
command -v yq >/dev/null || { sudo curl -sSL -o /usr/local/bin/yq https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 && sudo chmod +x /usr/local/bin/yq; }
6773
command -v helm >/dev/null || curl -fsSL https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash
6874
6975
- name: Login to registries
@@ -250,16 +256,12 @@ jobs:
250256
ref: ${{ needs.mirror.outputs.sha }}
251257
fetch-depth: 1
252258
persist-credentials: false
253-
- name: Set up toolchain (flux, oras)
254-
env:
255-
FLUX_VERSION: "2.8.6"
259+
- name: Set up flux
260+
uses: fluxcd/flux2/action@04acaec6161ac4fb1a82ffafa88901c03271d34f # v2.8.6
261+
with:
262+
version: "2.8.6"
263+
- name: Set up toolchain (oras)
256264
run: |
257-
if ! flux version --client 2>/dev/null | grep -Fqx "flux: v${FLUX_VERSION}"; then
258-
install_script="$(mktemp)"
259-
curl -fsSL https://fluxcd.io/install.sh -o "$install_script"
260-
sudo env "FLUX_VERSION=$FLUX_VERSION" bash "$install_script"
261-
rm -f "$install_script"
262-
fi
263265
command -v oras >/dev/null || { curl -fsSL https://github.com/oras-project/oras/releases/download/v1.2.0/oras_1.2.0_linux_amd64.tar.gz | sudo tar -xz -C /usr/local/bin oras; }
264266
- name: Login to GHCR
265267
env:

‎.github/workflows/promote-rc.yaml‎

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ jobs:
400400
# Promotion publishes one non-consumer-visible packages candidate. Stable
401401
# image/chart tags are still deferred to post-merge finalize.
402402
#
403-
# Both tools are version-pinned. This step arms the only registry write
403+
# Both tools are version-pinned. These steps arm the only registry write
404404
# the dispatch performs, so what performs it has to be a fixed input:
405405
# `latest/download` resolves to whatever mikefarah shipped this morning,
406406
# and a yq that changed how it emits or compares a value would rewrite
@@ -418,26 +418,19 @@ jobs:
418418
# chosen (against this release's own published checksums list) and makes
419419
# any later substitution loud. Bump the version and this together.
420420
#
421-
# The Flux installer is deliberately NOT pinned by content. It verifies
422-
# the flux binary it fetches against flux_${FLUX_VERSION}_checksums.txt
423-
# from the pinned release, so the binary is not the exposure — the ~6 KB
424-
# bootstrap script from fluxcd.io is, and it is mutable by design and
425-
# fetched the same way in ten other workflows here. Pinning its bytes in
426-
# this file alone would break on the next regeneration of a script the
427-
# project does not control, while leaving the identical fetch unpinned
428-
# everywhere else. Named rather than half-fixed.
429-
- name: Set up toolchain (flux, yq)
421+
# flux comes from the upstream setup action, pinned by commit and given
422+
# an explicit version. It checks the release tarball against that
423+
# release's checksums file and runs no script fetched at run time, the
424+
# way fluxcd.io/install.sh did as root.
425+
- name: Set up flux
426+
uses: fluxcd/flux2/action@04acaec6161ac4fb1a82ffafa88901c03271d34f # v2.8.6
427+
with:
428+
version: "2.8.6"
429+
- name: Set up toolchain (yq)
430430
env:
431-
FLUX_VERSION: "2.8.6"
432431
YQ_VERSION: "4.53.3"
433432
YQ_SHA256: "fa52a4e758c63d38299163fbdd1edfb4c4963247918bf9c1c5d31d84789eded4"
434433
run: |
435-
if ! flux version --client 2>/dev/null | grep -qx "flux: v${FLUX_VERSION}"; then
436-
install_script="$(mktemp)"
437-
curl -fsSL https://fluxcd.io/install.sh -o "$install_script"
438-
sudo env "FLUX_VERSION=$FLUX_VERSION" bash "$install_script"
439-
rm -f "$install_script"
440-
fi
441434
if ! yq --version 2>/dev/null | grep -q "mikefarah.* version v${YQ_VERSION}\$"; then
442435
yq_bin="$(mktemp)"
443436
curl -fsSL -o "$yq_bin" \

‎.github/workflows/pull-requests-release.yaml‎

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -115,22 +115,20 @@ jobs:
115115
# this morning. The version tracks
116116
# packages/core/testing/images/e2e-sandbox/Dockerfile. yq is additionally
117117
# pinned by content — it stamps the chart's platformVersion, and this step
118-
# is the last one before write-once names exist. The Flux installer is not,
119-
# because it checksums the binary it fetches and the mutable part is its
120-
# own bootstrap script. promote-rc.yaml's copy carries the full reasoning.
121-
- name: Set up promotion toolchain (flux, skopeo, yq, helm)
118+
# is the last one before write-once names exist. flux comes from the
119+
# commit-pinned upstream setup action, which checksums the release
120+
# tarball. promote-rc.yaml's copy carries the full reasoning.
121+
- name: Set up flux
122+
if: ${{ !contains(steps.get_tag.outputs.tag, '-') }}
123+
uses: fluxcd/flux2/action@04acaec6161ac4fb1a82ffafa88901c03271d34f # v2.8.6
124+
with:
125+
version: "2.8.6"
126+
- name: Set up promotion toolchain (skopeo, yq, helm)
122127
if: ${{ !contains(steps.get_tag.outputs.tag, '-') }}
123128
env:
124-
FLUX_VERSION: "2.8.6"
125129
YQ_VERSION: "4.53.3"
126130
YQ_SHA256: "fa52a4e758c63d38299163fbdd1edfb4c4963247918bf9c1c5d31d84789eded4"
127131
run: |
128-
if ! flux version --client 2>/dev/null | grep -qx "flux: v${FLUX_VERSION}"; then
129-
install_script="$(mktemp)"
130-
curl -fsSL https://fluxcd.io/install.sh -o "$install_script"
131-
sudo env "FLUX_VERSION=$FLUX_VERSION" bash "$install_script"
132-
rm -f "$install_script"
133-
fi
134132
if ! yq --version 2>/dev/null | grep -q "mikefarah.* version v${YQ_VERSION}\$"; then
135133
yq_bin="$(mktemp)"
136134
curl -fsSL -o "$yq_bin" \

‎.github/workflows/pull-requests.yaml‎

Lines changed: 26 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -249,22 +249,18 @@ jobs:
249249
# resolves to whatever mikefarah shipped this morning, and a yq that changed
250250
# how it emits or compares a value turns a release gate into a moving one.
251251
# The version tracks packages/core/testing/images/e2e-sandbox/Dockerfile.
252-
# yq is additionally pinned by content; the Flux installer is not, because
253-
# it checksums the binary it fetches and the mutable part is its own
254-
# bootstrap script. promote-rc.yaml's copy of this step carries the full
255-
# reasoning for both.
256-
- name: Set up promotion toolchain (flux, yq)
252+
# yq is additionally pinned by content; flux comes from the commit-pinned
253+
# upstream setup action, which checksums the release tarball.
254+
# promote-rc.yaml's copy of this step carries the full reasoning for both.
255+
- name: Set up flux
256+
uses: fluxcd/flux2/action@04acaec6161ac4fb1a82ffafa88901c03271d34f # v2.8.6
257+
with:
258+
version: "2.8.6"
259+
- name: Set up promotion toolchain (yq)
257260
env:
258-
FLUX_VERSION: "2.8.6"
259261
YQ_VERSION: "4.53.3"
260262
YQ_SHA256: "fa52a4e758c63d38299163fbdd1edfb4c4963247918bf9c1c5d31d84789eded4"
261263
run: |
262-
if ! flux version --client 2>/dev/null | grep -qx "flux: v${FLUX_VERSION}"; then
263-
install_script="$(mktemp)"
264-
curl -fsSL https://fluxcd.io/install.sh -o "$install_script"
265-
sudo env "FLUX_VERSION=$FLUX_VERSION" bash "$install_script"
266-
rm -f "$install_script"
267-
fi
268264
if ! yq --version 2>/dev/null | grep -q "mikefarah.* version v${YQ_VERSION}\$"; then
269265
yq_bin="$(mktemp)"
270266
curl -fsSL -o "$yq_bin" \
@@ -313,11 +309,17 @@ jobs:
313309
with:
314310
fetch-depth: 0
315311
# Ephemeral runners don't carry the helm-unittest plugin the persistent
316-
# self-hosted runner accreted. Install if absent (idempotent).
312+
# self-hosted runner accreted. The plugin embeds its own Helm, so its
313+
# version is pinned: a plugin release must not change test results.
317314
- name: Set up test toolchain
315+
env:
316+
HELM_UNITTEST_VERSION: "1.1.2"
318317
run: |
319-
helm plugin list 2>/dev/null | grep -q unittest \
320-
|| helm plugin install https://github.com/helm-unittest/helm-unittest
318+
installed="$(helm plugin list 2>/dev/null | awk '$1 == "unittest" { print $2 }')"
319+
if [ "$installed" != "$HELM_UNITTEST_VERSION" ]; then
320+
[ -z "$installed" ] || helm plugin uninstall unittest
321+
helm plugin install https://github.com/helm-unittest/helm-unittest --version "v${HELM_UNITTEST_VERSION}"
322+
fi
321323
# The make processes share one four-slot jobserver. Each BATS file is a
322324
# separate target, so the long tail no longer runs as one nine-minute shell
323325
# loop; Helm and Go targets share the same bounded pool. Output stays
@@ -359,17 +361,11 @@ jobs:
359361
fetch-depth: 0
360362
fetch-tags: true
361363
# installer is built in finalize, but some package image targets shell out
362-
# to flux; install the pinned version when it is not already present.
363-
- name: Set up build toolchain
364-
env:
365-
FLUX_VERSION: "2.8.6"
366-
run: |
367-
if ! flux version --client 2>/dev/null | grep -Fqx "flux: v${FLUX_VERSION}"; then
368-
install_script="$(mktemp)"
369-
curl -fsSL https://fluxcd.io/install.sh -o "$install_script"
370-
sudo env "FLUX_VERSION=$FLUX_VERSION" bash "$install_script"
371-
rm -f "$install_script"
372-
fi
364+
# to flux.
365+
- name: Set up flux
366+
uses: fluxcd/flux2/action@04acaec6161ac4fb1a82ffafa88901c03271d34f # v2.8.6
367+
with:
368+
version: "2.8.6"
373369
- name: Set up Docker config
374370
run: |
375371
if [ -d ~/.docker ]; then
@@ -587,16 +583,10 @@ jobs:
587583
with:
588584
fetch-depth: 0
589585
fetch-tags: true
590-
- name: Set up build toolchain
591-
env:
592-
FLUX_VERSION: "2.8.6"
593-
run: |
594-
if ! flux version --client 2>/dev/null | grep -Fqx "flux: v${FLUX_VERSION}"; then
595-
install_script="$(mktemp)"
596-
curl -fsSL https://fluxcd.io/install.sh -o "$install_script"
597-
sudo env "FLUX_VERSION=$FLUX_VERSION" bash "$install_script"
598-
rm -f "$install_script"
599-
fi
586+
- name: Set up flux
587+
uses: fluxcd/flux2/action@04acaec6161ac4fb1a82ffafa88901c03271d34f # v2.8.6
588+
with:
589+
version: "2.8.6"
600590
- name: Download patch fragments
601591
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4
602592
with:

‎.github/workflows/tags.yaml‎

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -256,18 +256,12 @@ jobs:
256256
persist-credentials: false
257257

258258
# Ephemeral runners lack the flux CLI the installer's image-packages step
259-
# shells out to; install the pinned version when it is not already present.
260-
- name: Set up build toolchain
259+
# shells out to.
260+
- name: Set up flux
261261
if: steps.check_release.outputs.release_exists == 'false'
262-
env:
263-
FLUX_VERSION: "2.8.6"
264-
run: |
265-
if ! flux version --client 2>/dev/null | grep -Fqx "flux: v${FLUX_VERSION}"; then
266-
install_script="$(mktemp)"
267-
curl -fsSL https://fluxcd.io/install.sh -o "$install_script"
268-
sudo env "FLUX_VERSION=$FLUX_VERSION" bash "$install_script"
269-
rm -f "$install_script"
270-
fi
262+
uses: fluxcd/flux2/action@04acaec6161ac4fb1a82ffafa88901c03271d34f # v2.8.6
263+
with:
264+
version: "2.8.6"
271265

272266
- name: Login to GHCR
273267
if: steps.check_release.outputs.release_exists == 'false'
@@ -421,17 +415,14 @@ jobs:
421415

422416
# The stitch and the multi-arch gate read the registry with skopeo and
423417
# the tree with mikefarah yq; the republish needs flux and helm.
418+
- name: Set up flux
419+
if: needs.build-amd64.outputs.release_exists == 'false'
420+
uses: fluxcd/flux2/action@04acaec6161ac4fb1a82ffafa88901c03271d34f # v2.8.6
421+
with:
422+
version: "2.8.6"
424423
- name: Set up build toolchain
425424
if: needs.build-amd64.outputs.release_exists == 'false'
426-
env:
427-
FLUX_VERSION: "2.8.6"
428425
run: |
429-
if ! flux version --client 2>/dev/null | grep -Fqx "flux: v${FLUX_VERSION}"; then
430-
install_script="$(mktemp)"
431-
curl -fsSL https://fluxcd.io/install.sh -o "$install_script"
432-
sudo env "FLUX_VERSION=$FLUX_VERSION" bash "$install_script"
433-
rm -f "$install_script"
434-
fi
435426
command -v skopeo >/dev/null \
436427
|| { sudo apt-get update -qq && sudo apt-get install -y -qq skopeo; }
437428
command -V skopeo jq yq helm

0 commit comments

Comments
 (0)