From 898b52edcb47bcb3e9d6106e74ca73e74ea01e70 Mon Sep 17 00:00:00 2001 From: sillylaird Date: Thu, 3 Sep 2026 00:33:59 +0000 Subject: import live www.sillylaird.ca webroot --- tools/run_audits.sh | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100755 tools/run_audits.sh (limited to 'tools/run_audits.sh') diff --git a/tools/run_audits.sh b/tools/run_audits.sh new file mode 100755 index 0000000..cf6c548 --- /dev/null +++ b/tools/run_audits.sh @@ -0,0 +1,52 @@ +#!/usr/bin/env bash +# Run all repo audits and regenerate the sitemap. +# Suitable for cron; exits non-zero if anything failed. +# +# Env: +# SILENT=1 suppress per-audit headers +# STRICT=1 also exit non-zero if audits report issues +# (default: only exit non-zero on script errors, not on findings — +# so the cron mail surfaces the report without flapping daily) +# CHECK_LINKS=1 also run the (slow, network-bound) external link rot check + +set -u +cd "$(dirname "$0")/.." + +ROOT="$(pwd)" +PY="${PYTHON:-python3}" + +heading() { [ "${SILENT:-0}" = "1" ] || printf '\n=== %s ===\n' "$1"; } +run_audit() { + local name="$1"; shift + heading "$name" + if "$@"; then + return 0 + else + local rc=$? + [ "${STRICT:-0}" = "1" ] && return $rc + return 0 + fi +} + +# Generate sitemap first (unconditional, idempotent). +heading "generate_sitemap" +"$PY" "$ROOT/tools/generate_sitemap.py" || exit $? + +# Audits — STRICT controls whether their findings fail the run. +run_audit "link_check" "$PY" "$ROOT/tools/link_check.py" +LC_RC=$? +run_audit "html_audit" "$PY" "$ROOT/tools/html_audit.py" +HA_RC=$? +run_audit "image_budget" "$PY" "$ROOT/tools/image_budget.py" +IB_RC=$? + +LR_RC=0 +if [ "${CHECK_LINKS:-0}" = "1" ]; then + run_audit "link_rot" "$PY" "$ROOT/tools/link_rot.py" + LR_RC=$? +fi + +if [ "${STRICT:-0}" = "1" ]; then + exit $(( LC_RC | HA_RC | IB_RC | LR_RC )) +fi +exit 0 -- cgit v1.2.3