79 lines
2.1 KiB
Bash
Executable File
79 lines
2.1 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
failures=0
|
|
warnings=0
|
|
|
|
score() {
|
|
local label="$1"
|
|
local severity="$2"
|
|
shift 2
|
|
local output
|
|
local summary
|
|
local status
|
|
|
|
printf '%-28s ' "$label"
|
|
set +e
|
|
output="$("$@" 2>&1)"
|
|
status=$?
|
|
set -e
|
|
if [ "$status" -eq 0 ]; then
|
|
printf 'pass\n'
|
|
return 0
|
|
fi
|
|
if [ "$severity" = "fail" ]; then
|
|
failures=$((failures + 1))
|
|
printf 'fail'
|
|
else
|
|
warnings=$((warnings + 1))
|
|
printf 'warn'
|
|
fi
|
|
summary="$(
|
|
printf '%s\n' "$output" |
|
|
awk 'NF && $0 !~ /^\+/ { print; exit }'
|
|
)"
|
|
if [ -z "$summary" ]; then
|
|
summary="check exited with status ${status}"
|
|
fi
|
|
printf ' - %s' "$summary"
|
|
printf '\n'
|
|
}
|
|
|
|
docs_fresh() {
|
|
"${REPO_ROOT}/scripts/render-docs" --check >/dev/null
|
|
}
|
|
|
|
inventory_ok() {
|
|
"${REPO_ROOT}/scripts/validate-homelab-inventory" "${HOMELAB_INVENTORY_FILE:-${REPO_ROOT}/homelab.yml}" >/dev/null
|
|
}
|
|
|
|
security_static_ok() {
|
|
"${REPO_ROOT}/scripts/validate-tailnet-policy" >/dev/null
|
|
}
|
|
|
|
printf 'Homelab scorecard\n'
|
|
printf '=================\n\n'
|
|
|
|
score "Inventory" fail inventory_ok
|
|
score "Documentation freshness" warn docs_fresh
|
|
score "Backup readiness" fail "${REPO_ROOT}/scripts/backup-status"
|
|
score "GitOps health" warn "${REPO_ROOT}/scripts/gitops-status"
|
|
score "DNS and RPi health" fail "${REPO_ROOT}/jeannie" doctor-rpi
|
|
score "Cluster health" fail "${REPO_ROOT}/jeannie" doctor-cluster
|
|
score "Edge health" fail "${REPO_ROOT}/jeannie" doctor-edge
|
|
score "Capacity pressure" warn "${REPO_ROOT}/scripts/resource-budget"
|
|
score "Security posture" warn security_static_ok
|
|
score "Public certificates" warn "${REPO_ROOT}/scripts/cert-check"
|
|
|
|
printf '\nSummary: failures=%s warnings=%s\n' "$failures" "$warnings"
|
|
if [ "$failures" -gt 0 ]; then
|
|
printf 'Focus on the failed categories first, then clear warnings.\n'
|
|
exit 1
|
|
fi
|
|
if [ "$warnings" -gt 0 ]; then
|
|
printf 'No blocking failures, but warnings need cleanup.\n'
|
|
exit 0
|
|
fi
|
|
printf 'Scorecard passed.\n'
|