|
| 1 | +.NOTPARALLEL: ; # wait for this target to finish |
| 2 | +.EXPORT_ALL_VARIABLES: ; # send all vars to shell |
| 3 | +.PHONY: all # All targets are accessible for user |
| 4 | +.DEFAULT: help # Running Make will run the help target |
| 5 | + |
| 6 | +PYTHON = @.venv/bin/python -m |
| 7 | +APP = bitrix24 |
| 8 | + |
| 9 | +# ------------------------------------------------------------------------------------------------- |
| 10 | +# help: @ List available tasks on this project |
| 11 | +# ------------------------------------------------------------------------------------------------- |
| 12 | +help: |
| 13 | + @grep -oE '^#.[a-zA-Z0-9]+:.*?@ .*$$' $(MAKEFILE_LIST) | tr -d '#' |\ |
| 14 | + awk 'BEGIN {FS = ":.*?@ "}; {printf " make%-10s%s\n", $$1, $$2}' |
| 15 | + |
| 16 | +# ------------------------------------------------------------------------------------------------- |
| 17 | +# all: @ Apply all checks at once |
| 18 | +# ------------------------------------------------------------------------------------------------- |
| 19 | +all: format lint test |
| 20 | + |
| 21 | +# ------------------------------------------------------------------------------------------------- |
| 22 | +# init: @ Setup local environment |
| 23 | +# ------------------------------------------------------------------------------------------------- |
| 24 | +init: activate install |
| 25 | + |
| 26 | +# ------------------------------------------------------------------------------------------------- |
| 27 | +# update: @ Update package dependencies and install them |
| 28 | +# ------------------------------------------------------------------------------------------------- |
| 29 | +update: compile install |
| 30 | + |
| 31 | +# ------------------------------------------------------------------------------------------------- |
| 32 | +# Activate virtual environment |
| 33 | +# ------------------------------------------------------------------------------------------------- |
| 34 | +activate: |
| 35 | + @python3 -m venv .venv |
| 36 | + @. .venv/bin/activate |
| 37 | + |
| 38 | +# ------------------------------------------------------------------------------------------------- |
| 39 | +# Install packages to current environment |
| 40 | +# ------------------------------------------------------------------------------------------------- |
| 41 | +install: |
| 42 | + $(PYTHON) pip install -e .[dev] |
| 43 | + |
| 44 | +# ------------------------------------------------------------------------------------------------- |
| 45 | +# test: @ Run tests using pytest |
| 46 | +# ------------------------------------------------------------------------------------------------- |
| 47 | +test: |
| 48 | + $(PYTHON) pytest tests --cov=. |
| 49 | + |
| 50 | +# ------------------------------------------------------------------------------------------------- |
| 51 | +# lint: @ Checks the source code against coding standard rules and safety |
| 52 | +# ------------------------------------------------------------------------------------------------- |
| 53 | +lint: lint.setup lint.flake8 lint.safety lint.docs |
| 54 | + |
| 55 | +# ------------------------------------------------------------------------------------------------- |
| 56 | +# format: @ Format source code and auto fix minor issues |
| 57 | +# ------------------------------------------------------------------------------------------------- |
| 58 | +format: |
| 59 | + $(PYTHON) black --quiet --line-length=100 $(APP) |
| 60 | + $(PYTHON) isort $(APP) |
| 61 | + |
| 62 | +# ------------------------------------------------------------------------------------------------- |
| 63 | +# setup.py |
| 64 | +# ------------------------------------------------------------------------------------------------- |
| 65 | +lint.setup: |
| 66 | + $(PYTHON) setup check -s |
| 67 | + |
| 68 | +# ------------------------------------------------------------------------------------------------- |
| 69 | +# flake8 |
| 70 | +# ------------------------------------------------------------------------------------------------- |
| 71 | +lint.flake8: |
| 72 | + $(PYTHON) flake8 --exclude=.venv,.eggs,*.egg,.git,migrations,__init__.py \ |
| 73 | + --filename=*.py,*.pyx \ |
| 74 | + --max-line-length=100 . |
| 75 | + |
| 76 | +# ------------------------------------------------------------------------------------------------- |
| 77 | +# safety |
| 78 | +# ------------------------------------------------------------------------------------------------- |
| 79 | +lint.safety: |
| 80 | + $(PYTHON) safety check --full-report |
| 81 | + |
| 82 | +# ------------------------------------------------------------------------------------------------- |
| 83 | +# pydocstyle |
| 84 | +# ------------------------------------------------------------------------------------------------- |
| 85 | +# Ignored error codes: |
| 86 | +# D100 Missing docstring in public module |
| 87 | +# D101 Missing docstring in public class |
| 88 | +# D102 Missing docstring in public method |
| 89 | +# D103 Missing docstring in public function |
| 90 | +# D104 Missing docstring in public package |
| 91 | +# D105 Missing docstring in magic method |
| 92 | +# D106 Missing docstring in public nested class |
| 93 | +# D107 Missing docstring in __init__ |
| 94 | +lint.docs: |
| 95 | + $(PYTHON) pydocstyle --convention=numpy --add-ignore=D100,D101,D102,D103,D104,D105,D106,D107 . |
| 96 | + |
| 97 | +# ------------------------------------------------------------------------------------------------- |
| 98 | +# clean: @ Remove artifacts and temp files |
| 99 | +# ------------------------------------------------------------------------------------------------- |
| 100 | +clean: |
| 101 | + @rm -rf .venv/ dist/ build/ *.egg-info/ .pytest_cache/ .coverage coverage.xml |
| 102 | + @find . | grep -E "\(__pycache__|\.pyc|\.pyo\$\)" | xargs rm -rf |
0 commit comments