Skip to content

Lint_slo_doc

FieldValue
TypeSkill Resource
Source~/.copilot/skills/platform/scripts/lint_slo_doc.sh
DescriptionNot specified

Source Content

#!/usr/bin/env bash
# Validate an SLO doc (Markdown or YAML): every SLO has an explicit SLI +
# numeric target + error-budget window, and every alert references a runbook
# link and a paired dashboard/panel mention. Pure text/regex parsing
# (python3 stdlib, no deps) — there is no off-the-shelf tool for "does this
# SLO doc have complete fields", so this check is 100% custom, honestly
# labeled as such below. `yamllint` is used as a bonus structural check when
# the target is a .yaml/.yml file and yamllint is on PATH — degrades to a
# skipped warning if absent, same pattern as helm/scripts/lint_chart.sh.
#
# Usage:
# lint_slo_doc.sh [slo-doc.md|slo-doc.yaml]
#
# Example:
# scripts/lint_slo_doc.sh ./slo.md
set -uo pipefail
DOC="${1:-./slo.md}"
fail=0
warn() { printf '⚠️ %s\n' "$1"; }
error() { printf '❌ %s\n' "$1"; fail=1; }
ok() { printf '✅ %s\n' "$1"; }
if [[ ! -f "$DOC" ]]; then
echo "Usage: $0 [slo-doc.md|slo-doc.yaml]" >&2
echo "File not found: $DOC" >&2
exit 2
fi
case "$DOC" in
*.yaml|*.yml)
echo "== yamllint (bonus structural check on YAML) =="
if command -v yamllint >/dev/null 2>&1; then
if yamllint "$DOC"; then
ok "yamllint clean"
else
error "yamllint reported errors"
fi
else
warn "yamllint not on PATH — skipped (install: pip install yamllint)"
fi
echo
;;
esac
echo "== SLI + numeric target + error-budget window, per SLO; runbook + dashboard, per alert =="
py_out=$(python3 "$(dirname "$0")/_lint_slo_doc.py" "$DOC")
py_status=$?
while IFS= read -r line; do
case "$line" in
OK::*) ok "${line#OK::}" ;;
ERROR::*) error "${line#ERROR::}" ;;
*) [[ -n "$line" ]] && echo "$line" ;;
esac
done <<< "$py_out"
if [[ "$py_status" -ne 0 ]]; then
fail=1
fi
echo
if [[ "$fail" -eq 0 ]]; then
echo "All checks passed."
else
echo "One or more checks failed — see ❌ lines above."
fi
exit "$fail"