forked from corvis/prana_rc
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
105 lines (93 loc) · 3.14 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
VIRTUAL_ENV_PATH=venv
SKIP_VENV="${NO_VENV}"
PYPI_API_KEY :=
PYPI_REPOSITORY_URL :=
ALPHA_VERSION :=
SHELL := /bin/bash
.DEFAULT_GOAL := pre_commit
pre_commit: copyright format lint test
copyright:
@( \
if [ -z $(SKIP_VENV) ]; then source $(VIRTUAL_ENV_PATH)/bin/activate; fi; \
echo "Applying copyright..."; \
./development/copyright-update; \
echo "DONE: copyright"; \
)
flake8:
@( \
set -e; \
if [ -z $(SKIP_VENV) ]; then source $(VIRTUAL_ENV_PATH)/bin/activate; fi; \
echo "Runing Flake8 checks..."; \
flake8 ./src/prana_rc --count --statistics; \
echo "DONE: Flake8"; \
)
mypy:
@( \
set -e; \
if [ -z $(SKIP_VENV) ]; then source $(VIRTUAL_ENV_PATH)/bin/activate; fi; \
echo "Runing MyPy checks..."; \
mypy --show-error-codes ./src/prana_rc; \
echo "DONE: MyPy"; \
)
lint: flake8 mypy
test:
@( \
set -e; \
if [ -z $(SKIP_VENV) ]; then source $(VIRTUAL_ENV_PATH)/bin/activate; fi; \
echo "Running unit tests..."; \
pytest; \
echo "DONE: unit tests"; \
)
build: copyright format lint clean
@( \
set -e; \
if [ -z $(SKIP_VENV) ]; then source $(VIRTUAL_ENV_PATH)/bin/activate; fi; \
echo "Building client wheel package..."; \
bash -c "cd src && VERSION_OVERRIDE="$(ALPHA_VERSION)" python ./client_setup.py bdist_wheel --dist-dir=../dist --bdist-dir=../../build"; \
echo "DONE: wheel client package"; \
)
@( \
set -e; \
if [ -z $(SKIP_VENV) ]; then source $(VIRTUAL_ENV_PATH)/bin/activate; fi; \
echo "Building wheel package..."; \
bash -c "cd src && VERSION_OVERRIDE="$(ALPHA_VERSION)" python ./setup.py bdist_wheel --dist-dir=../dist --bdist-dir=../../build"; \
echo "DONE: wheel package"; \
)
@( \
set -e; \
if [ -z $(SKIP_VENV) ]; then source $(VIRTUAL_ENV_PATH)/bin/activate; fi; \
echo "Building source distribution..."; \
bash -c "cd src && VERSION_OVERRIDE="$(ALPHA_VERSION)" python ./setup.py sdist --dist-dir=../dist"; \
echo "DONE: source distribution"; \
)
clean:
@(rm -rf src/build dist/* *.egg-info src/*.egg-info .pytest_cache)
format:
@( \
if [ -z $(SKIP_VENV) ]; then source $(VIRTUAL_ENV_PATH)/bin/activate; fi; \
echo "Runing Black code formater..."; \
black ./src/prana_rc; \
echo "DONE: Black"; \
)
publish:
@( \
set -e; \
if [ -z $(SKIP_VENV) ]; then source $(VIRTUAL_ENV_PATH)/bin/activate; fi; \
if [ ! -z $(PYPI_API_KEY) ]; then export TWINE_USERNAME="__token__"; export TWINE_PASSWORD="$(PYPI_API_KEY)"; fi; \
if [ ! -z $(PYPI_REPOSITORY_URL) ]; then export TWINE_REPOSITORY_URL="$(PYPI_REPOSITORY_URL)"; fi; \
echo "Uploading to PyPi"; \
twine upload -r pypi dist/*; \
echo "DONE: Publish"; \
)
set-version:
@( \
if [ -z $(VERSION) ]; then echo "Missing VERSION argument"; exit 1; fi; \
echo '__version__ = "$(VERSION)"' > ./src/prana_rc/__version__.py; \
echo "Version updated: $(VERSION)"; \
)
venv:
@( \
virtualenv $(VIRTUAL_ENV_PATH); \
source ./venv/bin/activate; \
pip install -r ./requirements.txt; \
)