Running the workflow, not just linting it, turned the lint job red
The workflow file had never been executed anywhere. It was linted, and its
steps were run by hand through scripts/ci-gates.sh, but nothing had ever taken
the YAML and played it start to finish. nektos/act (0.2.89, sha256
48ae218af96725f7635a66de2b87e1e346893b02add0f16b92f560296b2151fc) does that in a
Docker container, so the file itself got executed.
It found a defect on the first run. The lint job called `shellcheck` expecting
the copy baked into ubuntu-latest - 0.9.0-1, per the runner image's own package
list. Local shellcheck is 0.11.0 and says nothing about
scripts/geo-db-bump.sh:42; 0.9.0 flags it (SC2015: `A && B || C` is not
if-then-else). So the gate's verdict depended on which tool version the image
happened to ship, and the first push to a real runner would have gone red on a
pattern that is legal, just ambiguous.
Two changes, both version-independent:
- geo-db-bump.sh: the guard is now an explicit `if [ -z "$newest" ] || [
"$newest" = unknown ]`. Verified with the version that found it: shellcheck
0.9.0 in a Linux container now exits 0 over scripts/*.sh, and 0.11.0 on the
host exits 0. The script's behaviour is unchanged: DRY_RUN with a current pin
exits 0 ("nothing to do"), and an edition the vendor does not serve exits 2
("REFUSED - the freshness check could not name a newer release").
- ci.yml: shellcheck is pinned to 0.11.0 with a checksum per architecture, the
same way actionlint already is, and the step prints the version so the log
says which version did the linting.
Executed end to end in act on catthehacker/ubuntu:act-latest, arm64:
lint - Job succeeded (checkout, actionlint 1.7.12 sha256 OK, shellcheck
0.11.0 sha256 OK, 0 findings over scripts/*.sh)
source - Job succeeded (setup-dotnet, restore, build, unit, integration
34/34, smoke 19/19)
image - Job succeeded (docker build -> openwaf:ci 261 MB, compose smoke
43 passed / 0 failed)
This is not GitHub: it is a local Actions-compatible runner, so it proves the
file executes and the pinned tools resolve, not that a GitHub-hosted run is
green. The console job is the remaining one and is reported separately.
This commit is contained in:
@@ -69,8 +69,31 @@ jobs:
|
||||
|
||||
# Both smoke scripts are gates, so a broken one has to fail loudly here
|
||||
# rather than look like a passing run with zero assertions.
|
||||
- name: shellcheck the smoke scripts
|
||||
run: shellcheck -s bash scripts/*.sh
|
||||
#
|
||||
# The version is pinned the same way actionlint is, because relying on the
|
||||
# copy baked into the image made the gate's verdict depend on the image:
|
||||
# ubuntu-latest ships shellcheck 0.9.0-1, and running this file in a local
|
||||
# actions-compatible runner (nektos/act on catthehacker/ubuntu:act-latest)
|
||||
# had 0.9.0 flag an `A && B || C` pattern in scripts/geo-db-bump.sh that
|
||||
# the 0.11.0 developers run locally does not. The script was rewritten as
|
||||
# an explicit if, and the version is fixed here so the gate says the same
|
||||
# thing everywhere it runs. The log prints which version did the linting.
|
||||
- name: shellcheck the smoke scripts (pinned, checksum verified)
|
||||
run: |
|
||||
VERSION=0.11.0
|
||||
SHA_X86_64=8c3be12b05d5c177a04c29e3c78ce89ac86f1595681cab149b65b97c4e227198
|
||||
SHA_AARCH64=12b331c1d2db6b9eb13cfca64306b1b157a86eb69db83023e261eaa7e7c14588
|
||||
case "$(uname -m)" in
|
||||
x86_64) ARCH=x86_64; SHA=$SHA_X86_64 ;;
|
||||
aarch64) ARCH=aarch64; SHA=$SHA_AARCH64 ;;
|
||||
*) echo "shellcheck: unsupported architecture $(uname -m)" >&2; exit 1 ;;
|
||||
esac
|
||||
curl -fsSL -o /tmp/shellcheck.tar.xz \
|
||||
"https://github.com/koalaman/shellcheck/releases/download/v${VERSION}/shellcheck-v${VERSION}.linux.${ARCH}.tar.xz"
|
||||
echo "${SHA} /tmp/shellcheck.tar.xz" | sha256sum -c -
|
||||
tar xJf /tmp/shellcheck.tar.xz -C /tmp
|
||||
/tmp/shellcheck-v${VERSION}/shellcheck --version
|
||||
/tmp/shellcheck-v${VERSION}/shellcheck -s bash scripts/*.sh
|
||||
|
||||
source:
|
||||
name: build, test, smoke
|
||||
|
||||
@@ -39,8 +39,9 @@ esac
|
||||
|
||||
newest=$(printf '%s' "$line" | awk '{print $2}')
|
||||
pin=$(printf '%s' "$line" | awk '{print $1}')
|
||||
[ -n "$newest" ] && [ "$newest" != unknown ] || {
|
||||
echo 'geo bump: REFUSED — no release to bump to.' >&2; exit 2; }
|
||||
if [ -z "$newest" ] || [ "$newest" = unknown ]; then
|
||||
echo 'geo bump: REFUSED — no release to bump to.' >&2; exit 2;
|
||||
fi
|
||||
|
||||
if [ "$DRY_RUN" = 1 ]; then
|
||||
echo "geo bump: DRY_RUN — would rewrite ARG DBIP_VERSION=$pin to $newest in $DOCKERFILE"
|
||||
|
||||
Reference in New Issue
Block a user