diff --git a/monitoring/ceph-mixin/Makefile b/monitoring/ceph-mixin/Makefile index 0cb7aa5393c..915481d8c14 100644 --- a/monitoring/ceph-mixin/Makefile +++ b/monitoring/ceph-mixin/Makefile @@ -4,6 +4,7 @@ fmt: ./lint-jsonnet.sh -i generate: dashboards_out + tox -ealerts-fix vendor: jsonnetfile.lock.json tox -ejsonnet-bundler-install @@ -18,7 +19,7 @@ lint: test: generate tox -ejsonnet-check tox -epromql-query-test - tox -ealerts-check + tox -ealerts-test check: test .PHONY: all fmt generate lint test check diff --git a/monitoring/ceph-mixin/alerts.jsonnet b/monitoring/ceph-mixin/alerts.jsonnet index 43826eedd21..ab7907c76fd 100644 --- a/monitoring/ceph-mixin/alerts.jsonnet +++ b/monitoring/ceph-mixin/alerts.jsonnet @@ -1 +1 @@ -std.manifestYamlDoc((import 'alerts.libsonnet').prometheusAlerts, indent_array_in_object=true, quote_keys=false) +std.manifestYamlDoc(((import 'config.libsonnet') + (import 'alerts.libsonnet')).prometheusAlerts, indent_array_in_object=true, quote_keys=false) diff --git a/monitoring/ceph-mixin/lint-jsonnet.sh b/monitoring/ceph-mixin/lint-jsonnet.sh index 6f771626982..76424568453 100755 --- a/monitoring/ceph-mixin/lint-jsonnet.sh +++ b/monitoring/ceph-mixin/lint-jsonnet.sh @@ -1,5 +1,14 @@ #!/bin/sh -e JSONNETS_FILES=$(find . -name 'vendor' -prune -o \ - -name '*.jsonnet' -print -o -name '*.libsonnet' -print) -jsonnetfmt "$@" ${JSONNETS_FILES} + -name '*.jsonnet' -print -o -name '*.libsonnet' -print) +for each_jsonnet_file in ${JSONNETS_FILES}; do + jsonnetfmt "$@" ${each_jsonnet_file} || jfmt_failed_files="$jfmt_failed_files ${each_jsonnet_file}" +done +exit_status=0 +# if variable 'jfmt_failed_files' is not empty/null +if [ -n "${jfmt_failed_files}" ]; then + echo "'jsonnetfmt' check failed on:${jfmt_failed_files}" + exit_status=1 +fi +exit $exit_status diff --git a/monitoring/ceph-mixin/tox.ini b/monitoring/ceph-mixin/tox.ini index d0d97fc98b9..90ac311edba 100644 --- a/monitoring/ceph-mixin/tox.ini +++ b/monitoring/ceph-mixin/tox.ini @@ -4,7 +4,8 @@ envlist = jsonnet-{check,lint,fix}, jsonnet-bundler-{install,update}, promql-query-{test,lint}, - alerts-check + alerts-{fix,check,lint,test} + skipsdist = true [testenv:jsonnet-bundler-{install,update}] @@ -23,7 +24,7 @@ allowlist_externals = find jb jsonnet - jsonnetfm + jsonnetfmt sh description = check: Ensure that auto-generated files matches the current version @@ -61,13 +62,14 @@ allowlist_externals = commands = behave tests_dashboards/features -[testenv:alerts-{fix,check,lint}] +[testenv:alerts-{fix,check,lint,test}] deps = -rrequirements-alerts.txt pytest depends = grafonnet-check allowlist_externals = promtool + jsonnet commands = fix: jsonnet -J vendor -S alerts.jsonnet -o prometheus_alerts.yml lint: promtool check rules prometheus_alerts.yml