34 lines
1.3 KiB
Shell
Executable file
34 lines
1.3 KiB
Shell
Executable file
#!/bin/sh
|
|
# Accessibility check with pa11y-ci, used by CI and for local runs (see README.md).
|
|
# Builds the site into a temporary directory, serves it on localhost and checks every page
|
|
# in the sitemaps except the past events, which are kept as they were.
|
|
set -eu
|
|
|
|
PA11Y_CI_VERSION=5.0.0
|
|
PORT=${PORT:-8080}
|
|
# Pages that are not checked: past events and the individual news posts.
|
|
EXCLUDE='^http://localhost:[0-9]+/[a-z]+/(37c3|38c3|39c3|eh22|posts/[^/]+)/'
|
|
|
|
# Use an installed Chrome/Chromium instead of letting Puppeteer download one.
|
|
if [ -z "${PUPPETEER_EXECUTABLE_PATH:-}" ]; then
|
|
for candidate in /usr/bin/chromium-browser /usr/bin/chromium "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"; do
|
|
if [ -x "$candidate" ]; then PUPPETEER_EXECUTABLE_PATH=$candidate; break; fi
|
|
done
|
|
fi
|
|
export PUPPETEER_EXECUTABLE_PATH
|
|
export PUPPETEER_SKIP_DOWNLOAD=1
|
|
|
|
cd "$(dirname "$0")/.."
|
|
site=$(mktemp -d)
|
|
hugo --quiet --buildFuture --buildDrafts --baseURL "http://localhost:$PORT/" -d "$site"
|
|
python3 -m http.server "$PORT" --bind 127.0.0.1 -d "$site" >/dev/null 2>&1 &
|
|
server=$!
|
|
trap 'kill $server; rm -rf "$site"' EXIT
|
|
sleep 1
|
|
|
|
status=0
|
|
for lang in de en; do
|
|
npx --yes "pa11y-ci@$PA11Y_CI_VERSION" --config .pa11yci.json \
|
|
--sitemap "http://localhost:$PORT/$lang/sitemap.xml" --sitemap-exclude "$EXCLUDE" || status=1
|
|
done
|
|
exit $status
|