-
Notifications
You must be signed in to change notification settings - Fork 23
87 lines (75 loc) · 2.51 KB
/
test.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# This is a GitHub workflow defining a set of jobs with a set of steps.
# ref: https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions
#
name: Tests
on:
pull_request:
paths-ignore:
- "docs/**"
- ".github/workflows/*.yaml"
- "!.github/workflows/test.yaml"
push:
paths-ignore:
- "docs/**"
- ".github/workflows/*.yaml"
- "!.github/workflows/test.yaml"
branches-ignore:
- "dependabot/**"
- "pre-commit-ci-update-config"
tags: ["**"]
workflow_dispatch:
jobs:
render-lint-dashboards:
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
jsonnet-version: ["0.20.0"]
steps:
- uses: actions/checkout@v4
- name: Download jsonnet (go-jsonnet)
run: |
JSONNET_VERSION=${{ matrix.jsonnet-version }}
wget -qO- https://github.com/google/go-jsonnet/releases/download/v${JSONNET_VERSION}/go-jsonnet_${JSONNET_VERSION}_Linux_x86_64.tar.gz \
| tar -xvz --one-top-level=$HOME/.local/bin
- run: jsonnet --version
- name: Render dashboards
run: |
mkdir rendered-dashboards
dashboard_folders="dashboards"
for file in `find $dashboard_folders -name '*.jsonnet'`
do
jsonnet -J vendor --output-file rendered-dashboards/`basename $file` $file
done
- name: Install dashboard-linter
run: |
go install github.com/grafana/dashboard-linter@latest
echo "$HOME/go/bin" >> "$GITHUB_PATH"
- name: dashboard-linter rules
run: |
echo "Available rules are documented in https://github.com/grafana/dashboard-linter/blob/main/docs/index.md#rules"
echo ""
dashboard-linter rules
- name: dashboard-linter lint
run: |
lint_failures=""
dashboard_folders=rendered-dashboards
for file in `find $dashboard_folders -name '*.jsonnet'`
do
lint_fail=""
echo "::group::$file"
dashboard-linter lint --strict $file || lint_fail=1
echo "::endgroup::"
if [ -n "$lint_fail" ]; then
lint_failures="$lint_failures $file";
fi
done
if [ -n "$lint_failures" ]; then
echo ""
echo "dashboard-linter errored for:"
for file in $lint_failures
do
echo `basename $file`
done
exit 1
fi