-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
246 lines (190 loc) · 6.59 KB
/
Makefile
File metadata and controls
246 lines (190 loc) · 6.59 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
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
ifeq (, $(ENV))
ENV := development
env := development
else ifeq (test, $(ENV))
env := testing
else
env := $(ENV)
endif
ifeq (, $(NODE_ENV))
NODE_ENV := development
endif
app := aarau
.DEFAULT_GOAL = test\:coverage
default: test\:coverage
# -- setup
setup: ## Install Python packages
pip install -e '.[${env}]' -c constraints.txt
.PHONY: setup
setup\:force: ## Install Python packages with `--force-reinstall`
pip install --upgrade --force-reinstall -e '.[${env}]' -c constraints.txt
.PHONY: setup\:force
setup\:update: ## Update Python packages
pip install --upgrade -e '.[${env}]' -c constraints.txt
.PHONY: setup\:update
# -- db
db\:init: ## Create database
ENV=$(ENV) ${app}_manage 'config/${env}.ini#${app}' db init
.PHONY: db\:init
db\:migrate: ## Run migrations
ENV=$(ENV) ${app}_manage 'config/${env}.ini#${app}' db migrate
.PHONY: db\:migrate
db\:rollback: ## Rollback latest migration
ENV=$(ENV) ${app}_manage 'config/${env}.ini#${app}' db rollback
.PHONY: db\:rollback
db\:seed: ## Put seed records for development (See db/seeds)
ENV=$(ENV) ${app}_manage 'config/${env}.ini#${app}' db seed
.PHONY: db\:seed
db\:drop: ## Drop database
ENV=$(ENV) ${app}_manage 'config/${env}.ini#${app}' db drop
.PHONY: db\:drop
db\:reset: ## Reset database
ENV=$(ENV) ${app}_manage 'config/${env}.ini#${app}' db drop
ENV=$(ENV) ${app}_manage 'config/${env}.ini#${app}' db init
ENV=$(ENV) ${app}_manage 'config/${env}.ini#${app}' db migrate
ifneq (test, $(ENV))
ENV=$(ENV) ${app}_manage 'config/${env}.ini#${app}' db seed
endif
.PHONY: db\:reset
# -- serve
serve: ## Run server process (development)
./bin/serve --env development --config config/development.ini --reload
.PHONY: serve
serve\:worker: ## Run worker process (development)
ENV=$(ENV) ${app}_worker 'config/${env}.ini#${app}'
.PHONY: serve\:worker
serve\:production: ## Run {server,worker} process both in production mode (see Procfile)
honcho start
.PHONY: serve\:production
# -- test
test: ## Run unit tests and functional tests both
ENV=test py.test -c 'config/testing.ini' -s -q \
test/unit test/func test/routes_test.py
.PHONY: test
test\:unit: ## Run unit tests
ENV=test py.test -c 'config/testing.ini' -s -q \
test/unit
.PHONY: test\:unit
test\:func: ## Run functional tests
ENV=test py.test -c 'config/testing.ini' -s -q \
test/func
.PHONY: test\:func
test\:route: ## Run only route tests
ENV=test py.test -c 'config/testing.ini' -s -q \
test/routes_test.py
.PHONY: test\:route
test\:integration: ## Run integration tests on browser (Firefox Headless)
ENV=test TEST_DOMAIN=localhost TEST_SESSION_COOKIE_DOMAIN=localhost \
py.test -c 'config/testing.ini' -s -v \
--driver Firefox --driver-path ./bin/geckodriver test/integration
.PHONY: test\:integration
test\:doc: ## Run doctest in Python code
ENV=test ./bin/run_doctest
.PHONY: test\:doc
test\:js: ## Run JavaScript (js,component) unit tests
NODE_ENV=development karma start
.PHONY: test\:js
test\:coverage: ## Run `test` with coverage outputs
ENV=test py.test -c 'config/testing.ini' -s -q \
test/unit test/func \
--cov=${app} --cov-report term-missing:skip-covered
.PHONY: test\:coverage
# -- i18n (translation)
i18n: | i18n\:compile ## An alias of `i18n:compile`
.PHONY: i18n
i18n\:extract: ## Extract translation targets from code
./bin/linguine extract classification
./bin/linguine extract form
./bin/linguine extract message
.PHONY: i18n\:extract
i18n\:compile: ## Make translation files (catalog)
ifneq (production, $(ENV))
ifeq (, $(shell which i18next-conv 2>/dev/null))
$(info i18next-conv command not found. run `npm install -g i18next-conv`)
$(info )
endif
endif
for ns in classification form message console\.json ; do \
for locale in en ; do \
./bin/linguine compile $$ns $$locale; \
done; \
done
.PHONY: i18n\:compile
i18n\:update: ## Update catalog (pot)
for ns in classification form message console\.json ; do \
for locale in en ; do \
./bin/linguine update $$ns $$locale; \
done; \
done
.PHONY: i18n\:update
i18n\:sync: ## Fetch translation updates from upstrm (scrolliris/scrolliris-console-translation)
./bin/linguine sync
.PHONY: i18n\:sync
# -- vet
vet: | vet\:style vet\:lint ## Run `vet:style` and `vet:lint` both (without vet:quality)
.PHONY: vet
vet\:style: ## Check style using py{code,doc}style (see setup.cfg)
pycodestyle test aarau
pydocstyle test aarau
.PHONY: vet\:style
vet\:lint: ## Lint python codes
pylint test ${app}
.PHONY: vet\:lint
vet\:quality: ## Generate codequality.txt using codeclimate (require Docker)
docker run --interactive --tty --rm --env CODECLIMATE_CODE="${PWD}" \
--volume "${PWD}":/code \
--volume /var/run/docker.sock:/var/run/docker.sock \
--volume /tmp/cc:/tmp/cc \
codeclimate/codeclimate analyze -f text > tmp/codequality.txt
cat tmp/codequality.txt
.PHONY: vet\:quality
# -- fmt
fmt: ## Apply python formatter (black) with --diff option
black --config=.pythonfmt.toml aarau test
.PHONY: fmt
# -- utilities
pack: ## Assemble assets using gulp-cli
ifeq (, $(shell which gulp 2>/dev/null))
$(info gulp command not found. run `npm install -g gulp-cli`)
$(info )
else
NODE_ENV=$(NODE_ENV) gulp
endif
.PHONY: pack
build: | setup pack i18n ## (Re) Run setup, pack and i18n:compile at once
.PHONY: build
clean: ## Delete unnecessary cache etc.
find . ! -readable -prune -o \
! -path "./.git/*" ! -path "./node_modules/*" ! -path "./venv*" \
! -path "./doc/*" ! -path "./locale/*" ! -path "./tmp/*" \
! -path "./lib/*" -print | \
grep -E "(__pycache__|\.pytest_cache|\.cache|\.egg-info|\.pyc|\.pyo)" | \
xargs rm -rf
ifeq (, $(shell which gulp 2>/dev/null))
$(info gulp command not found. run `npm install -g gulp-cli`)
$(info )
else
NODE_ENV=$(NODE_ENV) gulp clean
endif
.PHONY: clean
shell: ## Open python REPL in application context
ENV=$(ENV) ${app}_pshell 'config/${env}.ini#${app}' --python-shell ptpython
.PHONY: shell
routes: ## Display all routes for the application
ENV=$(ENV) ${app}_proute 'config/${env}.ini#${app}'
.PHONY: routes
expose: ## Print untracked (volatile) files
git ls-files --others | \
grep -vE '(lib|tmp|test|static|db|locale|node_modules|\.?cache)/' | \
grep -vE '(__pycache__|\.egg-info|venv)/' | \
grep -vE '(\.coverage|\.*-version|bin\/gitlab*)'
.PHONY: expose
deploy: ## Deploy app to production server
./bin/plate $(ACTION) $(VERSION)
.PHONY: deploy
help: ## Display this message
@grep -E '^[0-9a-z\:\\]+: ' $(MAKEFILE_LIST) | grep -E ' ## ' | \
sed -e 's/\(\s|\(\s[0-9a-z\:\\]*\)*\) / /' | tr -d \\\\ | \
awk 'BEGIN {FS = ": ## "}; {printf "\033[36m%-17s\033[0m %s\n", $$1, $$2}' | \
sort
.PHONY: help