Skip to content

Commit

Permalink
Merge pull request #1 from Akinari1087/master
Browse files Browse the repository at this point in the history
Add Unit Test Rules Hook
  • Loading branch information
fortman authored Jun 23, 2020
2 parents 41c2800 + 47eac34 commit b817aa7
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .pre-commit-hooks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,14 @@
args:
- check
- rules

- id: test-rules
stages: [commit]
name: Unit test prometheus rule files
description: Unit test prometheus rule files
language: docker_image
entry: --entrypoint /bin/promtool prom/prometheus:latest
files: ^$
args:
- test
- rules
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,18 @@ To lint Prometheus Config files, use the `prometheus-config` hook. Make sure to
(?x)^(
config_directory/.*\.yml
)$

To unit-test Prometheus Rule files, use the `test-rules` hook. Make sure to filter files passed to hook by defining the `files` section. Note: the `entry` option below is optional and will default to the latest prometheus version. It is shown just as an example of pinning to a specific prometheus version.

In the example provided, we are setting this to always run as rule files could be changed without altering the unit tests. Unit tests should be run against their respective rule files after any change.

- repo: https://github.com/fortman/pre-commit-prometheus
rev: v1.2.0
hooks:
- id: test-rules
entry: --entrypoint /bin/promtool prom/prometheus:v2.18.2
always_run: true
files: >
(?x)^(
unit_test_directory/.*\.yml
)$

0 comments on commit b817aa7

Please sign in to comment.