aboutsummaryrefslogtreecommitdiffstats
path: root/tools/run_audits.sh
diff options
context:
space:
mode:
authorsillylaird <sillyfanboy@gmail.com>2026-09-03 00:33:59 +0000
committersillylaird <sillyfanboy@gmail.com>2026-09-03 00:33:59 +0000
commit898b52edcb47bcb3e9d6106e74ca73e74ea01e70 (patch)
tree85c6ee5ad58b860144551184d4cf86b560c62b91 /tools/run_audits.sh
downloadwww-main.tar.gz
www-main.zip
import live www.sillylaird.ca webrootHEADmain
Diffstat (limited to 'tools/run_audits.sh')
-rwxr-xr-xtools/run_audits.sh52
1 files changed, 52 insertions, 0 deletions
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