-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
157 lines (99 loc) · 2.66 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
DOCKER_COMPOSE_DEV = docker compose
DOCKER_COMPOSE_CI = docker compose -f docker-compose.yml
DOCKER_COMPOSE = $(DOCKER_COMPOSE_DEV)
VENV = venv
PIP = $(VENV)/bin/pip
PYTHON = $(VENV)/bin/python
DOCKER_RUN = $(DOCKER_COMPOSE) run --rm sciety-labs
DOCKER_PYTHON = $(DOCKER_RUN) python
ARGS =
PYTEST_WATCH_MODULES = tests/unit_tests
LOCUST_FILE =
LOAD_TEST_PORT = 8101
.require-%:
@ if [ "${${*}}" = "" ]; then \
echo "Environment variable $* not set"; \
exit 1; \
fi
venv-clean:
@if [ -d "$(VENV)" ]; then \
rm -rf "$(VENV)"; \
fi
venv-create:
python3 -m venv $(VENV)
venv-activate:
chmod +x venv/bin/activate
bash -c "venv/bin/activate"
dev-install:
$(PIP) install --disable-pip-version-check \
-r requirements.build.txt \
-r requirements.txt \
-r requirements.dev.txt
dev-venv: venv-create dev-install
dev-flake8:
$(PYTHON) -m flake8 sciety_labs tests
dev-pylint:
$(PYTHON) -m pylint sciety_labs tests
dev-mypy:
$(PYTHON) -m mypy sciety_labs tests
dev-lint: dev-flake8 dev-pylint dev-mypy
dev-unittest:
$(PYTHON) -m pytest -p no:cacheprovider $(ARGS) tests/unit_tests
dev-watch:
$(PYTHON) -m pytest_watch -- -p no:cacheprovider $(ARGS) $(PYTEST_WATCH_MODULES)
dev-test: dev-lint dev-unittest
dev-regression-test:
$(PYTHON) -m pytest -p no:cacheprovider $(ARGS) tests/regression_tests
dev-start:
$(PYTHON) -m uvicorn \
sciety_labs.app.main:create_app \
--reload \
--factory \
--host 127.0.0.1 \
--port 8000 \
--log-config=config/logging.yaml
dev-start-without-reload:
$(PYTHON) -m uvicorn \
sciety_labs.app.main:create_app \
--factory \
--host 127.0.0.1 \
--port 8000 \
--lifespan on \
--log-config=config/logging.yaml
dev-start-load-test-ui: .require-LOCUST_FILE
PYTHONWARNINGS="ignore:Unverified HTTPS request" \
$(PYTHON) -m locust \
--web-port=$(LOAD_TEST_PORT) \
--locustfile=$(LOCUST_FILE)
check-or-reload-data:
curl \
--fail-with-body \
--request POST \
http://localhost:8000/api/check-or-reload-data
build:
$(DOCKER_COMPOSE) build sciety-labs
flake8:
$(DOCKER_PYTHON) -m flake8 sciety_labs tests
pylint:
$(DOCKER_PYTHON) -m pylint sciety_labs tests
mypy:
$(DOCKER_PYTHON) -m mypy sciety_labs tests
lint: flake8 pylint mypy
unittest:
$(DOCKER_PYTHON) -m pytest -p no:cacheprovider $(ARGS) tests/unit_tests
watch:
$(DOCKER_PYTHON) -m pytest_watch -- -p no:cacheprovider $(ARGS) $(PYTEST_WATCH_MODULES)
test: lint unittest
start:
$(DOCKER_COMPOSE) up -d
stop:
$(DOCKER_COMPOSE) down
logs:
$(DOCKER_COMPOSE) logs -f
docker-push:
$(DOCKER_COMPOSE) push sciety-labs
ci-build-and-test:
$(MAKE) DOCKER_COMPOSE="$(DOCKER_COMPOSE_CI)" \
build test
ci-clean:
$(DOCKER_COMPOSE_CI) down -v