Skip to content

CI: run the deploy bash suites under bash 3.2 (macOS /bin/bash) - #660

Merged
pdettori merged 1 commit into
rossoctl:mainfrom
cwiklik:fix/440-bash32-ci
Oct 29, 2026
Merged

pdettori merged 1 commit into
rossoctl:mainfrom
cwiklik:fix/440-bash32-ci

Conversation

@cwiklik

@cwiklik cwiklik commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

Summary

Operators run deploy/k8s/setup.sh with macOS's /bin/bash, which is 3.2.57 (2007-era). Every CI job is ubuntu-latest on bash 5, so a 3.2-only regression had no way to be caught — slice 2 (#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 let that happen. Both are closed here.

1. The harnesses picked their own interpreter, not the one that launched them

setup.test.sh used REAL_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.sh tested bash 5. smoke.test.sh and setup-microvm.test.sh spawned a bare bash "$SCRIPT", with the same effect.

All three now use ${BASH:-$(command -v bash)}. $BASH is 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 bash and prepend to PATH, so env bash resolved 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 way setup.test.sh already pinned its own. The #!/bin/sh shims are left alone: they exec an 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-bash32 runs the three suites on /bin/bash, mirroring test-deploy's collect-failures structure so one red suite cannot make the rest look green by never running.
  • deploy-scripts-bash32 on macos-latest runs 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 typecheck target already states. 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 in compose/tests/images.test.sh; mapfile in sbx/tests/smoke.test.sh and vm/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/bash is 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/bash would quietly turn this job into a green duplicate of deploy-scripts that 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 reason TestTheCIWorkflowsRunTheGates gives 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 reachable deploy/k8s/setup.sh function and ran both paths on identical code:

Result
bash 5 (make test-deploy, today's CI) green, setup.test.sh: all passed
bash 3.2 (make test-deploy-bash32, new job) red, FAIL: setup.sh --target kind failed

Reverted afterwards; setup.sh is untouched in this PR.

Verification

Check Result
/bin/bash -n on all three suites parse OK
Each suite individually under /bin/bash 3.2 pass (107 / 29 / 325 oks)
setup.test.sh under bash 5 pass
make test-deploy-bash32 pass, 463 oks, ~5 min
Drift-guard negative test (rename the job) fails with the right message; restored
Signal negative test see above
shellcheck -x -S warning on the three suites clean
pre-commit on the five changed files check-yaml / shellcheck / whitespace / secrets pass
prettier --check ci.yml clean
make test-deploy (full, bash 5) 29/30 pass — see below

The one red suite is deploy/microvm/tests/build-snapshot.test.sh, which this PR does not touch and which fails identically on a pristine upstream/main with every change stashed: two happy-path assertions where main exits 1 and $OUT is MISSING, because it needs microvm build tooling my Mac lacks. It passes in the existing deploy-scripts job on ubuntu-latest.

Notes on the new macOS job: no openssl install — the suites pass against stock LibreSSL 3.3.6, verified; no jq install — it ships on the runner image; shellcheck is installed, because setup-microvm.test.sh guards its shellcheck "$SCRIPT" with command -v shellcheck and would otherwise skip silently and assert nothing. macos-latest bills 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.yml already establishes that a different runner gets its own job, and 4 of deploy-scripts' 30 suites cannot run here.

Out of scope

  • The ~130 other bash "$SCRIPT" spawn sites across deploy/sbx, deploy/knative, deploy/vm and the remaining microvm suites. Nothing runs those under 3.2 and four of them cannot, so editing them would be a large unverifiable diff.
  • Making the declare -A / mapfile suites 3.2-safe — deliberate, and not run by this job.
  • A documented repo-wide bash floor. None exists today; it lives in scattered comments (compose.test.sh:77, mocactl-quickstart.sh:215, k8s/smoke.sh:542). Worth a follow-up issue.
  • Any change to deploy/k8s/setup.sh, smoke.sh or setup-microvm.sh — they pass on 3.2 as-is. No runtime code path changes.

Fixes #440

Assisted-By: Claude Code

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]>
@cwiklik
cwiklik requested a review from pdettori as a code owner October 28, 2026 23:24
@pdettori pdettori added the ready-for-ai-review Request automated AI code review from clawgenti label Oct 29, 2026

@ingpaolodettori-dev ingpaolodettori-dev left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread .github/workflows/ci.yml
# 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

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@pdettori
pdettori merged commit c13d556 into rossoctl:main Oct 29, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-ai-review Request automated AI code review from clawgenti

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CI: run the deploy bash suites under bash 3.2 (macOS /bin/bash), and make the harnesses use the bash they were launched with

3 participants