From 4506638ea7b76038c5707f5c5d0b1fe2895fd8dc Mon Sep 17 00:00:00 2001 From: Loki Date: Tue, 3 Nov 2026 23:42:19 +0800 Subject: [PATCH] fix(smoke): make the absence checks fail the run A negated command (! cmd) never trips set -e, so the checks for the placeholder and the nginx header could not fail. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_014sgfmRNRtGuDLrKY4AjgHi --- deploy/smoke.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/deploy/smoke.sh b/deploy/smoke.sh index 64d1f7a..4f99dc0 100755 --- a/deploy/smoke.sh +++ b/deploy/smoke.sh @@ -4,6 +4,8 @@ # loaded as ghcr.io/nycu-winlab/ui:ci. set -euo pipefail trap 'docker compose logs' EXIT +# A negated test (! cmd) never trips set -e, so absence is checked here. +absent() { if grep -qiF "$1"; then echo "unexpected $1 in $2" >&2; exit 1; fi; } printf 'UI_VERSION=ci\n' > .env docker compose up -d --no-build --wait @@ -18,18 +20,18 @@ curl -s localhost:8080/missing | grep -q '找不到這個頁面' test "$(curl -s -o /dev/null -w '%{http_code}' localhost:8080/404)" = 404 test "$(curl -s -o /dev/null -w '%{http_code}' localhost:8080/404.html)" = 404 curl -s localhost:8080/404 | grep -q '找不到這個頁面' -! curl -sI localhost:8080/ | grep -qi "server: nginx/" +curl -sI localhost:8080/ | absent "server: nginx/" headers # Not a sha- version: the corner reads dev, and no placeholder is left. curl -sf localhost:8080/ | grep -q '>dev<' -! curl -sf localhost:8080/ | grep -q __BUILD_SHA__ +curl -sf localhost:8080/ | absent __BUILD_SHA__ / # A release: the corner reads the commit, in the page and in its scripts. docker compose run --rm -d -e UI_VERSION=sha-abc1234 -p 127.0.0.1:8081:8080 web >/dev/null for i in $(seq 1 20); do curl -sf localhost:8081/ >/dev/null && break; sleep 0.5; done curl -sf localhost:8081/ | grep -q '>abc1234<' -! curl -sf localhost:8081/ | grep -q __BUILD_SHA__ +curl -sf localhost:8081/ | absent __BUILD_SHA__ / for js in $(curl -sf localhost:8081/ | grep -o '/_next/static/[^"]*\.js' | sort -u); do - ! curl -sf "localhost:8081$js" | grep -q __BUILD_SHA__ + curl -sf "localhost:8081$js" | absent __BUILD_SHA__ "$js" done echo "smoke passed"