forked from StackStorm/st2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
254 lines (213 loc) · 7.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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
SHELL := /bin/bash
TOX_DIR := .tox
VIRTUALENV_DIR ?= virtualenv
# Sphinx docs options
SPHINXBUILD := sphinx-build
DOC_SOURCE_DIR := docs/source
DOC_BUILD_DIR := docs/build
BINARIES := bin
# All components are prefixed by st2
COMPONENTS := $(wildcard st2*)
# Components that implement a component-controlled test-runner. These components provide an
# in-component Makefile. (Temporary fix until I can generalize the pecan unittest setup. -mar)
COMPONENT_SPECIFIC_TESTS := st2tests
# nasty hack to get a space into a variable
space_char :=
space_char +=
COMPONENT_PYTHONPATH = $(subst $(space_char),:,$(realpath $(COMPONENTS)))
COMPONENTS_TEST := $(foreach component,$(filter-out $(COMPONENT_SPECIFIC_TESTS),$(COMPONENTS)),$(component))
PYTHON_TARGET := 2.7
REQUIREMENTS := requirements.txt test-requirements.txt st2client/requirements.txt
.PHONY: all
all: requirements check tests docs
# Target for debugging Makefile variable assembly
.PHONY: play
play:
@echo COMPONENTS=$(COMPONENTS)
@echo COMPONENTS_TEST=$(COMPONENTS_TEST)
@echo COMPONENT_PYTHONPATH=$(COMPONENT_PYTHONPATH)
.PHONY: check
check: requirements flake8 checklogs
.PHONY: checklogs
checklogs:
@echo
@echo "================== LOG WATCHER ===================="
@echo
. $(VIRTUALENV_DIR)/bin/activate; ./tools/log_watcher.py 10
.PHONY: docs
docs: requirements .docs
.PHONY: .docs
.docs:
@echo
@echo "====================docs===================="
@echo
. $(VIRTUALENV_DIR)/bin/activate; $(SPHINXBUILD) -W -b html $(DOC_SOURCE_DIR) $(DOC_BUILD_DIR)/html
@echo
@echo "Build finished. The HTML pages are in $(DOC_BUILD_DIR)/html."
.PHONY: livedocs
livedocs: docs .livedocs
.PHONY: .livedocs
.livedocs:
@echo
@echo "==========================================================="
@echo " RUNNING DOCS"
@echo "==========================================================="
@echo
. $(VIRTUALENV_DIR)/bin/activate; sphinx-autobuild -H 0.0.0.0 -b html $(DOC_SOURCE_DIR) $(DOC_BUILD_DIR)/html
@echo
.PHONY: pylint
pylint: requirements .pylint
.PHONY: .pylint
.pylint:
@echo
@echo "================== pylint ===================="
@echo
@for component in $(COMPONENTS); do\
echo "==========================================================="; \
echo "Running pylint on" $$component; \
echo "==========================================================="; \
. $(VIRTUALENV_DIR)/bin/activate; pylint -E --rcfile=./.pylintrc $$component/$$component; \
done
.PHONY: flake8
flake8: requirements .flake8
.PHONY: .flake8
.flake8:
@echo
@echo "==================== flake ===================="
@echo
. $(VIRTUALENV_DIR)/bin/activate; flake8 --config ./.flake8 $(COMPONENTS)
.PHONY: lint
lint: requirements .flake8 .pylint
.PHONY: clean
clean: .cleanpycs .cleandocs
.PHONY: .cleanpycs
.cleanpycs:
@echo "Removing all .pyc files"
find $(COMPONENTS) -name \*.pyc -type f -print0 | xargs -0 -I {} rm {}
.PHONY: .cleandocs
.cleandocs:
@echo "Removing generated documentation"
rm -rf $(DOC_BUILD_DIR)
.PHONY: distclean
distclean: clean
@echo
@echo "==================== distclean ===================="
@echo
rm -rf $(VIRTUALENV_DIR)
.PHONY: requirements
requirements: virtualenv $(REQUIREMENTS)
@echo
@echo "==================== requirements ===================="
@echo
for req in $(REQUIREMENTS); do \
echo "Installing $$req..." ; \
. $(VIRTUALENV_DIR)/bin/activate && pip install -U -q -r $$req ; \
done
.PHONY: virtualenv
virtualenv: $(VIRTUALENV_DIR)/bin/activate
$(VIRTUALENV_DIR)/bin/activate:
@echo
@echo "==================== virtualenv ===================="
@echo
test -d $(VIRTUALENV_DIR) || virtualenv --no-site-packages $(VIRTUALENV_DIR)
# Setup PYTHONPATH in bash activate script...
echo '' >> $(VIRTUALENV_DIR)/bin/activate
echo '_OLD_PYTHONPATH=$$PYTHONPATH' >> $(VIRTUALENV_DIR)/bin/activate
echo 'PYTHONPATH=$$_OLD_PYTHONPATH:$(COMPONENT_PYTHONPATH)' >> $(VIRTUALENV_DIR)/bin/activate
echo 'export PYTHONPATH' >> $(VIRTUALENV_DIR)/bin/activate
touch $(VIRTUALENV_DIR)/bin/activate
# Setup PYTHONPATH in fish activate script...
echo '' >> $(VIRTUALENV_DIR)/bin/activate.fish
echo 'set -gx _OLD_PYTHONPATH $$PYTHONPATH' >> $(VIRTUALENV_DIR)/bin/activate.fish
echo 'set -gx PYTHONPATH $$_OLD_PYTHONPATH $(COMPONENT_PYTHONPATH)' >> $(VIRTUALENV_DIR)/bin/activate.fish
echo 'functions -c deactivate old_deactivate' >> $(VIRTUALENV_DIR)/bin/activate.fish
echo 'function deactivate' >> $(VIRTUALENV_DIR)/bin/activate.fish
echo ' if test -n $$_OLD_PYTHONPATH' >> $(VIRTUALENV_DIR)/bin/activate.fish
echo ' set -gx PYTHONPATH $$_OLD_PYTHONPATH' >> $(VIRTUALENV_DIR)/bin/activate.fish
echo ' set -e _OLD_PYTHONPATH' >> $(VIRTUALENV_DIR)/bin/activate.fish
echo ' end' >> $(VIRTUALENV_DIR)/bin/activate.fish
echo ' old_deactivate' >> $(VIRTUALENV_DIR)/bin/activate.fish
echo ' functions -e old_deactivate' >> $(VIRTUALENV_DIR)/bin/activate.fish
echo 'end' >> $(VIRTUALENV_DIR)/bin/activate.fish
touch $(VIRTUALENV_DIR)/bin/activate.fish
.PHONY: tests
tests: pytests
# Travis cannot run itests since those require users to be configured etc.
# Creating special travis target. (Yuck!)
.PHONY: tests-travis
tests-travis: requirements .flake8 unit-tests-coverage
.PHONY: pytests
pytests: requirements .flake8 .pytests-coverage
.PHONY: .pytests
.pytests: unit-tests itests clean
.PHONY: .pytests-coverage
.pytests-coverage: unit-tests-coverage itests clean
.PHONY: unit-tests
unit-tests:
@echo
@echo "==================== tests ===================="
@echo
@echo "----- Dropping st2-test db -----"
@mongo st2-test --eval "db.dropDatabase();"
@for component in $(COMPONENTS_TEST); do\
echo "==========================================================="; \
echo "Running tests in" $$component; \
echo "==========================================================="; \
. $(VIRTUALENV_DIR)/bin/activate; nosetests -s -v $$component/tests/unit || exit 1; \
done
.PHONY: unit-tests-coverage
unit-tests-coverage:
@echo
@echo "==================== unit tests with coverage ===================="
@echo
@echo "----- Dropping st2-test db -----"
@mongo st2-test --eval "db.dropDatabase();"
@for component in $(COMPONENTS_TEST); do\
echo "==========================================================="; \
echo "Running tests in" $$component; \
echo "==========================================================="; \
. $(VIRTUALENV_DIR)/bin/activate; nosetests -sv --with-xcoverage --xcoverage-file=coverage-$$component.xml --cover-package=$$component $$component/tests/unit || exit 1; \
done
.PHONY: itests
itests:
@echo
@echo "==================== integration tests ===================="
@echo
@echo "----- Dropping st2-test db -----"
@mongo st2-test --eval "db.dropDatabase();"
@for component in $(COMPONENTS_TEST); do\
echo "==========================================================="; \
echo "Running tests in" $$component; \
echo "==========================================================="; \
. $(VIRTUALENV_DIR)/bin/activate; nosetests -sv $$component/tests/integration || exit 1; \
done
.PHONY: mistral-itests
mistral-itests:
@echo
@echo "==================== integration tests ===================="
@echo "The tests assume both st2 and mistral are running on localhost."
@echo
. $(VIRTUALENV_DIR)/bin/activate; nosetests -s -v st2tests/integration || exit 1;
.PHONY: rpms
rpms:
@echo
@echo "==================== rpm ===================="
@echo
rm -Rf ~/rpmbuild
$(foreach COM,$(COMPONENTS), pushd $(COM); make rpm; popd;)
pushd st2client && make rpm && popd
rhel-rpms:
@echo
@echo "==================== rpm ===================="
@echo
rm -Rf ~/rpmbuild
$(foreach COM,$(COMPONENTS), pushd $(COM); make rhel-rpm; popd;)
pushd st2client && make rhel-rpm && popd
.PHONY: debs
debs:
@echo
@echo "==================== deb ===================="
@echo
rm -Rf ~/debbuild
$(foreach COM,$(COMPONENTS), pushd $(COM); make deb; popd;)
pushd st2client && make deb && popd