-
Notifications
You must be signed in to change notification settings - Fork 5
/
Makefile
64 lines (52 loc) · 1.79 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
PYTHON_MODULE := pytest_hoverfly
ENVIRONMENT := dev
VENV_NAME := .venv
PYTHON_BIN := python3
POETRY_VERSION := 1.0.3
POETRY_BIN := ${HOME}/.poetry/bin/poetry
MAX_LINE_LENGTH := 120
.PHONY: help test lint pyfmt prepare clean version name install_poetry
help:
@echo "Help"
@echo "----"
@echo
@echo " prepare - create venv and install requirements"
@echo " tests - run pytest"
@echo " lint - run available linters"
@echo " pyfmt - run available formatters"
@echo " clean - clean directory from created files"
@echo " version - print package version"
@echo " name - print package name"
@echo " install_poetry - install poetry"
install_poetry:
curl -sSL https://raw.githubusercontent.com/sdispater/poetry/${POETRY_VERSION}/get-poetry.py > get-poetry.py \
&& cat get-poetry.py | sha256sum -c poetry-${POETRY_VERSION}.checksum \
&& python get-poetry.py --version ${POETRY_VERSION} -y \
&& rm get-poetry.py
prepare:
${PYTHON_BIN} -m venv ${VENV_NAME} \
&& . ${VENV_NAME}/bin/activate \
&& (if [ "${ENVIRONMENT}" = "prod" ]; \
then ${POETRY_BIN} install --no-dev --no-root \
&& ${POETRY_BIN} build --format=wheel \
&& python -m pip install dist/*.whl; \
else ${POETRY_BIN} install; \
fi)
test:
python -m pytest tests/ --cov=${PYTHON_MODULE}
lint:
flake8 --max-line-length=120 ${PYTHON_MODULE} tests
black -l ${MAX_LINE_LENGTH} --check ${PYTHON_MODULE} tests
isort -l ${MAX_LINE_LENGTH} --check-only --diff --jobs 4 ${PYTHON_MODULE} tests
pyfmt:
black -l ${MAX_LINE_LENGTH} --quiet ${PYTHON_MODULE} tests
isort -l ${MAX_LINE_LENGTH} ${PYTHON_MODULE} tests --jobs 4
clean:
rm -rf ${VENV_NAME}
find . -name \*.pyc -delete
version:
@sed -n 's/.*version = "\(.*\)".*/\1/p' pyproject.toml
name:
@sed -n 's/.*name = "\(.*\)".*/\1/p' pyproject.toml
publish:
${POETRY_BIN} publish --build