This repository has been archived by the owner on Sep 16, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMakefile
148 lines (120 loc) · 3.9 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
venv = venv
python=python3
pip = $(venv)/bin/pip
pip_min_version = 19
pip_min_version_guard_base = $(venv)/pip-version
pip_min_version_guard = $(pip_min_version_guard_base)-$(pip_min_version)
pip_compile=$(venv)/bin/pip-compile
# raise non-zero exit codes in pipes
SHELL=/bin/bash -o pipefail
# create a venv for running the hangupsbot
.PHONY: venv
venv: install-requirements
# create a venv for running the hangupsbot
.PHONY: install-requirements
install-requirements: venv-create
$(pip) install --requirement requirements/requirements.txt
# install the hangupsbot package into a venv
.PHONY: install
install: venv-create
rm -rf `find hangupsbot -name __pycache__`
$(pip) install . --upgrade
# update or reinstall all packages
.PHONY: update-requirements
update-requirements: venv-create
$(pip) install --requirement requirements/requirements.txt --upgrade
# check the venv and run pylint
.PHONY: lint
lint: venv-dev
$(venv)/bin/pylint -s no -j 1 hangupsbot
# check the venv and run the test-suite
.PHONY: test-only
test-only: venv-dev
$(venv)/bin/py.test -v tests
# run pylint and the test-suite
.PHONY: test
test: lint
test: test-only
# remove the local cache and compiled python files from local directories
.PHONY: clean
clean:
rm -rf \
.cache \
venv \
`find hangupsbot tests examples -name __pycache__`
### internal, house keeping and debugging targets ###
# house keeping: update the Jenkinsfile
Jenkinsfile: tools/gen_Jenkinsfile.py
$(python) tools/gen_Jenkinsfile.py
# house keeping: update the localization
.PHONY: localization
localization:
make --directory hangupsbot/locale
# internal: ensure an existing venv
.PHONY: venv-create
venv-create: $(pip)
venv-create: $(venv)/bin/wheel
$(venv)/bin/python:
$(python) -m venv $(venv)
$(pip): $(pip_min_version_guard)
touch $(pip)
$(pip_min_version_guard): $(venv)/bin/python
$(pip) install --upgrade 'pip>=$(pip_min_version)'
rm -f $(pip_min_version_guard_base)*
touch $(pip_min_version_guard)
$(venv)/bin/wheel: $(pip)
$(pip) install --upgrade wheel
touch $(venv)/bin/wheel
# house keeping: update the requirements.in file
requirements/requirements.in: $(shell find hangupsbot -type d)
requirements/requirements.in: tools/gen_requirements.in.sh
tools/gen_requirements.in.sh
# house keeping: update the requirements-dev.in file
requirements/requirements-dev.in: requirements/requirements.in
requirements/requirements-dev.in: $(shell find tests -type d)
requirements/requirements-dev.in: tools/gen_requirements-dev.in.sh
tools/gen_requirements-dev.in.sh
# internal: check for `pip-compile`
$(pip_compile): $(pip)
$(pip) install pip-tools
touch $(pip_compile)
# house keeping: update `requirements.txt`:
# pip-compile prints everything to stdout as well, direct it to /dev/null
.PHONY: gen-requirements
gen-requirements: $(pip_compile)
gen-requirements: requirements/requirements.in
CUSTOM_COMPILE_COMMAND="make gen-requirements" \
$(pip_compile) \
--upgrade \
--no-annotate \
--no-index \
--no-emit-trusted-host \
--output-file requirements/requirements.txt \
requirements/requirements.in \
> /dev/null
# house keeping: update `requirements-dev.txt`:
# gather requirements from ./hangupsbot and ./tests
.PHONY: gen-dev-requirements
gen-dev-requirements: $(pip_compile)
gen-dev-requirements: requirements/requirements-dev.in
CUSTOM_COMPILE_COMMAND="make gen-dev-requirements" \
$(pip_compile) \
--upgrade \
--no-annotate \
--no-index \
--no-emit-trusted-host \
--output-file requirements/requirements-dev.txt \
requirements/requirements-dev.in \
> /dev/null
# internal: ensure a venv with dev requirements
.PHONY: venv-dev
venv-dev: $(venv)/dev
$(venv)/dev: $(pip)
$(venv)/dev: $(venv)/bin/wheel
$(venv)/dev: requirements/requirements-dev.txt
$(pip) install --requirement requirements/requirements-dev.txt
touch $(venv)/dev
# debugging: run the test suite verbose
.PHONY: test-only-verbose
test-only-verbose:
$(venv)/bin/py.test -vvv tests