forked from redhat-appstudio/o11y
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
71 lines (58 loc) · 2.44 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
PINT_VERSION = 0.42.2
PROMTOOL_VERSION = 2.42.0
YQ_VERSION = 4.31.2
EXTRACTED_RULE_FILE = test/promql/extracted-rules.yaml
RECORDING_RULE_FILES = prometheus/base/recording/*.yaml
ALERTING_RULE_FILES = prometheus/base/alerting/*.yaml
.PHONY: all
all: prepare sync_pipenv lint test_rules pint_lint lint_yamls kustomize_build
.PHONY: prepare
prepare: pint promtool yq kustomize
echo "Extract Prometheus rules"
(./yq eval-all '. as $$item ireduce ({}; . *+ $$item)' ${RECORDING_RULE_FILES} ${ALERTING_RULE_FILES} | ./yq ".spec" ) > ${EXTRACTED_RULE_FILE}
.PHONY: lint
lint:
echo "Running Prometheus rules linter tests"
./promtool check rules ${EXTRACTED_RULE_FILE}
.PHONY: test_rules
test_rules:
echo "Running Prometheus rules unit tests"
./promtool test rules test/promql/tests/*
pint:
echo 'Installing pint...'
curl -OJL 'https://github.com/cloudflare/pint/releases/download/v${PINT_VERSION}/pint-${PINT_VERSION}-linux-amd64.tar.gz'
tar xvzf 'pint-${PINT_VERSION}-linux-amd64.tar.gz' pint-linux-amd64
mv pint-linux-amd64 pint
rm 'pint-${PINT_VERSION}-linux-amd64.tar.gz'
promtool:
echo "Installing promtool..."
curl -OJL "https://github.com/prometheus/prometheus/releases/download/v${PROMTOOL_VERSION}/prometheus-${PROMTOOL_VERSION}.linux-amd64.tar.gz"
tar xvzf "prometheus-${PROMTOOL_VERSION}.linux-amd64.tar.gz" "prometheus-${PROMTOOL_VERSION}.linux-amd64"/promtool --strip-components=1
rm -f prometheus-${PROMTOOL_VERSION}.linux-amd64.tar.gz
yq:
echo "Installing yq..."
curl -OJL "https://github.com/mikefarah/yq/releases/download/v${YQ_VERSION}/yq_linux_amd64.tar.gz"
tar xvzf yq_linux_amd64.tar.gz ./yq_linux_amd64
rm -f yq_linux_amd64.tar.gz
mv yq_linux_amd64 yq
kustomize:
curl -s "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" | bash
.PHONY: pint_lint
pint_lint:
echo "Linting Prometheus rules..."
./pint --no-color lint ${EXTRACTED_RULE_FILE}
.PHONY: install_pipenv
install_pipenv:
python3 -m pip install pipenv
.PHONY: sync_pipenv
sync_pipenv:
python3 -m pipenv sync --dev
.PHONY: lint_yamls
lint_yamls:
python3 -m pipenv run yamllint . && echo "lint_yamls: SUCCESS"
.PHONY: kustomize_build
kustomize_build:
# This validates that the build command passes and not its output's validity.
# It will fail once we have more than one subdirectory, which will prevent us from
# adding untested configurations (this target will have to chage when that happens).
./kustomize build prometheus/* 1>/dev/null