Skip to content

Commit

Permalink
Merge pull request #958 from rexagod/pint
Browse files Browse the repository at this point in the history
chore: add pint
  • Loading branch information
povilasv authored Jul 18, 2024
2 parents 766beaf + a97d59b commit e4a4969
Show file tree
Hide file tree
Showing 6 changed files with 430 additions and 415 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ jobs:
run: make --always-make vale && git diff --exit-code
- name: Jsonnet linter
run: make --always-make jsonnet-lint
- name: YAML linter (Pint)
run: make --always-make pint-lint
- name: Unit tests
run: make --always-make test

Expand Down
15 changes: 12 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ MD_FILES = $(shell find . \( -type d -name '.vale' -o -type d -name 'vendor' \)
MARKDOWNFMT_BIN=$(BIN_DIR)/markdownfmt
VALE_BIN=$(BIN_DIR)/vale
PROMTOOL_BIN=$(BIN_DIR)/promtool
TOOLING=$(JB_BIN) $(JSONNETLINT_BIN) $(JSONNET_BIN) $(JSONNETFMT_BIN) $(PROMTOOL_BIN) $(GRAFANA_DASHBOARD_LINTER_BIN) $(MARKDOWNFMT_BIN) $(VALE_BIN)
PINT_BIN=$(BIN_DIR)/pint
TOOLING=$(JB_BIN) $(JSONNETLINT_BIN) $(JSONNET_BIN) $(JSONNETFMT_BIN) $(PROMTOOL_BIN) $(GRAFANA_DASHBOARD_LINTER_BIN) $(MARKDOWNFMT_BIN) $(VALE_BIN) $(PINT_BIN)
JSONNETFMT_ARGS=-n 2 --max-blank-lines 2 --string-style s --comment-style s
SRC_DIR ?=dashboards
OUT_DIR ?=dashboards_out
Expand Down Expand Up @@ -44,7 +45,7 @@ $(OUT_DIR): $(JSONNET_BIN) $(JSONNET_VENDOR) mixin.libsonnet lib/dashboards.json
@$(JSONNET_BIN) -J vendor -m $(OUT_DIR) lib/dashboards.jsonnet

.PHONY: lint
lint: jsonnet-lint alerts-lint dashboards-lint vale
lint: jsonnet-lint alerts-lint dashboards-lint vale pint-lint

.PHONY: jsonnet-lint
jsonnet-lint: $(JSONNETLINT_BIN) $(JSONNET_VENDOR)
Expand All @@ -67,10 +68,18 @@ dashboards-lint: $(GRAFANA_DASHBOARD_LINTER_BIN) $(OUT_DIR)/.lint

.PHONY: vale
vale: $(VALE_BIN)
@echo $(MD_FILES)
@$(VALE_BIN) sync && \
$(VALE_BIN) $(MD_FILES)

.PHONY: pint-lint
pint-lint: generate $(PINT_BIN)
@# Pint will not exit with a non-zero status code if there are linting issues.
@output=$$($(PINT_BIN) -n -o -l WARN lint prometheus_alerts.yaml prometheus_rules.yaml 2>&1); \
if [ -n "$$output" ]; then \
echo "\n$$output"; \
exit 1; \
fi

.PHONY: clean
clean:
# Remove all files and directories ignored by git.
Expand Down
2 changes: 1 addition & 1 deletion alerts/apps_alerts.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@
{
expr: |||
(
max without (revision) (
max by(namespace, statefulset) (
kube_statefulset_status_current_revision{%(prefixedNamespaceSelector)s%(kubeStateMetricsSelector)s}
unless
kube_statefulset_status_update_revision{%(prefixedNamespaceSelector)s%(kubeStateMetricsSelector)s}
Expand Down
Loading

0 comments on commit e4a4969

Please sign in to comment.