Skip to content

Commit

Permalink
Update to Makefile - var assigment
Browse files Browse the repository at this point in the history
  • Loading branch information
biswassri committed Nov 18, 2024
1 parent 5a453e9 commit d07a540
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ IMAGE_BUILD_FLAGS ?= --build-arg USE_LOCAL=false
PROMETHEUS_CONFIG_YAML = ./config/monitoring/prometheus/apps/prometheus-configs.yaml
PROMETHEUS_CONFIG_DIR = ./config/monitoring/prometheus/apps
PROMETHEUS_TEST_DIR = ./tests/prometheus_unit_tests
PROMETHEUS_ALERT_TESTS = $(shell find $(PROMETHEUS_TEST_DIR) -name "*.unit-tests.yaml")
PROMETHEUS_ALERT_TESTS = $(wildcard $(PROMETHEUS_TEST_DIR)/*.unit-tests.yaml)

ALERT_SEVERITY = critical

Expand Down Expand Up @@ -387,15 +387,18 @@ CLEANFILES += cover.out
$(PROMETHEUS_TEST_DIR)/%.rules.yaml: $(PROMETHEUS_TEST_DIR)/%.unit-tests.yaml $(PROMETHEUS_CONFIG_YAML) $(YQ)
$(YQ) eval ".data.\"$(@F:.rules.yaml=.rules)\"" $(PROMETHEUS_CONFIG_YAML) > $@

PROMETHEUS_ALERT_RULES := $(PROMETHEUS_ALERT_TESTS:.unit-tests.yaml=.rules.yaml)

# Run prometheus-alert-unit-tests
.PHONY: test-alerts
test-alerts: $(PROMETHEUS_ALERT_TESTS:.unit-tests.yaml=.rules.yaml)
test-alerts: $(PROMETHEUS_ALERT_RULES)
promtool test rules $(PROMETHEUS_ALERT_TESTS)

#Check for alerts without unit-tests
.PHONY: check-prometheus-alert-unit-tests
check-prometheus-alert-unit-tests: $(PROMETHEUS_ALERT_TESTS:.unit-tests.yaml=.rules.yaml)
check-prometheus-alert-unit-tests: $(PROMETHEUS_ALERT_RULES)
./tests/prometheus_unit_tests/scripts/check_alert_tests.sh $(PROMETHEUS_CONFIG_YAML) $(PROMETHEUS_TEST_DIR) $(ALERT_SEVERITY)
CLEANFILES += $(PROMETHEUS_ALERT_RULES)

.PHONY: e2e-test
e2e-test: ## Run e2e tests for the controller
Expand All @@ -406,4 +409,3 @@ clean: $(GOLANGCI_LINT)
$(GOLANGCI_LINT) cache clean
chmod u+w -R $(LOCALBIN) # envtest makes its dir RO
rm -rf $(CLEANFILES)
rm $(PROMETHEUS_ALERT_TESTS:.unit-tests.yaml=.rules.yaml)

0 comments on commit d07a540

Please sign in to comment.