All checks were successful
secrets-guard / encrypted (pull_request) Successful in 9s
PR build (required check) / changes (pull_request) Successful in 17s
shell-lint / shellcheck (pull_request) Successful in 13s
PR build (required check) / validate-observability (pull_request) Has been skipped
PR build (required check) / build-frontend (pull_request) Successful in 1m27s
PR build (required check) / build-backend (pull_request) Successful in 1m36s
PR build (required check) / gate (pull_request) Successful in 3s
No static analysis has ever run over the ~2k lines of shell that deploy, provision secrets, and bootstrap hosts as root over SSH. Add shell-lint.yml (pinned shellcheck v0.11.0 + sha256, -x, default severity, fail on any finding) and fix everything it reports, plus two defects it structurally cannot see. Not path-filtered, matching secrets-guard's call: a backstop that only runs when you expect it to isn't a backstop. Scripts are discovered with find, so new ones are covered on landing. The version is pinned to a static release rather than apt's, so a drifted shellcheck can't fail CI on an unrelated push. render-secrets.sh: the mktemp holding DECRYPTED vault contents was only removed on the success path and one failure branch, so a sops decrypt failure left plaintext POSTGRES_PASSWORD in /tmp indefinitely on a live host. A RETURN trap makes removal unconditional, and the two sops calls now `|| return 1` explicitly instead of relying on the caller's set -e (a bare set -e abort skips the trap). The function stays free of `set -e` itself -- it is sourced, and shell options would leak into the caller. autoscale.sh: ran `set -eu` without pipefail while piping docker stats into awk, so a failed left side was swallowed and the loop scaled on empty input. Promoted to pipefail with avg_cpu's failure treated as a missed sample, so a daemon hiccup can't kill the autoscaler. Verified busybox ash in docker:27-cli supports pipefail and the script still parses there. capture-fixtures.sh: `jq . || cat` ran cat after jq had already consumed stdin, silently writing a truncated fixture; now a real if/else that fails loudly. deploy.sh/deploy-stack.sh: `# shellcheck source=` paths corrected for the monorepo layout, and /etc/thermograph.env marked unfollowable (it is rendered at deploy time and cannot exist at lint time).
31 lines
1.3 KiB
Bash
Executable file
31 lines
1.3 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
# Refresh the committed unit-test fixtures (tests/fixtures/*.json) by capturing the
|
|
# real payloads a live backend returns for a known city. Run when the backend's content
|
|
# contract changes. Brings the backend harness up, saves each api_client endpoint's
|
|
# response, and tears it down. Requires jq for pretty output.
|
|
#
|
|
# scripts/capture-fixtures.sh
|
|
set -euo pipefail
|
|
cd "$(dirname "$0")/.."
|
|
|
|
SLUG="${FIXTURE_CITY:-london-england-gb}" # GB city -> Celsius rendering
|
|
MONTH="${FIXTURE_MONTH:-july}"
|
|
OUT=tests/fixtures
|
|
mkdir -p "$OUT"
|
|
|
|
BASE=$(scripts/backend-for-tests.sh up)
|
|
trap 'scripts/backend-for-tests.sh down >/dev/null 2>&1 || true' EXIT
|
|
|
|
fetch() { # <endpoint-path> <fixture-name>
|
|
echo "==> $2.json <- $1"
|
|
curl -fsS "$BASE/$1" --max-time 40 | { if command -v jq >/dev/null; then jq .; else cat; fi; } > "$OUT/$2.json"
|
|
}
|
|
|
|
fetch "api/v2/content/home" home
|
|
fetch "api/v2/content/sitemap" sitemap
|
|
fetch "api/v2/content/hub" hub
|
|
fetch "api/v2/content/city/$SLUG" city
|
|
fetch "api/v2/content/city/$SLUG/month/$MONTH" month
|
|
fetch "api/v2/content/city/$SLUG/records" records
|
|
|
|
echo "==> captured $(find "$OUT" -maxdepth 1 -name '*.json' | wc -l) fixtures for $SLUG into $OUT/"
|