Files
CatoandClaude 62b5d9754b fix(deploy): smoke check and sender follow the move to fragheidi.ch (#463)
* fix(deploy): post-deploy smoke checks fragheidi.ch; sender and caption no longer lead with the old host

scripts/smoke.sh defaulted to heidi.orangecat.ch, which now answers 301, so the
smoke step after a deploy read 301 where it expects 307/200 and failed the job.
The sender list tries fragheidi.ch first (used only once the mail service says
it is verified). The care-shift video caption no longer names the old host.

Co-Authored-By: Claude <noreply@anthropic.com>

* fix(shell): footer language list keeps the page being read

On a phone the footer list is the only language control, and it sent people to
the other language's start page. It now links to the same page, as the header
switcher does.

Co-Authored-By: Claude <noreply@anthropic.com>

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-12-04 00:20:26 +01:00

95 lines
3.9 KiB
Bash
Executable File

#!/usr/bin/env bash
# Post-deploy smoke check: does the site actually answer, for both kinds of
# visitor?
#
# WHY THIS EXISTS. A middleware rewrite took the locale root down for every
# signed-in visitor, in production, with a full green test suite behind it —
# 339 tests, lint, typecheck, and a production build exercised in a browser.
# None of them could have caught it: the failure needs a reverse proxy in
# front of the app (CI has none, `pnpm start` has none), and the broken branch
# only ran when a session cookie was present.
#
# So the one thing that WOULD have caught it is the cheapest thing here:
# request the same URLs twice, once with a session cookie and once without.
#
# WHAT THE COOKIE DOES AND DOES NOT PROVE. It is not a real session — `auth()`
# rejects it and the page renders as signed-out. What it exercises is every
# code path gated on "is a session cookie present", which is where routing,
# rewrites and redirects live, and where this class of bug lives with them.
# A genuinely authenticated end-to-end test needs a test account and a real
# login; this is not that, and does not pretend to be.
#
# scripts/smoke.sh # against production
# scripts/smoke.sh http://localhost:3111 # against a local build
set -uo pipefail
BASE="${1:-https://fragheidi.ch}"
# Any non-empty value. Deliberately not a real token: this must be safe to
# commit, safe to log, and safe to run against production.
SESSION="__Secure-heidi.session_token=smoke; heidi.session_token=smoke; __Secure-authjs.session-token=smoke"
fail=0
check() {
local path="$1" expect="$2" who="$3" cookie="$4"
local code
code=$(curl -s -o /dev/null -w "%{http_code}" --max-time 20 \
${cookie:+-H "Cookie: $cookie"} "$BASE$path")
if [ "$code" = "$expect" ]; then
printf ' ok %-28s %-11s %s\n' "$path" "$who" "$code"
else
printf ' FAIL %-28s %-11s %s (expected %s)\n' "$path" "$who" "$code" "$expect"
fail=1
fi
}
both() {
check "$1" "$2" "signed out" ""
check "$1" "$2" "signed in" "$SESSION"
}
echo "smoke: $BASE"
# The bare root negotiates a locale. 307 and NOT 308: the right locale for the
# next visitor may differ, so a browser or proxy caching it as permanent would
# pin everyone to whoever asked first.
both / 307
# Every page a visitor can reach by name. Both ways round, because the outage
# this file exists for was invisible from one of them.
for path in /de /de/chat /de/speaking /de/grammar /de/method /de/contribute /de/about /de/listen /de/channels /en /fr; do
both "$path" 200
done
# `/portal` REDIRECTS, and asserting that is the point rather than a weakening.
#
# The dashboard moved back to the locale root — `/` and `/portal` were
# rendering the identical page, which is the duplication that made "start and
# chat show the same thing" a fair complaint one pair along. The route stays
# for the bookmarks and for the sign-in return, and it sends a Location header.
#
# This file asserted 200 here and so it failed the deploy that made the change,
# which is the check doing its job: the behaviour was intended, the assertion
# was not updated with it. 307 rather than 308 because the page could come
# back, and a permanent redirect is the one browsers refuse to forget.
both /de/portal 307
# The crawler files, which live outside the locale and have been broken by a
# middleware matcher before.
check /robots.txt 200 "anonymous" ""
check /sitemap.xml 200 "anonymous" ""
# Health carries the schema verdict; a deploy that cannot use its own tables
# reports 200 with `state != ok`, so read the body rather than the status.
health=$(curl -s --max-time 20 "$BASE/api/health")
if grep -q '"state":"ok"' <<<"$health"; then
echo " ok /api/health schema $(printf '%s' "$health" | tr -d '\n')"
else
echo " FAIL /api/health schema $health"
fail=1
fi
[ "$fail" -eq 0 ] && echo "smoke: all good" || echo "smoke: FAILURES above"
exit "$fail"