-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
140 lines (111 loc) · 3.76 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
SHELL=/bin/bash
PACKAGE-NAME=jewel
export PYTEST_DISABLE_PLUGIN_AUTOLOAD = 1
UNIT_TESTS_PATH = tests/unit
help:
@echo "clean - remove all build, test, coverage and Python artifacts"
@echo "install - install package and dependencies globally but from the local path"
@echo "remove - uninstall package"
@echo "build - install package and dependencies for local development"
@echo "clean - clean all build and test artifacts"
@echo "clean-build - remove build artifacts"
@echo "clean-pyc - remove Python file artifacts"
@echo "clean-test - remove test and coverage artifacts"
@echo "lint-source - check style for source with flake8"
@echo "lint-tests - check style for tests with flake8"
@echo "lint-all - check style with flake8"
@echo "lint - alias for lint-source"
@echo "black - run black auto-formatting on all code"
@echo "test-unit - run unit tests"
@echo "test - run specified tests, e.g.:"
@echo " make test DEST=tests/unit/my_module.py"
@echo " (defaults to unit tests if none specified)"
@echo "test-stop - run tests and stop on the first failure"
@echo "test-debug - run specified tests and enter debugger on the first failure. e.g."
@echo " make test-debug DEST=tests/unit/my_module.py"
@echo " (defaults to unit tests if none specified)"
@echo "test-matrix - run tests on every Python version with tox"
@echo "test-tldr - run specified tests and output just the stacktrace, e.g."
@echo " make test-tldr DEST=tests/unit/my_module.py"
@echo " (defaults to unit tests if none specified)"
@echo "debug - alias for test-debug"
@echo "tldr - alias for test-tldr"
@echo "coverage - check code coverage quickly with the default Python"
@echo "sdist - package"
install:
pip install -e .
remove:
pip uninstall $(PACKAGE-NAME)
build:
pip install -e .[dev]
build-for-test:
pip install -e .[test]
clean: clean-build clean-pyc clean-test
clean-build:
rm -fr build/
rm -fr dist/
rm -fr pip-wheel-metadata/
rm -fr .eggs/
rm -fr *.egg-info
clean-pyc:
find . -name '*.pyc' -exec rm -f {} +
find . -name '*.pyo' -exec rm -f {} +
find . -name '*~' -exec rm -f {} +
find . -name '__pycache__' -exec rm -fr {} +
clean-test:
rm -fr .tox/
rm -f .coverage
rm -fr coverage_html_report/
lint-source:
flake8 $(PACKAGE-NAME)
lint-tests:
flake8 tests
lint-all: lint-source lint-tests
lint: lint-source
black:
black $(PACKAGE-NAME) tests
test-unit:
python setup.py test --addopts $(UNIT_TESTS_PATH)
test-all: clean-test test-unit
test:
ifdef DEST
$(eval OPTS := --addopts $(DEST))
else
$(eval OPTS := --addopts $(UNIT_TESTS_PATH))
endif
python setup.py test $(OPTS)
# stop on first failing test
test-stop:
python setup.py test --addopts -x
# debug on first failing test
test-debug:
ifdef DEST
$(eval OPTS := --addopts "-x --pudb $(DEST)")
else
$(eval OPTS := --addopts "-x --pudb $(UNIT_TESTS_PATH)")
endif
python setup.py test $(OPTS)
test-matrix:
tox
test-tldr:
ifdef DEST
$(eval OPTS := --addopts "-p tldr -p no:sugar $(DEST)")
else
$(eval OPTS := --addopts "-p tldr -p no:sugar $(UNIT_TESTS_PATH)")
endif
python setup.py test $(OPTS)
# ideally this should launch pudb to step through the specified tests
debug: test-debug
tldr: test-tldr
coverage: clean-test
coverage run --source $(PACKAGE-NAME) setup.py test --addopts $(UNIT_TESTS_PATH)
coverage report -m
coverage html
open coverage_html_report/index.html
cover-coveralls: clean-test
coverage run --source $(PACKAGE-NAME) setup.py test --addopts $(UNIT_TESTS_PATH)
coveralls
sdist: clean
python setup.py sdist
ls -l dist
.PHONY: help build build-for-test docs clean clean-build clean-pyc clean-test lint-source lint-tests lint-all lint black test-unit test-all test test-stop test-debug test-matrix test-tldr test-wiki debug coverage cover-coveralls sdist