forked from WycliffeAssociates/DOC
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
177 lines (139 loc) · 5.88 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
.PHONY: checkvenv
checkvenv:
# raises error if environment is not active
ifeq ("$(VIRTUAL_ENV)","")
@echo "Venv is not activated!"
@echo "Activate venv first."
@echo
exit 1
endif
.PHONY: pyupgrade
pyupgrade: checkvenv
# checks if pip-tools is installed
ifeq ("$(wildcard .venv/bin/pip-compile)","")
@echo "Installing Pip-tools..."
@pip install pip-tools
endif
ifeq ("$(wildcard .venv/bin/pip-sync)","")
@echo "Installing Pip-tools..."
@pip install pip-tools
endif
.PHONY: build
build: checkvenv local-update-deps-dev
docker-compose build
.PHONY: build-no-cache
build-no-cache: checkvenv
docker-compose build --no-cache
.PHONY: up
up: checkvenv
docker-compose up -d
.PHONY: server
server: up
docker-compose run api
.PHONY: test
test: up
docker-compose run --rm --no-deps --entrypoint=pytest api /tests/unit /tests/integration /tests/e2e
.PHONY: unit-tests
unit-tests: up
docker-compose run --rm --no-deps --entrypoint=pytest api /tests/unit
.PHONY: integration-tests
integration-tests: up
docker-compose run --rm --no-deps --entrypoint=pytest api /tests/integration
.PHONY: e2e-tests
e2e-tests: up
docker-compose run --rm --no-deps --entrypoint=pytest api /tests/e2e
.PHONY: down
down:
docker-compose down --remove-orphans
.PHONY: mypy-install-types
mypy-install-types: checkvenv
mypy --install-types --non-interactive # install all missing stub packages
.PHONY: mypy
mypy: mypy-install-types
mypy src/document/*.py
mypy src/document/**/*.py
mypy tests/*.py
mypy tests/**/*.py
.PHONY: pyicontract-lint
pyicontract-lint: checkvenv
pyicontract-lint --dont_panic src/document/domain
pyicontract-lint --dont_panic src/document/utils
pyicontract-lint --dont_panic src/document/entrypoints
# https://radon.readthedocs.io/en/latest/commandline.html
.PHONY: radon-cyclomatic-complexity
radon-cyclomatic-complexity: checkvenv
radon cc src/document/**/*.py
.PHONY: radon-raw-stats
radon-raw-stats: checkvenv
radon raw src/document/**/*.py
.PHONY: radon-maintainability-index
radon-maintainability-index: checkvenv
radon mi src/document/**/*.py
.PHONY: radon-halstead-complexity
radon-halstead-complexity: checkvenv
radon hal src/document/**/*.py
.PHONY: vulture-dead-code
vulture-dead-code: checkvenv
vulture src/document/ --min-confidence 100
vulture tests/ --min-confidence 100
.PHONY: all
all: down build up test
.PHONY: all-plus-linting
all-plus-linting: mypy pyicontract-lint down build up test
#########################
# Local dev
# Run a local Uvicorn server outside Docker
.PHONY: local-uvicorn-server
local-server: checkvenv
uvicorn document.entrypoints.app:app --reload --host "127.0.0.1" --port "5005" --app-dir "./src/"
.PHONY: local-gunicorn-server
local-gunicorn-server: checkvenv
exec gunicorn --name IRG --worker-class uvicorn.workers.UvicornWorker --conf ./gunicorn.conf.py --pythonpath ./src document.entrypoints.app:app
.PHONY: local-update-deps-prod
local-update-deps-prod: checkvenv
pip-compile # --upgrade
.PHONY: local-update-deps-dev
local-update-deps-dev: local-update-deps-prod
pip-compile requirements-dev.in
# pip-compile --upgrade requirements-dev.in
.PHONY: local-install-deps-prod
local-install-deps-prod: local-update-deps-prod
pip install -r requirements.txt
.PHONY: local-install-deps-dev
local-install-deps-dev: local-update-deps-dev
pip install -r requirements.txt
pip install -r requirements-dev.txt
.PHONY: local-prepare-for-tests
local-prepare-for-tests: mypy pyicontract-lint local-clean-working-output-dir
.PHONY: local-prepare-for-tests-without-cleaning
local-prepare-for-tests-without-cleaning: mypy pyicontract-lint
.PHONY: local-clean-working-output-dir
local-clean-working-output-dir:
find working/output/ -type f -name "*.html" -exec rm -- {} +
find working/output/ -type f -name "*.pdf" -exec rm -- {} +
# local-unit-tests: local-install-deps-dev local-prepare-for-tests
.PHONY: local-unit-tests
local-unit-tests: local-prepare-for-tests-without-cleaning
IN_CONTAINER=false ENABLE_ASSET_CACHING=true SEND_EMAIL=false FROM_EMAIL="[email protected]" TO_EMAIL="[email protected]" pytest tests/unit/ -vv
# local-e2e-tests: local-install-deps-dev local-prepare-for-tests
.PHONY: local-e2e-tests
local-e2e-tests: local-prepare-for-tests-without-cleaning
IN_CONTAINER=false ENABLE_ASSET_CACHING=true SEND_EMAIL=false FROM_EMAIL="[email protected]" TO_EMAIL="[email protected]" pytest tests/e2e/ -vv
.PHONY: local-smoke-test-with-translation-words
local-smoke-test-with-translation-words: local-prepare-for-tests
IN_CONTAINER=false ENABLE_ASSET_CACHING=true SEND_EMAIL=false FROM_EMAIL="[email protected]" TO_EMAIL="[email protected]" pytest tests/e2e/ -k test_en_ulb_wa_col_en_tn_wa_col_en_tq_wa_col_en_tw_wa_col_pt_br_ulb_col_pt_br_tn_col_pt_br_tq_col_pt_br_tw_col_book_language_order
.PHONY: local-smoke-test-with-translation-words2
local-smoke-test-with-translation-words2: local-prepare-for-tests
IN_CONTAINER=false ENABLE_ASSET_CACHING=true SEND_EMAIL=false FROM_EMAIL="[email protected]" TO_EMAIL="[email protected]" pytest tests/e2e/ -k test_en_ulb_wa_rom_en_tn_wa_rom_en_tq_wa_rom_en_tw_wa_rom_es_419_ulb_rom_es_419_tn_rom_en_tq_rom_es_419_tw_rom_book_language_order
.PHONY: local-icontract-hypothesis-tests
local-icontract-hypothesis-tests: local-prepare-for-tests
IN_CONTAINER=false ENABLE_ASSET_CACHING=true SEND_EMAIL=false FROM_EMAIL="[email protected]" TO_EMAIL="[email protected]" pyicontract-hypothesis test -p src/document/domain/resource.py
.PHONY: local-icontract-hypothesis-test2
local-icontract-hypothesis-tests2: local-prepare-for-tests
IN_CONTAINER=false ENABLE_ASSET_CACHING=true SEND_EMAIL=false FROM_EMAIL="[email protected]" TO_EMAIL="[email protected]" pyicontract-hypothesis test -p src/document/entrypoints/app.py
# This is one to run after running local-e2e-tests or any tests which
# has yielded HTML and PDFs that need to be checked for linking
# correctness.
.PHONY: local-check-anchor-links
local-check-anchor-links: checkvenv
IN_CONTAINER=false python tests/e2e/test_anchor_linking.py