-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
152 lines (115 loc) · 4.81 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
SHELL := /usr/bin/env bash
# Exclude vendor and dot directories, but do include the `.gitlab` directory
VERIFY_PATH_SELECTOR := \( -not \( -path "*/vendor/*" -o -path "*/.*/*" \) -o -path "*/.gitlab/*" \)
JSONNET_FMT_FLAGS := --string-style s -n 2
JSONNET_FILES ?= $(shell find . \( -name "*.jsonnet" -o -name "*.libsonnet" \) -type f $(VERIFY_PATH_SELECTOR) )
SHELL_FMT_FLAGS := -i 2 -ci
SHELL_FILES = $(shell find . -type f \( -perm -u=x -o -name "*.sh" \) $(VERIFY_PATH_SELECTOR) -print0|xargs -0 file -n |grep 'Bourne-Again'|cut -d: -f1)
AMTOOL = $(shell which amtool || echo "/alertmanager/amtool")
AMTOOL_PATH=$(dir $(AMTOOL))
JSONET_COMMAND = $(shell which jsonnetfmt || (which jsonnet && echo " fmt"))
PROMTOOL_COMMAND = $(shell which promtool || echo "/prometheus/promtool")
SHELLCHECK_FLAGS := -e SC1090,SC1091,SC2002
.PHONY: help
help: ## Lists all available commands
@fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/\\$$//' | sed -e 's/##//'
.PHONY: all
all: verify
.PHONY: verify
verify: verify-shellcheck verify-fmt
.PHONY: verify-fmt
verify-fmt:
if ! $(JSONET_COMMAND) $(JSONNET_FMT_FLAGS) --test $(JSONNET_FILES) ; then $(JSONET_COMMAND) $(JSONNET_FMT_FLAGS) -i $(JSONNET_FILES); git --no-pager diff; exit 1; fi
shfmt $(SHELL_FMT_FLAGS) -l -d $(SHELL_FILES)
.PHONY: verify-shellcheck
verify-shellcheck:
shellcheck $(SHELLCHECK_FLAGS) $(SHELL_FILES)
.PHONY: fmt
fmt: jsonnet-fmt shell-fmt
git diff --exit-code
.PHONY: jsonnet-fmt
jsonnet-fmt:
$(JSONET_COMMAND) $(JSONNET_FMT_FLAGS) -i $(JSONNET_FILES)
.PHONY: shell-fmt
shell-fmt:
shfmt $(SHELL_FMT_FLAGS) -w $(SHELL_FILES)
.PHONY: generate
generate:
./scripts/generate.sh
alertmanager/alertmanager.yml: alertmanager/alertmanager.jsonnet
./alertmanager/generate.sh
test-alertmanager: alertmanager/alertmanager.yml
$(AMTOOL) check-config alertmanager/alertmanager.yml
PATH=$(AMTOOL_PATH):$(PATH) alertmanager/test-routing.sh alertmanager/alertmanager.yml
.PHONY: test
test: validate-service-dashboards validate-service-catalog validate-prom-rules validate-kibana-urls validate-alerts validate-yaml jsonnet-bundle test-jsonnet test-shunit
.PHONY: validate-service-catalog
validate-service-catalog:
./scripts/validate-service-catalog.rb
.PHONY: validate-service-dashboards
validate-service-dashboards:
./scripts/validate-service-dashboards
.PHONY: validate-prom-rules
validate-prom-rules:
./scripts/validate-recording-rule-groups
.PHONY: validate-kibana-urls
validate-kibana-urls:
./scripts/validate_kibana_urls
.PHONY: validate-alerts
validate-alerts:
./scripts/validate-alerts
.PHONY:validate-yaml
validate-yaml:
@if ! command -v yamllint >/dev/null; then echo "Please install yamllint: https://yamllint.readthedocs.io/en/stable/quickstart.html#installing-yamllint"; exit 1; fi
yamllint -f colored .
.PHONY: test-jsonnet
test-jsonnet:
./scripts/jsonnet_test.sh
.PHONY: test-shunit
test-shunit:
./test/custom-reference-architecture_test.sh
.PHONY: test-alert-templates
test-alert-templates:
cd alertmanager/templates && go test -v ./...
.PHONY: jsonnet-bundle
jsonnet-bundle:
./scripts/bundler.sh
# Checks the `make generate` doesn't modify any files, or create any new files
.PHONY: ensure-generated-content-up-to-date
ensure-generated-content-up-to-date: generate
(git diff --exit-code && \
[[ "$$(git ls-files -o --directory --exclude-standard | sed q | wc -l)" == "0" ]]) || \
(echo "Please run 'make generate'" && exit 1)
.PHONY: .update-feature-categories
.update-feature-categories:
./scripts/update_stage_groups_feature_categories.rb && ./scripts/update_stage_groups_dashboards.rb && ./scripts/update_stage_error_budget_dashboards.rb
.PHONY: generate-crossover-mappings
generate-crossover-mappings:
./scripts/generate_crossover_stage_group_mappings.rb
.PHONY: update-feature-categories
update-feature-categories: .update-feature-categories generate-crossover-mappings generate
# In CI, we don't want to generate crossover mappings, as those depend on a git
# diff compared to the previous HEAD.
.PHONY: update-feature-categories-ci
update-feature-categories-ci: .update-feature-categories generate
.PHONY: validate-mimir-rules
validate-mimir-rules:
@for dir in $$(find mimir-rules -mindepth 1 -maxdepth 1 -type d); do \
tenant=$$(basename $${dir}); \
echo "Checking rules for tenant: $${tenant}"; \
mimirtool rules check --rule-dirs="$${dir}"; \
done
.PHONY: generate-mixins
generate-mixins:
./scripts/generate-mixins.sh
# Ensure that you have Graphviz and Python installed
# Instructions at https://diagrams.mingrammer.com/docs/getting-started/installation
# then install `pip install diagrams`
diagrams:
./scripts/make-diagrams
glsh-install:
ln -s $$PWD/glsh.sh /usr/local/bin/glsh
build-docker-image:
docker build -t runbooks \
$(shell awk '/^[^# ]/ { gsub("-", "_", $$1); print "--build-arg=GL_ASDF_" toupper($$1) "_VERSION=" $$2 }' .tool-versions) \
.