@@ -33,34 +33,67 @@ jobs:
33
33
- uses : actions/checkout@v4
34
34
35
35
# Based on https://github.com/zendesk/setup-jsonnet/blob/master/install-jsonnet.sh
36
- - name : Install jsonnet
36
+ - name : Install jsonnet (go-jsonnet)
37
37
run : |
38
38
go install "github.com/google/go-jsonnet/cmd/jsonnet@${{ matrix.jsonnet-version }}"
39
- go install "github.com/google/go-jsonnet/cmd/jsonnetfmt@${{ matrix.jsonnet-version }}"
40
- go install "github.com/google/go-jsonnet/cmd/jsonnet-deps@${{ matrix.jsonnet-version }}"
41
- go install "github.com/google/go-jsonnet/cmd/jsonnet-lint@${{ matrix.jsonnet-version }}"
42
-
43
39
echo "$HOME/go/bin" >> "$GITHUB_PATH"
44
40
45
- - name : jsonnet --version
41
+ - run : jsonnet --version
42
+
43
+ - name : Render dashboards
46
44
run : |
47
- jsonnet --version
45
+ mkdir rendered-dashboards
46
+ dashboard_folders="dashboards global-dashboards"
47
+ for file in `find $dashboard_folders -name '*.jsonnet'`
48
+ do
49
+ jsonnet -J vendor --tla-code 'datasources=["prometheus-test"]' --output-file rendered-dashboards/`basename $file` $file
50
+ done
48
51
49
- # - name: Upload rendered dashboards
50
- # uses: actions/upload-artifact@v4
51
- # with:
52
- # name: dist -${{ github.run_attempt }}
53
- # path: ./dist
52
+ - name : Upload rendered dashboards
53
+ uses : actions/upload-artifact@v4
54
+ with :
55
+ name : rendered-dashboards -${{ github.run_attempt }}
56
+ path : ./rendered-dashboards
54
57
55
58
lint-dashboards :
56
59
runs-on : ubuntu-22.04
60
+ needs : [render-dashboards]
57
61
58
62
steps :
59
- # - name: Download built artifacts
60
- # uses: actions/download-artifact@v4
61
- # with:
62
- # name: dist-${{ github.run_attempt }}
63
- # path: ./dist
63
+ - name : Download rendered dashboards
64
+ uses : actions/download-artifact@v4
65
+ with :
66
+ name : rendered-dashboards-${{ github.run_attempt }}
67
+ path : ./rendered-dashboards
68
+
69
+ - name : Install dashboard-linter
70
+ run : |
71
+ go install github.com/grafana/dashboard-linter@latest
72
+ echo "$HOME/go/bin" >> "$GITHUB_PATH"
73
+
74
+ - run : dashboard-linter rules
75
+
76
+ - name : Lint rendered dashboards
77
+ run : |
78
+ lint_failures=""
79
+
80
+ dashboard_folders=rendered-dashboards
81
+ for file in `find $dashboard_folders -name '*.jsonnet'`
82
+ do
83
+ lint_fail=""
84
+ echo "::group::$file"
85
+ dashboard-linter lint --strict $file || lint_fail=1
86
+ echo "::endgroup::"
87
+ if [ -n "$lint_fail" ]; then
88
+ lint_failures="$lint_failures $file";
89
+ fi
90
+ done
64
91
65
- - run : |
66
- echo duh
92
+ if [ -n "$lint_failures" ]; then
93
+ echo "dashboard-linter errored for the following rendered dashboards:"
94
+ for file in $lint_failures
95
+ do
96
+ echo basename $file
97
+ done
98
+ exit 1
99
+ fi
0 commit comments