Skip to content
This repository was archived by the owner on Apr 2, 2024. It is now read-only.

Commit 70161d8

Browse files
committed
.github: add dashboard linter to CI
1 parent 7836383 commit 70161d8

File tree

3 files changed

+24
-5
lines changed

3 files changed

+24
-5
lines changed

.github/workflows/mixin.yml

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ name: mixin
22
on:
33
push:
44
paths:
5-
- 'docs/mixin/alerts/*.yml'
5+
- 'docs/mixin/**'
66
pull_request:
77
paths:
8-
- 'docs/mixin/alerts/*.yml'
8+
- 'docs/mixin/**'
99

1010
env:
1111
golang-version: 1.18.0
@@ -27,7 +27,16 @@ jobs:
2727
with:
2828
go-version: ${{ env.golang-version }}
2929

30+
- name: download dashboard linter
31+
run: go install -a github.com/grafana/dashboard-linter@latest
32+
3033
- name: download promtool
31-
run: go install -a github.com/prometheus/prometheus/cmd/promtool@latest
32-
33-
- run: make check-alerts
34+
run: |
35+
VERSION=$(curl -s https://api.github.com/repos/prometheus/prometheus/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3)}' | sed 's/v//')
36+
curl -s -L "https://github.com/prometheus/prometheus/releases/download/v${VERSION}/prometheus-${VERSION}.linux-amd64.tar.gz" | tar -zxf - -C "${GITHUB_WORKSPACE}/" --strip-components 1 "prometheus-${VERSION}.linux-amd64/promtool"
37+
38+
- run: |
39+
PATH="${PATH}:${GITHUB_WORKSPACE}"
40+
make check-alerts
41+
42+
- run: make check-dashboards

Makefile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,11 @@ check-alerts:
4444
# go install -a github.com/prometheus/prometheus/cmd/promtool@latest
4545
promtool check rules docs/mixin/alerts/alerts.yaml
4646

47+
.PHONY: check-dashboards
48+
check-dashboards:
49+
# If you don't have promtool, install it with
50+
# go install -a github.com/grafana/dashboard-linter@latest
51+
find docs/mixin/dashboards -name '*.json' -print0 | xargs -n 1 -0 dashboard-linter lint
52+
4753
.PHONY: all
4854
all: build test go-fmt go-lint

docs/mixin/dashboards/.lint

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Those exclusions are needed due to usage of newer dashboard schema
2+
exclusions:
3+
template-datasource-rule:
4+
panel-datasource-rule:

0 commit comments

Comments
 (0)