Skip to content

Commit 9e4ea6e

Browse files
committed
test
1 parent ae0f1ae commit 9e4ea6e

File tree

1 file changed

+52
-19
lines changed

1 file changed

+52
-19
lines changed

.github/workflows/test.yaml

Lines changed: 52 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -33,34 +33,67 @@ jobs:
3333
- uses: actions/checkout@v4
3434

3535
# Based on https://github.com/zendesk/setup-jsonnet/blob/master/install-jsonnet.sh
36-
- name: Install jsonnet
36+
- name: Install jsonnet (go-jsonnet)
3737
run: |
3838
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-
4339
echo "$HOME/go/bin" >> "$GITHUB_PATH"
4440
45-
- name: jsonnet --version
41+
- run: jsonnet --version
42+
43+
- name: Render dashboards
4644
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
4851
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
5457

5558
lint-dashboards:
5659
runs-on: ubuntu-22.04
60+
needs: [render-dashboards]
5761

5862
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
6491
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

Comments
 (0)