forked from grafana/cortex-jsonnet
-
Notifications
You must be signed in to change notification settings - Fork 10
/
Makefile
69 lines (51 loc) · 2.15 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
.PHONY: lint build-image publish-build-image test-readme clean
JSONNET_FMT := jsonnetfmt
# Support gsed/gfind on OSX (installed via brew), falling back to sed/find. On Linux
# systems gsed/gfind won't be installed, so will use sed/gfind as expected.
SED ?= $(shell which gsed 2>/dev/null || which sed)
FIND ?= $(shell which gfind 2>/dev/null || which find)
lint: lint-mixin lint-playbooks
lint-mixin: lint-mixin-with-mixtool lint-mixin-with-jsonnetfmt
lint-mixin-with-jsonnetfmt:
@RESULT=0; \
for f in $$(find . -name '*.libsonnet' -print -o -name '*.jsonnet' -print); do \
$(JSONNET_FMT) -- "$$f" | diff -u "$$f" -; \
RESULT=$$(($$RESULT + $$?)); \
done; \
exit $$RESULT
lint-mixin-with-mixtool:
cd cortex-mixin && \
jb install && \
mixtool lint mixin.libsonnet
lint-playbooks: build-mixin
@./scripts/lint-playbooks.sh
fmt:
@find . -name 'vendor' -prune -o -name '*.libsonnet' -print -o -name '*.jsonnet' -print | \
xargs -n 1 -- $(JSONNET_FMT) -i
build-image:
docker build -t quay.io/cortexproject/cortex-jsonnet-build-image:$(shell git rev-parse --short HEAD) build-image
save-build-image:
docker save quay.io/cortexproject/cortex-jsonnet-build-image:$(shell git rev-parse --short HEAD) > build-image.tar
load-build-image:
docker load < build-image.tar
publish-build-image:
docker push quay.io/cortexproject/cortex-jsonnet-build-image:$(shell git rev-parse --short HEAD)
build-mixin:
@cd cortex-mixin && \
rm -rf out && mkdir out && \
jb install && \
mixtool generate all --output-alerts out/alerts.yaml --output-rules out/rules.yaml --directory out/dashboards mixin.libsonnet && \
zip -q -r cortex-mixin.zip out
test-readme: test-readme/azure test-readme/gcs test-readme/s3
test-readme/%:
@./scripts/test-readme.sh $@
clean-white-noise:
@$(FIND) . -type f -regextype posix-extended -regex '.*(md|libsonnet)' -print | \
SED_BIN="$(SED)" xargs ./scripts/cleanup-white-noise.sh
check-white-noise: clean-white-noise
@git diff --exit-code --quiet || (echo "Please remove trailing whitespaces running 'make clean-white-noise'" && false)
clean:
rm -rf cortex-mixin/out
rm -rf cortex-mixin/vendor
rm -f cortex-mixin/cortex-mixin.zip
rm -rf test-readme