-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathMakefile
67 lines (54 loc) · 1.93 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
.PHONY: black clean help install isort lint mypy formatters test local-test venv build-flow register-flow
.DEFAULT_GOAL := help
help:
@python -c "$$PRINT_HELP_PYSCRIPT" < $(MAKEFILE_LIST)
install: ## Install the package dev to the active Python's site-packages
if [ -z ${VIRTUAL_ENV} ]; then \
echo "\nattempting to activate venv\n" \
&& . ./venv/bin/activate \
&& pip3 install --upgrade pip \
&& pip3 install -r requirements.txt --no-cache-dir \
&& pip3 install -e '.[dev, tests]'; \
else \
echo "\nvirtual environment detected\n" \
&& pip3 install --upgrade pip \
&& pip3 install -r requirements.txt --no-cache-dir \
&& pip3 install -e '.[dev, tests]';\
fi
clean: ## Remove test and coverage artifacts
rm -f .coverage
rm -fr htmlcov/
rm -fr .pytest_cache
rm -fr .mypy_cache
black: ## Format with black
black src tests
isort: ## Format and sort imports
isort src
lint: ## Check style with flake8
flake8 src
mypy: ## Typechecking with mypy
mypy src
formatters: black isort lint mypy
test: venv install ## Run unit tests with coverage
if [ -z ${VIRTUAL_ENV} ]; then \
echo "\nattempting to activate virtual environment\n" \
&& . ./venv/bin/activate \
&& pytest --cov=src/ --cov-report term-missing tests/ \
&& coverage report --fail-under=70 \
&& rm -rf .coverage; \
else \
echo "\nvirtual environment detected\n" \
&& pytest --cov=src/ --cov-report term-missing tests/ \
&& coverage report --fail-under=70 \
&& rm -rf .coverage; \
fi
local-test: ## Runs unit tests
pytest --cov=src/ --cov-report term-missing tests/
venv: ## Check if operating in a virtual environment, create if not detected.
if [ ! -z ${VIRTUAL_ENV} ]; then echo "\nvirtual environment detected\n"; else python3.8 -m venv venv && . ./venv/bin/activate; fi
package:
@ pip install -U pip
@ pip install .[packaging]
@ python -m build --sdist --wheel --outdir dist/ .
publish: venv login
twine upload --verbose dist/*