-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmakefile
136 lines (108 loc) · 3.34 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
ARGUMENTS = $(filter-out $@,$(MAKECMDGOALS)) $(filter-out --,$(MAKEFLAGS))
clean:
-find . -type f -name "*.pyc" -delete
-find . -type d -name "__pycache__" -delete
# configuration for black and isort is in pyproject.toml
autoformat:
isort $(PWD)
black $(PWD)
checks:
isort $(PWD) --check
black $(PWD) --check --verbose
flake8 .
ENV_FILES?='test,dev'
pytest:
ENV_FILES=$(ENV_FILES) \
pytest \
tests/unit \
--junit-xml=./results/pytest_unit_report.xml \
--cov-config=.coveragerc \
--cov-report=html \
--cov=. \
$(ARGUMENTS)
ENV_FILES?='test,dev'
pytest_codecov:
ENV_FILES=$(ENV_FILES) \
pytest \
tests/unit \
--junit-xml=./results/pytest_unit_report.xml \
--cov-config=.coveragerc \
--cov-report=html \
--cov=. \
--codecov \
$(ARGUMENTS)
# Usage: make pytest_single <path_to_file>::<method_name>
pytest_single:
ENV_FILES=$(ENV_FILES) \
pytest \
$(ARGUMENTS)
--junit-xml=./results/pytest_unit_report.xml \
--cov-config=.coveragerc \
--cov-report=html \
--cov=. \
pytest_browser:
ENV_FILES=$(ENV_FILES) \
pytest \
tests/browser \
--junit-xml=./results/pytest_browser_report.xml \
--ignore='./venv/' \
--color=no \
$(ARGUMENTS)
flake8:
flake8 . \
--exclude=ENV,ENV2,.venv,venv,node_modules,migrations \
--max-line-length=120
manage:
ENV_FILES='secrets-do-not-commit,dev' ./manage.py $(ARGUMENTS)
ENV_FILES?='secrets-do-not-commit,dev'
check_migrations:
yes n | ENV_FILES=$(ENV_FILES) ./manage.py migrate --plan
webserver: # runs on 8020
ENV_FILES='secrets-do-not-commit,dev' python manage.py runserver_plus 0.0.0.0:8020 --keep-meta-shutdown $(ARGUMENTS)
LOCUST_FILE?=tests/load/mvp_home.py
NUM_USERS?=10
HATCH_RATE?=2
RUN_TIME?=30s
LOCUST := \
locust \
--locustfile $(LOCUST_FILE) \
--users=$(NUM_USERS) \
--spawn-rate=$(HATCH_RATE) \
--run-time=$(RUN_TIME) \
--headless \
--csv=./results/results
kill_webserver := \
pkill -f runserver_plus
loadserver: # runs on 8020
ENV_FILES='test,dev' python manage.py runserver_plus 0.0.0.0:8020 --keep-meta-shutdown &
test_load:
sleep 25
$(LOCUST)
-$(kill_webserver)
requirements:
pip-compile --upgrade -r --annotate requirements.in
pip-compile --upgrade -r --annotate requirements_test.in
install_requirements:
pip install -q -r requirements_test.txt
pre-commit install --install-hooks
secrets:
@if [ ! -f ./config/env/secrets-do-not-commit ]; \
then sed -e 's/#DO NOT ADD SECRETS TO THIS FILE//g' config/env/secrets-template > config/env/secrets-do-not-commit \
&& echo "Created config/env/secrets-do-not-commit"; \
else echo "config/env/secrets-do-not-commit already exists. Delete first to recreate it."; \
fi
database:
PGPASSWORD=debug dropdb --if-exists -h localhost -U debug greatcms
PGPASSWORD=debug createdb -h localhost -U debug greatcms
recreate:
$(MAKE) database
$(MAKE) ARGUMENTS=migrate manage
$(MAKE) ARGUMENTS=bootstrap_great manage
$(MAKE) ARGUMENTS=create_tours manage
worker:
ENV_FILES='secrets-do-not-commit,dev' celery -A config worker -l info
beat:
ENV_FILES='secrets-do-not-commit,dev' celery -A config beat -l info -S django
checkmigrations:
ENV_FILES='secrets-do-not-commit,dev' python manage.py makemigrations --dry-run --check
.PHONY: checkmigrations clean autoformat checks pytest test_load flake8 manage webserver requirements install_requirements css worker secrets check_migrations database recreate worker beat