-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathMakefile
More file actions
88 lines (67 loc) · 2.63 KB
/
Copy pathMakefile
File metadata and controls
88 lines (67 loc) · 2.63 KB
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
DOCKER_IMAGE_TAG ?= $(subst /,-,$(shell git rev-parse --abbrev-ref HEAD))-$(shell date +%Y-%m-%d)-$(shell git rev-parse --short HEAD)
DOCKER_CI_TAG ?= test
JB ?= jb
EMBEDMD ?= embedmd
JSONNET ?= jsonnet
GOJSONTOYAML ?= gojsontoyaml
PROMTOOL ?= promtool
CLOUDFLARE_MIXIN ?= mixin
JSONNET_VENDOR_DIR ?= mixin/vendor
define require_clean_work_tree
@git update-index -q --ignore-submodules --refresh
@if ! git diff-files --quiet --ignore-submodules --; then \
echo >&2 "cannot $1: you have unstaged changes."; \
git diff-files --name-status -r --ignore-submodules -- >&2; \
echo >&2 "Please commit or stash them."; \
exit 1; \
fi
@if ! git diff-index --cached --quiet HEAD --ignore-submodules --; then \
echo >&2 "cannot $1: your index contains uncommitted changes."; \
git diff-index --cached --name-status -r --ignore-submodules HEAD -- >&2; \
echo >&2 "Please commit or stash them."; \
exit 1; \
fi
endef
.PHONY: build
clean: clean-build clean-pyc clean-test ## remove all build, test, coverage and Python artifacts
clean-build: ## remove build artifacts
rm -fr build/
rm -fr dist/
rm -fr .eggs/
find . -name '*.egg-info' -exec rm -fr {} +
find . -name '*.egg' -exec rm -f {} +
clean-pyc: ## remove Python file artifacts
find . -name '*.pyc' -exec rm -f {} +
find . -name '*.pyo' -exec rm -f {} +
find . -name '*~' -exec rm -f {} +
find . -name '__pycache__' -exec rm -fr {} +
clean-test: ## remove test and coverage artifacts
rm -fr .tox/
rm -f .coverage
rm -fr htmlcov/
rm -fr .pytest_cache
init: venv
pip install -r requirements-dev.txt
pre-commit install
venv:
python -m venv ./venv
source venv/bin/activate
test: ## run tests quickly with the default Python
py.test -o log_cli=true -sv --cov=cloudflare_exporter tests/
install: clean ## install the package to the active Python's site-packages
python setup.py install
dist: clean ## builds source and wheel package
python setup.py bdist_wheel --universal
build:
docker build . -t prometheus-exporter/cloudflare-exporter:${DOCKER_IMAGE_TAG}
mixin: jsonnet-vendor
-mkdir examples
$(JSONNET) -J ${JSONNET_VENDOR_DIR} ${CLOUDFLARE_MIXIN}/alerts.jsonnet | $(GOJSONTOYAML) > examples/alerts.yaml
$(JSONNET) -J ${JSONNET_VENDOR_DIR} ${CLOUDFLARE_MIXIN}/rules.jsonnet | $(GOJSONTOYAML) > examples/rules.yaml
$(JSONNET) -J ${JSONNET_VENDOR_DIR} ${CLOUDFLARE_MIXIN}/dashboards.jsonnet > examples/dashboards.json
${PROMTOOL} check rules examples/alerts.yaml
${PROMTOOL} check rules examples/rules.yaml
.PHONY: jsonnet-vendor
jsonnet-vendor:
rm -rf ${JSONNET_VENDOR_DIR}
cd ${CLOUDFLARE_MIXIN} && $(JB) install