From 02646c34693b43e10a81175c96a0f24b9dde4e3b Mon Sep 17 00:00:00 2001 From: sed-i <82407168+sed-i@users.noreply.github.com> Date: Wed, 4 Jan 2023 13:40:15 -0500 Subject: [PATCH 1/2] Add workflow for rule validation --- .github/workflows/_quality-checks.yaml | 3 +++ .github/workflows/_validate_rules.yaml | 22 ++++++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 .github/workflows/_validate_rules.yaml diff --git a/.github/workflows/_quality-checks.yaml b/.github/workflows/_quality-checks.yaml index fb8149f..066c968 100644 --- a/.github/workflows/_quality-checks.yaml +++ b/.github/workflows/_quality-checks.yaml @@ -43,6 +43,9 @@ jobs: linting: name: Linting uses: canonical/observability/.github/workflows/_linting.yaml@main + validate-rules: + name: Validate rules + uses: canonical/observability/.github/workflows/_validate_rules.yaml@main unit-test: name: Unit Tests uses: canonical/observability/.github/workflows/_unit-tests.yaml@main diff --git a/.github/workflows/_validate_rules.yaml b/.github/workflows/_validate_rules.yaml new file mode 100644 index 0000000..218c3f3 --- /dev/null +++ b/.github/workflows/_validate_rules.yaml @@ -0,0 +1,22 @@ +name: Validate rules + +on: + workflow_call: {} + +jobs: + rules: + name: Lint alert rules + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 1 + - name: Install dependencies + run: | + wget https://github.com/canonical/cos-tool/releases/download/rel-20220621/cos-tool-amd64 + chmod +x ./cos-tool-amd64 + - name: Validate prometheus alert rules + run: find . -path '*/prometheus_alert_rules/*' -type f -exec ./cos-tool-amd64 --format promql lint {} \; + - name: Validate loki alert rules + run: find . -path '*/loki_alert_rules/*' -type f -exec ./cos-tool-amd64 --format logql lint {} \; From 52e436d1e9950bf5bfbd04af844c9b91c03f85f3 Mon Sep 17 00:00:00 2001 From: sed-i <82407168+sed-i@users.noreply.github.com> Date: Wed, 4 Jan 2023 13:50:30 -0500 Subject: [PATCH 2/2] Fix exec --- .github/workflows/_validate_rules.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/_validate_rules.yaml b/.github/workflows/_validate_rules.yaml index 218c3f3..48e1595 100644 --- a/.github/workflows/_validate_rules.yaml +++ b/.github/workflows/_validate_rules.yaml @@ -17,6 +17,6 @@ jobs: wget https://github.com/canonical/cos-tool/releases/download/rel-20220621/cos-tool-amd64 chmod +x ./cos-tool-amd64 - name: Validate prometheus alert rules - run: find . -path '*/prometheus_alert_rules/*' -type f -exec ./cos-tool-amd64 --format promql lint {} \; + run: find . -path '*/prometheus_alert_rules/*' -type f -exec ./cos-tool-amd64 --format promql lint {} + - name: Validate loki alert rules - run: find . -path '*/loki_alert_rules/*' -type f -exec ./cos-tool-amd64 --format logql lint {} \; + run: find . -path '*/loki_alert_rules/*' -type f -exec ./cos-tool-amd64 --format logql lint {} +