name: Validate alert rules on: pull_request: paths: - 'rules/**' jobs: validate: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Install promtool run: | PROM_VERSION="2.51.0" wget -q https://github.com/prometheus/prometheus/releases/download/v${PROM_VERSION}/prometheus-${PROM_VERSION}.linux-amd64.tar.gz tar xf prometheus-*.tar.gz sudo mv prometheus-*/promtool /usr/local/bin/ - name: Validate rules run: | for f in rules/*.yaml; do echo "→ Validation de $f" python3 -c " import yaml, sys with open('$f') as fh: doc = yaml.safe_load(fh) groups = doc.get('spec', doc).get('groups', []) print(yaml.dump({'groups': groups})) " > /tmp/rules-flat.yaml promtool check rules /tmp/rules-flat.yaml done