Repository navigation
CI: run the deploy bash suites under bash 3.2 (macOS /bin/bash) - #660
Conversation
Operators run deploy/k8s/setup.sh with macOS's /bin/bash, which is 3.2.57. Every CI job is ubuntu-latest on bash 5, so a 3.2-only regression had no way to be caught: slice 2 (rossoctl#424) shipped `"${arr[@]}"` on an empty array under `set -u` -- fatal on every 3.2 run -- and only human review stopped it. Two independent gaps, both closed here. The harnesses picked their own interpreter rather than the one that launched them. setup.test.sh used `REAL_BASH="$(command -v bash)"`, i.e. PATH's first bash -- Homebrew 5.x on a dev Mac -- so even `/bin/bash setup.test.sh` tested bash 5. smoke.test.sh and setup-microvm.test.sh spawned a bare `bash`, with the same effect. All three now use `${BASH:-$(command -v bash)}`: $BASH is the running interpreter's own path, with a fallback for a sourced run. That alone is not enough. Both suites generate their mocks with `#!/usr/bin/env bash` and *prepend* to PATH, so the mocks would still resolve to Homebrew 5 while the script under test ran on 3.2. Their shebangs are now pinned to $REAL_BASH, the way setup.test.sh already pinned its own. The `#!/bin/sh` shims are left alone: they exec an absolute real binary. Nothing ran these suites on 3.2 at all, so `make test-deploy-bash32` runs the three on /bin/bash and a `deploy-scripts-bash32` job runs that target on macos-latest for every PR. The suite list lives in the Makefile so CI and local reproduction cannot drift. It is explicit rather than a glob over test-deploy's directories because four of those suites use bash 4 constructs by design (`declare -A`, `mapfile`); widening it would fail for reasons that are not regressions. The target skips with a message when /bin/bash is not 3.x, and the job hard-fails in that case -- otherwise an Apple bump would quietly turn it into a green duplicate of deploy-scripts. setup.test.sh also asserts that the job and target still exist, substring-level in the manner of TestTheCIWorkflowsRunTheGates. Without it, deleting the job would have no symptom: 3.2 regressions would simply stop being caught, and every remaining job would stay green. Verified by injecting a bash-4 construct into a reachable setup.sh function: bash 5 fully green, bash 3.2 red, on identical code. Suites pass on 3.2 as-is against stock LibreSSL, so no openssl install is needed; shellcheck is installed because setup-microvm.test.sh's check is guarded by `command -v`. No runtime script changes. Fixes rossoctl#440 Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: cwiklik <[email protected]>
ingpaolodettori-dev
left a comment
There was a problem hiding this comment.
Both gaps from #440 are closed. All 4 + 5 spawn sites in setup-microvm.test.sh / smoke.test.sh now use $REAL_BASH (${BASH:-…}), and every env bash mock reachable through $TMP/bin is pinned to it, so /bin/bash <suite> exercises 3.2 end to end. The only unpinned bash heredoc left is smoke.test.sh's P7 stand-in setup.sh, which smoke.sh itself launches with bash (out of scope, and harmless since it only records env). The target skips off-3.x while the job hard-fails off-3.x, which is the right split. The drift guard checks the wiring without being brittle. The new job uses the repo's SHA-pinned checkout, and deploy-scripts-bash32 is green on this head.
One nit inline: the brew-installed shellcheck is unpinned.
Assisted-By: Claude Code
| # jq is already on the runner image, and the suites pass against the stock LibreSSL at | ||
| # /usr/bin/openssl, so neither of those needs installing. | ||
| - name: Install shellcheck | ||
| run: brew install shellcheck |
There was a problem hiding this comment.
nit: brew install shellcheck is unpinned (latest, 0.11.x today), while deploy-scripts and the security-scans shellcheck job use the runner's apt version. deploy/microvm/tests/setup-microvm.test.sh:147 runs shellcheck "$SCRIPT" at the default severity (style/info included), not -S warning. So a future shellcheck release that adds a style check would turn only this job red, and the red would read like a 3.2 regression. Optional: pass -S warning there to match security-scans, or note in this comment that a red shellcheck step here may be version drift.
Summary
Operators run
deploy/k8s/setup.shwith macOS's/bin/bash, which is 3.2.57 (2007-era). Every CI job isubuntu-lateston bash 5, so a 3.2-only regression had no way to be caught — slice 2 (#424) shipped"${arr[@]}"on an empty array underset -u, fatal on every 3.2 run, and only human review stopped it.Two independent gaps let that happen. Both are closed here.
1. The harnesses picked their own interpreter, not the one that launched them
setup.test.shusedREAL_BASH="$(command -v bash)"— PATH's first bash, which is Homebrew 5.x on a dev Mac. So even/bin/bash deploy/k8s/tests/setup.test.shtested bash 5.smoke.test.shandsetup-microvm.test.shspawned a barebash "$SCRIPT", with the same effect.All three now use
${BASH:-$(command -v bash)}.$BASHis the running interpreter's own absolute path; the fallback covers a sourced run, where it is unset.That alone is not sufficient. Both suites generate their mocks with
#!/usr/bin/env bashand prepend toPATH, soenv bashresolved to the caller's Homebrew 5 even when the suite itself ran on 3.2 — the mocks and the script under test would be on different interpreters. Their shebangs are now pinned to$REAL_BASH, the waysetup.test.shalready pinned its own. The#!/bin/shshims are left alone: theyexecan absolute real binary and are interpreter-agnostic.The issue text names three spawn sites in
setup-microvm.test.sh; there are four. The fourth is fixed too.2. Nothing ran these suites on 3.2 at all
make test-deploy-bash32runs the three suites on/bin/bash, mirroringtest-deploy's collect-failures structure so one red suite cannot make the rest look green by never running.deploy-scripts-bash32onmacos-latestruns that target on every PR.The suite list lives in the Makefile, so CI and local reproduction cannot drift — the same anti-drift rationale the
typechecktarget already states. It is explicit rather than a glob overtest-deploy's directories because four of those suites use bash 4 constructs by design (declare -Aincompose/tests/images.test.sh;mapfileinsbx/tests/smoke.test.shandvm/tests/setup-vm.test.sh); widening it would make the target fail for reasons that are not regressions.The target skips with a message when
/bin/bashis not 3.x, so Linux contributors get a useful answer instead of a false green. The CI job hard-fails in that case instead — otherwise an Apple bump to a newer/bin/bashwould quietly turn this job into a green duplicate ofdeploy-scriptsthat still reads as coverage.3. Drift guard
setup.test.sh— one of the suites the job runs — asserts the job and the Makefile target still exist. Without it, deleting the job has no symptom: 3.2 regressions simply stop being caught and every remaining job stays green. Kept substring-level, for the reasonTestTheCIWorkflowsRunTheGatesgives for its own: a brittle assertion here gets edited away rather than satisfied. It degrades to a skip outside a repo checkout.Does this actually add signal?
This is the check that matters, since there is no live 3.2 failure today — the change is pure regression-prevention. I injected a bash-4 construct (
declare -A) into a reachabledeploy/k8s/setup.shfunction and ran both paths on identical code:make test-deploy, today's CI)setup.test.sh: all passedmake test-deploy-bash32, new job)FAIL: setup.sh --target kind failedReverted afterwards;
setup.shis untouched in this PR.Verification
/bin/bash -non all three suites/bin/bash3.2setup.test.shunder bash 5make test-deploy-bash32shellcheck -x -S warningon the three suitespre-commiton the five changed filesprettier --check ci.ymlmake test-deploy(full, bash 5)The one red suite is
deploy/microvm/tests/build-snapshot.test.sh, which this PR does not touch and which fails identically on a pristineupstream/mainwith every change stashed: two happy-path assertions wheremainexits 1 and$OUTisMISSING, because it needs microvm build tooling my Mac lacks. It passes in the existingdeploy-scriptsjob onubuntu-latest.Notes on the new macOS job: no
opensslinstall — the suites pass against stock LibreSSL 3.3.6, verified; nojqinstall — it ships on the runner image;shellcheckis installed, becausesetup-microvm.test.shguards itsshellcheck "$SCRIPT"withcommand -v shellcheckand would otherwise skip silently and assert nothing.macos-latestbills at 10× Linux minutes, hence three suites rather than thirty.A separate job rather than an OS matrix on
deploy-scripts: there is no matrix precedent in this repo,microvm-kvm-gates.ymlalready establishes that a different runner gets its own job, and 4 ofdeploy-scripts' 30 suites cannot run here.Out of scope
bash "$SCRIPT"spawn sites acrossdeploy/sbx,deploy/knative,deploy/vmand the remaining microvm suites. Nothing runs those under 3.2 and four of them cannot, so editing them would be a large unverifiable diff.declare -A/mapfilesuites 3.2-safe — deliberate, and not run by this job.compose.test.sh:77,mocactl-quickstart.sh:215,k8s/smoke.sh:542). Worth a follow-up issue.deploy/k8s/setup.sh,smoke.shorsetup-microvm.sh— they pass on 3.2 as-is. No runtime code path changes.Fixes #440
Assisted-By: Claude Code