This repository has been archived by the owner on May 7, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
315 lines (294 loc) · 14.3 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
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
.DEFAULT_GOAL := help
ifeq ($(OS),Windows_NT)
DCR_DOCKER_CONTAINER=scripts\\run_setup_postgresql.bat test
export MYPYPATH=
export PIPENV=python -m pipenv
export PYTHON=python
export PYTHONPATH=src\\dcr
else
DCR_DOCKER_CONTAINER=./scripts/run_setup_postgresql.sh test
export MYPYPATH=
export PIPENV=python3 -m pipenv
export PYTHON=python3
export PYTHONPATH=src/dcr
endif
## .
## ============================================================================
## DCR - Document Content Recognition - make Documentation.
## ---------------------------------------------------------------
## The purpose of this Makefile is to support the whole software
## development process for DCR. it contains also the necessary
## tools for the CI activities.
## ---------------------------------------------------------------
## The available make commands are:
## ----------------------------------------------------------------------------
## help: Show this help.
## ----------------------------------------------------------------------------
## dcr-core: Update the dcr-core API.
dcr-core: update-dcr-core version-dcr-core
## dev: Format, lint and test the code.
dev: format lint tests
## docs: Check the API documentation, create and upload the user documentation.
docs: pydocstyle mkdocs
## final: Format, lint and test the code and create the documentation.
final: format lint docs tests
## format: Format the code with isort, Black and docformatter.
format: isort black docformatter
## lint: Lint the code with Bandit, Flake8, Pylint and Mypy.
lint: bandit flake8 pylint mypy
## tests: Run all tests with pytest.
tests: pytest
## update: Update dcr-core.
update: update-dcr-core version-dcr-core
## ----------------------------------------------------------------------------
help:
@sed -ne '/@sed/!s/## //p' $(MAKEFILE_LIST)
export DCR_ENVIRONMENT_TYPE=test
# Bandit is a tool designed to find common security issues in Python code.
# https://github.com/PyCQA/bandit
# Configuration file: none
bandit: ## Find common security issues with Bandit.
@echo Info ********** Start: Bandit **************************************
@echo MYPYPATH =${MYPYPATH}
@echo PYTHON =${PYTHON}
@echo PYTHONPATH=${PYTHONPATH}
${PIPENV} run bandit --version
@echo ---------------------------------------------------------------------
${PIPENV} run bandit -c pyproject.toml -r ${PYTHONPATH}
@echo Info ********** End: Bandit **************************************
# The Uncompromising Code Formatter
# https://github.com/psf/black
# Configuration file: pyproject.toml
black: ## Format the code with Black.
@echo Info ********** Start: black ***************************************
@echo MYPYPATH =${MYPYPATH}
@echo PYTHON =${PYTHON}
@echo PYTHONPATH=${PYTHONPATH}
${PIPENV} run black --version
@echo ---------------------------------------------------------------------
${PIPENV} run black ${PYTHONPATH} tests
@echo Info ********** End: black ***************************************
# Byte-compile Python libraries
# https://docs.python.org/3/library/compileall.html
# Configuration file: none
compileall: ## Byte-compile the Python libraries.
@echo Info ********** Start: Compile All Python Scripts ******************
@echo MYPYPATH =${MYPYPATH}
@echo PYTHON =${PYTHON}
@echo PYTHONPATH=${PYTHONPATH}
${PYTHON} --version
@echo ---------------------------------------------------------------------
${PYTHON} -m compileall
@echo Info ********** End: Compile All Python Scripts ******************
# Python interface to coveralls.io API
# https://github.com/TheKevJames/coveralls-python
# Configuration file: none
coveralls: ## Run all the tests and upload the coverage data to coveralls.
@echo Info ********** Start: coveralls ***********************************
${PIPENV} run pytest --cov=${PYTHONPATH} --cov-report=xml tests
@echo ---------------------------------------------------------------------
${PIPENV} run coveralls --service=github
@echo Info ********** End: coveralls ***********************************
# Formats docstrings to follow PEP 257
# https://github.com/PyCQA/docformatter
# Configuration file: none
docformatter: ## Format the docstrings with docformatter.
@echo Info ********** Start: docformatter ********************************
@echo MYPYPATH =${MYPYPATH}
@echo PYTHON =${PYTHON}
@echo PYTHONPATH=${PYTHONPATH}
${PIPENV} run docformatter --version
@echo ---------------------------------------------------------------------
${PIPENV} run docformatter --in-place -r ${PYTHONPATH} tests
@echo Info ********** End: docformatter ********************************
# Flake8: Your Tool For Style Guide Enforcement.
# includes McCabe: https://github.com/PyCQA/mccabe
# includes pycodestyle: https://github.com/PyCQA/pycodestyle
# includes Pyflakes: https://github.com/PyCQA/pyflakes
# includes Radon: https://github.com/rubik/radon
# https://github.com/pycqa/flake8
# Configuration file: cfg.cfg
flake8: ## Enforce the Python Style Guides with Flake8.
@echo Info ********** Start: Flake8 **************************************
@echo MYPYPATH =${MYPYPATH}
@echo PYTHON =${PYTHON}
@echo PYTHONPATH=${PYTHONPATH}
${PIPENV} run flake8 --version
@echo ---------------------------------------------------------------------
${PIPENV} run flake8 --exclude TET.py ${PYTHONPATH} tests
@echo Info ********** End: Flake8 **************************************
# isort your imports, so you don't have to.
# https://github.com/PyCQA/isort
# Configuration file: pyproject.toml
isort: ## Edit and sort the imports with isort.
@echo Info ********** Start: isort ***************************************
@echo MYPYPATH =${MYPYPATH}
@echo PYTHON =${PYTHON}
@echo PYTHONPATH=${PYTHONPATH}
${PIPENV} run isort --version
@echo ---------------------------------------------------------------------
${PIPENV} run isort ${PYTHONPATH} tests
@echo Info ********** End: isort ***************************************
# Project documentation with Markdown.
# https://github.com/mkdocs/mkdocs/
# Configuration file: none
mkdocs: ## Create and upload the user documentation with MkDocs.
@echo Info ********** Start: MkDocs **************************************
@echo MYPYPATH =${MYPYPATH}
@echo PYTHON =${PYTHON}
@echo PYTHONPATH=${PYTHONPATH}
${PIPENV} run mkdocs --version
@echo ---------------------------------------------------------------------
${PIPENV} run mkdocs gh-deploy --force
@echo Info ********** End: MkDocs **************************************
# Mypy: Static Typing for Python
# https://github.com/python/mypy
# Configuration file: pyproject.toml
mypy: ## Find typing issues with Mypy.
@echo Info ********** Start: Mypy ****************************************
@echo MYPYPATH =${MYPYPATH}
@echo PYTHON =${PYTHON}
@echo PYTHONPATH=${PYTHONPATH}
${PIPENV} run mypy --version
@echo ---------------------------------------------------------------------
${PIPENV} run mypy --exclude TET.py ${PYTHONPATH}
@echo Info ********** End: Mypy ****************************************
# pip is the package installer for Python.
# https://pypi.org/project/pip/
# Configuration file: none
# Pipenv: Python Development Workflow for Humans.
# https://github.com/pypa/pipenv
# Configuration file: Pipfile
pipenv-dev: ## Install the package dependencies for development.
@echo Info ********** Start: Installation of Development Packages ********
@echo MYPYPATH =${MYPYPATH}
@echo PYTHON =${PYTHON}
@echo PYTHONPATH=${PYTHONPATH}
@echo ---------------------------------------------------------------------
${PYTHON} -m pip install --upgrade pip
${PYTHON} -m pip install --upgrade pipenv
${PIPENV} install --dev
${PIPENV} --rm
exit
${PIPENV} update --dev
${PIPENV} run spacy download de_dep_news_trf
${PIPENV} run spacy download en_core_web_trf
${PIPENV} run spacy download fr_dep_news_trf
${PIPENV} run spacy download it_core_news_lg
@echo ---------------------------------------------------------------------
${PIPENV} run pip freeze
@echo ---------------------------------------------------------------------
${PYTHON} --version
${PYTHON} -m pip --version
@echo Info ********** End: Installation of Development Packages ********
pipenv-prod: ## Install the package dependencies for production.
@echo Info ********** Start: Installation of Production Packages *********
@echo MYPYPATH =${MYPYPATH}
@echo PYTHON =${PYTHON}
@echo PYTHONPATH=${PYTHONPATH}
@echo ---------------------------------------------------------------------
${PYTHON} -m pip install --upgrade pip
${PYTHON} -m pip install --upgrade pipenv
${PYTHON} -m pipenv install
${PYTHON} -m pipenv --rm
exit
${PYTHON} -m pipenv update
${PIPENV} run spacy download de_dep_news_trf
${PIPENV} run spacy download en_core_web_trf
${PIPENV} run spacy download fr_dep_news_trf
${PIPENV} run spacy download it_core_news_lg
@echo ---------------------------------------------------------------------
${PIPENV} run pip freeze
@echo ---------------------------------------------------------------------
${PYTHON} --version
${PYTHON} -m pip --version
@echo Info ********** End: Installation of Production Packages *********
# pydocstyle - docstring style checker.
# https://github.com/PyCQA/pydocstyle
# Configuration file: pyproject.toml
pydocstyle: ## Check the API documentation with pydocstyle.
@echo Info ********** Start: pydocstyle **********************************
@echo MYPYPATH =${MYPYPATH}
@echo PYTHON =${PYTHON}
@echo PYTHONPATH=${PYTHONPATH}
${PIPENV} run pydocstyle --version
@echo ---------------------------------------------------------------------
${PIPENV} run pydocstyle --count ${PYTHONPATH} tests
@echo Info ********** End: pydocstyle **********************************
# Pylint is a tool that checks for errors in Python code.
# https://github.com/PyCQA/pylint/
# Configuration file: .pylintrc
pylint: ## Lint the code with Pylint.
@echo Info ********** Start: Pylint **************************************
@echo MYPYPATH =${MYPYPATH}
@echo PYTHON =${PYTHON}
@echo PYTHONPATH=${PYTHONPATH}
${PIPENV} run pylint --version
@echo ---------------------------------------------------------------------
${PIPENV} run pylint ${PYTHONPATH} tests
@echo Info ********** End: Pylint **************************************
# pytest: helps you write better programs.
# https://github.com/pytest-dev/pytest/
# Configuration file: pyproject.toml
pytest: ## Run all tests with pytest.
@echo Info ********** Start: pytest **************************************
$(DCR_DOCKER_CONTAINER)
${PIPENV} run pytest --version
@echo ---------------------------------------------------------------------
${PIPENV} run pytest --dead-fixtures tests
${PIPENV} run pytest --cache-clear --cov=${PYTHONPATH} --cov-report term-missing:skip-covered --random-order -v tests
@echo Info ********** End: pytest **************************************
pytest-ci: ## Run all tests with pytest after test tool installation.
@echo Info ********** Start: pytest **************************************
$(DCR_DOCKER_CONTAINER)
${PIPENV} install pytest
${PIPENV} install pytest-cov
${PIPENV} install pytest-deadfixtures
${PIPENV} install pytest-helpers-namespace
${PIPENV} install pytest-random-order
${PIPENV} install roman
@echo ---------------------------------------------------------------------
${PIPENV} run pytest --version
@echo ---------------------------------------------------------------------
${PIPENV} run pytest --dead-fixtures tests
${PIPENV} run pytest --cache-clear --cov=${PYTHONPATH} --cov-report term-missing:skip-covered --random-order -v tests
@echo Info ********** End: pytest **************************************
pytest-first-issue: ## Run all tests with pytest until the first issue occurs.
@echo Info ********** Start: pytest **************************************
@echo DCR_ENVIRONMENT_TYPE=${DCR_ENVIRONMENT_TYPE}
${PIPENV} run pytest --version
@echo ---------------------------------------------------------------------
${PIPENV} run pytest --cache-clear --cov=${PYTHONPATH} --cov-report term-missing:skip-covered --random-order -v -x tests
@echo Info ********** End: pytest **************************************
pytest-issue: ## Run only the tests with pytest which are marked with 'issue'.
@echo Info ********** Start: pytest **************************************
@echo DCR_ENVIRONMENT_TYPE=${DCR_ENVIRONMENT_TYPE}
${PIPENV} run pytest --version
@echo ---------------------------------------------------------------------
${PIPENV} run pytest --cache-clear --cov=${PYTHONPATH} --cov-report term-missing:skip-covered -m issue -s --setup-show -v -x tests
@echo Info ********** End: pytest **************************************
pytest-module: ## Run tests of specific module(s) with pytest - test_all & test_cfg_cls_setup & test_db_cls.
@echo Info ********** Start: pytest **************************************
@echo DCR_ENVIRONMENT_TYPE=${DCR_ENVIRONMENT_TYPE}
${PIPENV} run pytest --version
@echo ---------------------------------------------------------------------
${PIPENV} run pytest --cache-clear --cov=${PYTHONPATH} --cov-report term-missing:skip-covered -v tests/test_db_cls_action.py
@echo Info ********** End: pytest **************************************
update-dcr-core: ## Update dcr-core.
pipenv update dcr-core
version: ## Show the installed software versions.
@echo Info ********** Start: pip *****************************************
pipenv run pip freeze
@echo ---------------------------------------------------------------------
${PYTHON} --version
${PYTHON} -m build --version
${PYTHON} -m pip --version
${PIPENV} --version
@echo ---------------------------------------------------------------------
@echo MYPYPATH =${MYPYPATH}
@echo PYTHON =${PYTHON}
@echo PYTHONPATH=${PYTHONPATH}
@echo Info ********** End: pip *****************************************
version-dcr-core: ## Version dcr-core.
${PIPENV} run pip freeze | grep dcr-core
## ============================================================================