Skip to content

Commit

Permalink
*: run promtool checks on all PrometheusRule objects
Browse files Browse the repository at this point in the history
  • Loading branch information
paulfantom committed Feb 12, 2021
1 parent 01452a9 commit 31f8be6
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/prometheusrule.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
name: prom-rules

on:
push:
branches: [master]
pull_request:
branches: [master]

jobs:
verify:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: '1.15'
- run: go get -u github.com/prometheus/prometheus/cmd/promtool
- run: verify-prometheus-rules.sh
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ bin/
templates/
vendor/
crdschemas/
tmp/
12 changes: 12 additions & 0 deletions hack/verify-prometheus-rules.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

set -euo pipefail

mkdir -p tmp/rules

for f in $(grep -ir --include=*.yaml "PrometheusRule" . | grep kind | grep -v CustomResourceDefinition | sed 's/:.*//'); do
echo "$f"
tmpfile="$(echo "$f" | sed 's/\//-/g' | sed 's/.-//').json"
gojsontoyaml -yamltojson < "$f" | jq .spec > "tmp/rules/$tmpfile";
( cd tmp/rules && promtool check rules "$tmpfile")
done

0 comments on commit 31f8be6

Please sign in to comment.