Skip to content

Commit

Permalink
Merge pull request #106 from consideRatio/pr/test-dashboard-render
Browse files Browse the repository at this point in the history
Add test to render and lint dashboards
  • Loading branch information
consideRatio authored Apr 6, 2024
2 parents a537432 + 6dbaf51 commit b8e2868
Show file tree
Hide file tree
Showing 3 changed files with 107 additions and 0 deletions.
16 changes: 16 additions & 0 deletions .github/dependabot.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# dependabot.yaml reference: https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
#
# Notes:
# - Status and logs from dependabot are provided at
# https://github.com/jupyterhub/grafana-dashboards/network/updates.
#
version: 2
updates:
# Maintain dependencies in our GitHub Workflows
- package-ecosystem: github-actions
directory: /
labels: [ci]
schedule:
interval: monthly
time: "05:00"
timezone: Etc/UTC
87 changes: 87 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,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 global-dashboards"
for file in `find $dashboard_folders -name '*.jsonnet'`
do
jsonnet -J vendor --tla-code 'datasources=["prometheus-test"]' --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
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
rendered-dashboards

# ---

# Binaries for programs and plugins
*.exe
*.exe~
Expand Down

0 comments on commit b8e2868

Please sign in to comment.