-
Notifications
You must be signed in to change notification settings - Fork 45
/
Makefile
288 lines (204 loc) · 8 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
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
include Makefile.config
-include .env
.SILENT:
make-p:
# Launch all P targets in parallel and exit as soon as one exits.
set -m; (for p in $(P); do ($(MAKE) $$p || kill 0)& done; wait)
babel-extract:
$(PYBABEL) extract -F babel.cfg -k lazy_gettext -o messages.pot .
babel-init:
$(PYBABEL) init -i messages.pot -d fittrackee/emails/translations -l $(LANG)
babel-compile:
$(PYBABEL) compile -d fittrackee/emails/translations
babel-update:
$(PYBABEL) update -i messages.pot -d fittrackee/emails/translations
bandit:
$(BANDIT) -r fittrackee -c pyproject.toml
build-client: lint-client
cd fittrackee_client && $(NPM) build
check-all: bandit lint-all type-check-all test-all
check-client: lint-client type-check-client test-client
check-python: bandit lint-python type-check test-python
clean:
rm -rf .mypy_cache
rm -rf .pytest_cache
rm -rf .ruff_cache
rm -rf e2e/.pytest_cache
clean-install: clean
rm -fr $(NODE_MODULES)
rm -fr $(VENV)
rm -rf *.egg-info
rm -rf dist/
## Docker commands for evaluation purposes
docker-bandit:
docker compose -f docker-compose-dev.yml exec fittrackee bandit -r fittrackee -c pyproject.toml
docker-build:
docker compose -f docker-compose-dev.yml build fittrackee
docker-build-all: docker-build docker-build-client
docker-build-client:
docker compose -f docker-compose-dev.yml build fittrackee_client
docker-check-all: docker-run docker-bandit docker-lint-all docker-type-check docker-test-client docker-test-python
docker-downgrade-db:
docker compose -f docker-compose-dev.yml exec fittrackee flask db downgrade --directory $(DOCKER_MIGRATIONS)
docker-lint-all: docker-run docker-lint-client docker-lint-python
docker-lint-client:
docker compose -f docker-compose-dev.yml up -d fittrackee_client
docker compose -f docker-compose-dev.yml exec fittrackee_client $(NPM) lint
docker compose -f docker-compose-dev.yml exec fittrackee_client $(NPM) type-check
docker-lint-python: docker-run
docker compose -f docker-compose-dev.yml exec fittrackee docker/lint-python.sh
docker-logs:
docker compose -f docker-compose-dev.yml logs --follow
docker-migrate-db:
docker compose -f docker-compose-dev.yml exec fittrackee flask db migrate --directory $(DOCKER_MIGRATIONS)
docker-rebuild:
docker compose -f docker-compose-dev.yml build --no-cache
docker-restart:
docker compose -f docker-compose-dev.yml restart fittrackee
docker-revision:
docker compose -f docker-compose-dev.yml exec fittrackee flask db revision --directory $(DOCKER_MIGRATIONS) --message $(MIGRATION_MESSAGE)
docker-run:
docker compose -f docker-compose-dev.yml up -d fittrackee
docker-serve-client:
docker compose -f docker-compose-dev.yml up -d fittrackee_client
docker compose -f docker-compose-dev.yml exec fittrackee_client $(NPM) dev
docker-set-admin:
docker compose -f docker-compose-dev.yml exec fittrackee ftcli users update $(USERNAME) --set-admin true
docker-shell:
docker compose -f docker-compose-dev.yml exec fittrackee docker/shell.sh
docker-stop:
docker compose -f docker-compose-dev.yml stop
docker-test-client:
docker compose -f docker-compose-dev.yml up -d fittrackee_client
docker compose -f docker-compose-dev.yml exec fittrackee_client $(NPM) test:unit run
docker-test-client-watch:
docker compose -f docker-compose-dev.yml up -d fittrackee_client
docker compose -f docker-compose-dev.yml exec fittrackee_client $(NPM) test:unit watch
# needs a running application
docker-test-e2e: docker-run
docker compose -f docker-compose-dev.yml up -d selenium
docker compose -f docker-compose-dev.yml exec fittrackee docker/test-e2e.sh $(PYTEST_ARGS)
docker-test-python: docker-run
docker compose -f docker-compose-dev.yml exec fittrackee docker/test-python.sh $(PYTEST_ARGS)
docker-type-check:
echo 'Running mypy in docker...'
docker compose -f docker-compose-dev.yml exec fittrackee mypy fittrackee
docker-up:
docker compose -f docker-compose-dev.yml up fittrackee
docker-upgrade-db:
docker compose -f docker-compose-dev.yml exec fittrackee ftcli db upgrade
downgrade-db:
$(FLASK) db downgrade --directory $(MIGRATIONS)
gettext:
$(SPHINXBUILD) -M gettext "$(SOURCEDIR)" "$(DOCSRC)"
LANGUAGE := en
html:
rm -rf $(BUILDDIR)/$(LANGUAGE)
rm -rf docs/$(LANGUAGE)/*
$(SPHINXBUILD) -M html "$(SOURCEDIR)" "$(BUILDDIR)/$(LANGUAGE)" -D language=$(LANGUAGE)
grep -rl "fosstodon.org" $(BUILDDIR)/$(LANGUAGE)/html/ | xargs sed -i "s/href=\"https:\/\/fosstodon.org\/\@FitTrackee\"/rel=\"me\" href=\"https:\/\/fosstodon.org\/\@FitTrackee\"/"
cp -a $(BUILDDIR)/$(LANGUAGE)/html/. docs/$(LANGUAGE)
html-all:
for language in en fr ; do \
echo -e "\r\nGenerating documentation for '$$language'...\r\n" ; \
$(MAKE) html LANGUAGE=$$language ; \
done
html-update-po:
$(SPHINXINTL) update -p "$(GETTEXT)" -d "$(LOCALES_DIRS)" -l $(LANGUAGE)
html-update-po-all:
for language in en fr ; do \
echo -e "\r\nUpdating .po files for '$$language'...\r\n" ; \
$(MAKE) html-update-po LANGUAGE=$$language ; \
done
install-db:
psql -U postgres -f db/create.sql
$(FTCLI) db upgrade
init-db:
$(FTCLI) db drop
$(FTCLI) db upgrade
install: install-client install-python
install-client:
# NPM_ARGS="--ignore-engines", if errors with Node latest version
cd fittrackee_client && $(NPM) install --prod $(NPM_ARGS)
install-client-dev:
# NPM_ARGS="--ignore-engines", if errors with Node latest version
cd fittrackee_client && $(NPM) install $(NPM_ARGS)
install-dev: install-client-dev install-python-dev
install-python:
$(POETRY) install --only main
install-python-dev:
$(POETRY) install
lint-all: lint-python lint-client
lint-all-fix: lint-python-fix lint-client-fix
lint-client:
cd fittrackee_client && $(NPM) lint
lint-client-fix:
cd fittrackee_client && $(NPM) format
lint-python:
$(RUFF) check fittrackee e2e
lint-python-fix:
$(RUFF) format fittrackee e2e
$(RUFF) check --fix fittrackee e2e
mail:
docker run -d -e "MH_STORAGE=maildir" -v /tmp/maildir:/maildir -p 1025:1025 -p 8025:8025 mailhog/mailhog
migrate-db:
$(FLASK) db migrate --directory $(MIGRATIONS)
revision:
$(FLASK) db revision --directory $(MIGRATIONS) --message $(MIGRATION_MESSAGE)
run:
$(MAKE) P="run-server run-workers" make-p
run-server:
echo 'Running on http://$(HOST):$(PORT)'
cd fittrackee && $(GUNICORN) -b $(HOST):$(PORT) "fittrackee:create_app()" --error-logfile ../gunicorn.log
run-workers:
$(FLASK) worker --processes=$(WORKERS_PROCESSES) >> dramatiq.log 2>&1
serve:
# for dev environments
$(MAKE) P="serve-client serve-python" make-p
serve-dev:
# for dev environments
$(MAKE) P="serve-client serve-python-dev" make-p
serve-client:
# for dev environments
cd fittrackee_client && PORT=3000 $(NPM) dev
serve-python:
# for dev environments
echo 'Running on http://$(HOST):$(PORT)'
$(FLASK) run --with-threads -h $(HOST) -p $(PORT)
serve-python-dev:
# for dev environments (
echo 'Running on https://$(HOST):$(PORT)'
$(FLASK) run --with-threads -h $(HOST) -p $(PORT) --cert=adhoc
set-admin:
echo "Deprecated command, will be removed in a next version. Use 'user-set-admin' instead."
$(FTCLI) users update $(USERNAME) --set-admin true
test-all: test-client test-python
test-e2e:
$(PYTEST) e2e --driver firefox $(PYTEST_ARGS)
test-e2e-client:
E2E_ARGS=client $(PYTEST) e2e --driver firefox $(PYTEST_ARGS)
test-python:
# for tests parallelization: 4 workers max.
# make test-python PYTEST_ARGS="-p no:warnings -n auto --maxprocesses=4"
$(PYTEST) fittrackee --cov-config .coveragerc --cov=fittrackee --cov-report term-missing $(PYTEST_ARGS)
test-client:
cd fittrackee_client && $(NPM) test:unit run
test-client-watch:
cd fittrackee_client && $(NPM) test:unit watch
type-check:
echo 'Running mypy...'
$(MYPY) fittrackee
type-check-all: type-check-client type-check
type-check-client:
cd fittrackee_client && $(NPM) type-check
upgrade-db:
$(FTCLI) db upgrade
user-activate:
$(FTCLI) users update $(USERNAME) --activate
user-reset-password:
$(FTCLI) users update $(USERNAME) --reset-password
ADMIN := true
user-set-admin:
$(FTCLI) users update $(USERNAME) --set-admin $(ADMIN)
user-update-email:
$(FTCLI) users update $(USERNAME) --update-email $(EMAIL)