Skip to content

Commit

Permalink
chore: add pint
Browse files Browse the repository at this point in the history
  • Loading branch information
rexagod committed Jul 18, 2024
1 parent 766beaf commit 0b7cdb8
Show file tree
Hide file tree
Showing 5 changed files with 436 additions and 399 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
14 changes: 12 additions & 2 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 @@ -71,6 +72,15 @@ vale: $(VALE_BIN)
@$(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
Loading

0 comments on commit 0b7cdb8

Please sign in to comment.