forked from rackerlabs/otter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
194 lines (161 loc) · 5.26 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
CODEDIR=otter
TESTDIR1=autoscale_cloudroast/test_repo
TESTDIR2=autoscale_cloudcafe/autoscale
SCRIPTSDIR=scripts
PYDIRS=${CODEDIR} ${SCRIPTSDIR} autoscale_cloudcafe autoscale_cloudroast
CQLSH ?= $(shell which cqlsh)
DOCDIR=doc
UNITTESTS ?= ${CODEDIR}.test ${CODEDIR}.integration.lib
CASSANDRA_HOST ?= localhost
export CASSANDRA_HOST
CASSANDRA_PORT ?= 9160
export CASSANDRA_PORT
CONTROL_KEYSPACE ?= OTTER
REPLICATION_FACTOR ?= 3
CLOUDCAFE ?= $(shell which cafe-runner)
mkfile_dir := $(shell dirname "$(MAKEFILE_LIST)")
.PHONY: targets env-precheck docbook
targets:
@cat README.md
hooks:
cp ${mkfile_dir}/scripts/config_check.py ${mkfile_dir}/.git/hooks
echo "#!/bin/bash" > ${mkfile_dir}/.git/hooks/pre-commit
echo "python .git/hooks/config_check.py" >> ${mkfile_dir}/.git/hooks/pre-commit
chmod a+x ${mkfile_dir}/.git/hooks/pre-commit
env-precheck:
./scripts/env-precheck.py
test: unit integration
run:
twistd -n --logger=otter.log.observer_factory_debug otter-api
env:
./scripts/bootstrap-virtualenv.sh
lint: listoutdated lint-code
lint-code: flake8diff
pyflakes ${PYDIRS}
listoutdated:
pip list --outdated --allow-external=cafe,cloudcafe
# concatenate both environment variables together - if both are unset, the
# concatenation will be empty
ifneq ($(JENKINS_URL)$(TRAVIS_PULL_REQUEST), )
# On Jenkins or Travis, HEAD will be a Github-created merge commit. Hence,
# diffing against HEAD^1 gives you the diff introduced by the PR, which is what
# we're trying to test.
DIFF_TARGET = HEAD^1
else
# On not-Jenkins, we find the current branch's branch-off point from master,
# and diff against that.
DIFF_TARGET = $(shell git merge-base master HEAD)
endif
flake8diff:
git diff --patch --no-prefix ${DIFF_TARGET} | flake8 --diff
flake8full:
flake8 ${PYDIRS}
TRIAL_OPTIONS=--random 0
TRIAL_OPTIONS_UNIT=${TRIAL_OPTIONS} --jobs 4
unit:
ifneq ($(JENKINS_URL), )
PYRSISTENT_NO_C_EXTENSION=true trial ${TRIAL_OPTIONS_UNIT} \
--reporter=subunit ${UNITTESTS} \
| subunit-1to2 | tee subunit-output.txt
tail -n +4 subunit-output.txt | subunit2junitxml > test-report.xml
else
PYRSISTENT_NO_C_EXTENSION=true trial ${TRIAL_OPTIONS_UNIT} ${UNITTESTS}
endif
integration:
ifneq ($(JENKINS_URL), )
ifneq ($(CLOUDCAFE), )
cafe-runner autoscale dev -p functional --parallel
else
@echo "Environment variable CLOUDCAFE appears to not be set; is it installed"
@echo "correctly and are you on the correct environment?"
@echo "Invoke `make envcheck' to double-check your environment compatibility."
endif
else
@echo "Cloudcafe is not set up as desired, so can't run integration tests:"
@echo "- Missing JENKINS_URL environment setting."
endif
coverage:
PYRSISTENT_NO_C_EXTENSION=true coverage run --source=${CODEDIR} \
--omit="*/test/*","*/integration/tests/*","*/integration/lib/test_*.py" \
--branch `which trial` ${TRIAL_OPTIONS} ${UNITTESTS}
coverage-html: coverage
coverage html -d _trial_coverage
coverage-xml: coverage
coverage xml
cleandocs:
rm -rf _builddoc
rm -rf htmldoc
rm -rf docbook/target
docs: sphinxdocs docbook
sphinxdocs:
cp -r ${DOCDIR} _builddoc
sphinx-apidoc -F -T -o _builddoc ${CODEDIR}
sphinx-apidoc -F -T -o _builddoc ${TESTDIR2}
sphinx-apidoc -F -T -o _builddoc ${TESTDIR1}
sphinx-build -b html _builddoc htmldoc
docbook:
ifneq ($(shell git diff --name-only ${DIFF_TARGET} -- docbook), )
cd docbook; mvn -q compile
else
echo "Skipping, nothing changed between working tree and diff target"
endif
schema: FORCE schema-setup schema-teardown
schema-setup:
PATH=${SCRIPTSDIR}:${PATH} load_cql.py schema/setup \
--ban-unsafe \
--outfile schema/setup-dev.cql \
--replication 1 \
--keyspace ${CONTROL_KEYSPACE} \
--dry-run
PATH=${SCRIPTSDIR}:${PATH} load_cql.py schema/setup \
--ban-unsafe \
--outfile schema/setup-prod.cql \
--replication ${REPLICATION_FACTOR} \
--keyspace ${CONTROL_KEYSPACE} \
--dry-run
schema-teardown:
PATH=${SCRIPTSDIR}:${PATH} load_cql.py schema/teardown \
--outfile schema/teardown-dev.cql \
--replication 1 \
--keyspace ${CONTROL_KEYSPACE} \
--dry-run
PATH=${SCRIPTSDIR}:${PATH} load_cql.py schema/teardown \
--outfile schema/teardown-prod.cql \
--replication ${REPLICATION_FACTOR} \
--keyspace ${CONTROL_KEYSPACE} \
--dry-run
load-dev-schema:
PATH=${SCRIPTSDIR}:${PATH} load_cql.py schema/setup \
--ban-unsafe \
--outfile schema/setup-dev.cql \
--replication 1 \
--keyspace ${CONTROL_KEYSPACE} \
--host ${CASSANDRA_HOST} \
--port ${CASSANDRA_PORT}
migrate-dev-schema:
PATH=${SCRIPTSDIR}:${PATH} load_cql.py schema/migrations \
--outfile schema/migrations-dev.cql \
--replication 1 \
--keyspace ${CONTROL_KEYSPACE} \
--host ${CASSANDRA_HOST} \
--port ${CASSANDRA_PORT}
teardown-dev-schema:
PATH=${SCRIPTSDIR}:${PATH} load_cql.py schema/teardown \
--outfile schema/teardown-dev.cql \
--replication 1 \
--keyspace ${CONTROL_KEYSPACE} \
--host ${CASSANDRA_HOST} \
--port ${CASSANDRA_PORT}
clear-dev-schema: FORCE teardown-dev-schema load-dev-schema
FORCE:
clean: cleandocs
find . -name '*.pyc' -delete
find . -name '.coverage' -delete
find . -name 'coverage.xml' -delete
find . -name '_trial_coverage' -print0 | xargs rm -rf
find . -name '_trial_temp' -print0 | xargs rm -rf
rm -rf dist build *.egg-info
rm -rf otter*deploy*
rm -rf schema/setup-*.cql
rm -rf schema/migrations-*.cql
rm -rf schema/teardown-*.cql