johnandersen777.bsky.social/knotless
git that lives in your Atmosphere account
Forked from chadtmiller.com/knotless
0
0
#!/usr/bin/env bash
# The screenshots in Linux, in Playwright's image of the harness's version.
# The shots workflow runs this; `just shots-linux` runs it in Docker, from
# any machine.
#
# bash harness/shots/linux.sh [playwright args]
#
# The pages are compared with their base's (shots/compare.mjs): each that
# moved, or is new, is left in $KNOTLESS_RUN_OUTPUTS, when set, as
# pictures named for the page and project: `1 before`, `2 after` and
# `3 difference`, as WebP small enough to keep (shots/outputs.mjs), or as
# the PNG should that fail. It fails on one the change does not name.
#
# Node, the packages and the build: shots/node.sh.
set -euo pipefail
cd "$(dirname "$0")/../.."
# The base's pages come out of git.
command -v git >/dev/null || { apt-get update -qq && apt-get install -y -qq git >/dev/null; }
source harness/shots/node.sh
status=0
node harness/shots/compare.mjs "$@" || status=$?
results=target/shots/results
if [ -n "${KNOTLESS_RUN_OUTPUTS:-}" ] && [ -d $results ]; then
outputs=$PWD/harness/shots/outputs.mjs
cd $results
for shot in */; do
[ -d "$shot" ] || continue
page=${shot%/}
page=${page#views-}
for png in "$shot"*.png; do
kind=$(basename "$png" .png)
case ${kind##*-} in
expected) kind="1 before" ;;
actual) kind="2 after" ;;
diff) kind="3 difference" ;;
*) continue ;;
esac
# As WebP (outputs.mjs), or else as the PNG, saying so.
out="$KNOTLESS_RUN_OUTPUTS/$page $kind"
node "$outputs" "$png" "$out" "${kind#* }" && continue
echo "==> $page $kind.png: kept as PNG, being no WebP"
cp "$png" "$out.png"
done
done
fi
exit $status