This commit is contained in:
parent
6841623e23
commit
38688a68f5
3 changed files with 99 additions and 25 deletions
48
tools/e2e.sh
48
tools/e2e.sh
|
|
@ -28,6 +28,22 @@ fi
|
|||
|
||||
PORT="${E2E_PORT:-8199}"
|
||||
BASE="http://127.0.0.1:$PORT"
|
||||
|
||||
# Where tools/fetch-media.sh put the mirrored files.
|
||||
#
|
||||
# NOT hardcoded to ./media: in the repo that is where they land, but CI points
|
||||
# the mirror at the persistent mount instead (/deploy-app/media) so the copies
|
||||
# survive a deploy. A check that assumed the dev layout reported every single
|
||||
# referenced file as missing on CI while the files were perfectly fine on the
|
||||
# mount — a failure that said "40 files missing" and meant "wrong directory".
|
||||
# Override with E2E_MEDIA_DIR; the workflow passes the same path it gave the
|
||||
# mirror.
|
||||
MEDIA_DIR="${E2E_MEDIA_DIR:-}"
|
||||
if [ -z "$MEDIA_DIR" ]; then
|
||||
for d in media /deploy-app/media; do
|
||||
if [ -d "$d" ]; then MEDIA_DIR="$d"; break; fi
|
||||
done
|
||||
fi
|
||||
WORK="$(mktemp -d)"
|
||||
ORDERS="$WORK/orders.jsonl"
|
||||
|
||||
|
|
@ -505,18 +521,28 @@ else
|
|||
fi
|
||||
# Every tier has to be a file that exists, or the ladder serves a 404 to
|
||||
# whichever browsers pick that rung — which is precisely the set of
|
||||
# browsers nobody testing this site is using.
|
||||
missing=0
|
||||
for f in $(curl -s "$BASE/sitemap.xml" | grep -oE '/posts/[a-z0-9-]+' | head -n 20 \
|
||||
| while read -r pg; do curl -s "$BASE$pg"; done \
|
||||
| grep -oE '(src|srcset)="/media/[^"]+"' \
|
||||
| sed 's/.*="//; s/"$//' | sort -u); do
|
||||
[ -f "media${f#/media}" ] || { missing=$((missing + 1)); echo " missing: $f" >&2; }
|
||||
done
|
||||
if [ "$missing" -eq 0 ]; then
|
||||
ok "every referenced media file is on the mount"
|
||||
# browsers nobody testing this site is using. The files are served by
|
||||
# Caddy rather than by this server, so they are checked on disk.
|
||||
if [ -z "$MEDIA_DIR" ]; then
|
||||
skip "media files exist" "no media directory found; set E2E_MEDIA_DIR"
|
||||
else
|
||||
bad "media files" "$missing referenced file(s) not on the mount"
|
||||
missing=0
|
||||
for f in $(curl -s "$BASE/sitemap.xml" | grep -oE '/posts/[a-z0-9-]+' | head -n 20 \
|
||||
| while read -r pg; do curl -s "$BASE$pg"; done \
|
||||
| grep -oE '(src|srcset)="/media/[^"]+"' \
|
||||
| sed 's/.*="//; s/"$//' | sort -u); do
|
||||
if [ ! -f "$MEDIA_DIR/${f#/media/}" ]; then
|
||||
missing=$((missing + 1))
|
||||
# Bounded: a wrong directory makes EVERY file missing, and a
|
||||
# hundred identical lines buries the one fact that matters.
|
||||
[ "$missing" -le 5 ] && echo " missing: $f" >&2
|
||||
fi
|
||||
done
|
||||
if [ "$missing" -eq 0 ]; then
|
||||
ok "every referenced media file is in $MEDIA_DIR"
|
||||
else
|
||||
bad "media files" "$missing referenced file(s) not in $MEDIA_DIR"
|
||||
fi
|
||||
fi
|
||||
else
|
||||
skip "image format ladder" "no <picture> on this page — ffmpeg absent at mirror time?"
|
||||
|
|
|
|||
Loading…
Reference in a new issue