diff --git a/.github/workflows/test-alerts.yaml b/.github/workflows/test-alerts.yaml new file mode 100644 index 000000000..02f56f53c --- /dev/null +++ b/.github/workflows/test-alerts.yaml @@ -0,0 +1,31 @@ +name: Test + +on: + push: + branches: + - main + paths: + - examples/alerts/** + pull_request: + branches: + - main + paths: + - 'examples/alerts/**' +jobs: + promql-tests: + name: Promql Tests + runs-on: ubuntu-latest + defaults: + run: + shell: bash + steps: + - name: Set up Go 1.21.x + uses: actions/setup-go@v4 + with: + go-version: 1.21.x + id: go + - name: Check out code + uses: actions/checkout@v4 + - name: Run Promql tests + run: | + make test-alerts diff --git a/examples/alerts/README.md b/examples/alerts/README.md index e6dd9d8bc..4fdd62f45 100644 --- a/examples/alerts/README.md +++ b/examples/alerts/README.md @@ -37,5 +37,7 @@ make sloth-generate There are also two matching unit tests to verify and test the alerts that Sloth has generated. These can be run using the make target: ``` -make alerts-tests +make test-alerts ``` + +Note: The prometheus unit tests will also run via Github actions when a change is made in the alerts file. diff --git a/make/alerts.mk b/make/alerts.mk index 5b052e4ff..fd4499443 100644 --- a/make/alerts.mk +++ b/make/alerts.mk @@ -21,7 +21,7 @@ container-runtime-tool: exit 1; \ fi)) -alerts-tests: container-runtime-tool ## Test alerts using promtool +test-alerts: container-runtime-tool ## Test alerts using promtool $(CONTAINER_RUNTIME_BIN) run --rm -t \ -v $(AVAILABILITY_SLO_RULES):/prometheus/slo-availability.yaml \ -v $(LATENCY_SLO_RULES):/prometheus/slo-latency.yaml \