#!/usr/bin/env bash # ci/prom-rules.sh — Stage: Prometheus RULE-UNIT tests (no cluster; live now). # # Thin wrapper over platform/monitoring/tests/run.sh, which runs `promtool test rules` against the # COMMITTED PrometheusRule manifests. It is a gate stage because the two alerting defects this repo # has actually shipped — a permanently-firing rule and a structurally INERT one — are both invisible # to every other stage: yamllint parses them, Kyverno admits them, and a healthy cluster cannot tell # a correct alert from one that can never fire. Only the bad state, constructed on purpose, can. # # Exit codes per ci/lib.sh: 0 pass / 1 fail / 3 skipped (never green). set -euo pipefail CI_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" # shellcheck disable=SC1091 source "${CI_DIR}/lib.sh" log "Stage: Prometheus rule-unit tests (promtool test rules; no cluster)" RUNNER="${REPO_ROOT}/platform/monitoring/tests/run.sh" if [ ! -x "$RUNNER" ]; then skip "rule-unit harness not present at ${RUNNER} — UNWIRED, not green" summary "- prom-rules: **SKIPPED** (harness missing)" exit 3 fi set +e "$RUNNER" rc=$? set -e case "$rc" in 0) ok "Prometheus rule-unit tests passed" summary "- prom-rules: **passed**" ;; 3) skip "promtool unavailable (no promtool on PATH, no podman/docker) — NOT green" summary "- prom-rules: **SKIPPED** (promtool toolchain unavailable)" ;; *) err "Prometheus rule-unit tests FAILED" summary "- prom-rules: **FAILED**" ;; esac exit "$rc"