-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
156 lines (124 loc) · 4.34 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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
SHELL=/bin/bash
PACKAGE-NAME=oldabe
DOCS-PATH=docs
export PYTEST_DISABLE_PLUGIN_AUTOLOAD = 1
UNIT_TESTS_PATH = tests/unit
INTEGRATION_TESTS_PATH = tests/integration
help:
@echo "clean - remove all build, test, coverage and Python artifacts"
@echo "install - install package and dependencies globally but from the local path"
@echo "build - install package and dependencies for local development"
@echo "install-docs - Install dependencies for building the documentation"
@echo "build-docs - Build self-contained docs that could be hosted somewhere"
@echo "docs - view docs in a browser"
@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-integration - run integration 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 .
build:
pip install -e .[dev]
build-for-test:
pip install -e .[test]
install-docs:
raco pkg install --deps search-auto --link $(PWD)/docs
build-docs:
scribble ++style $(DOCS-PATH)/oldabe.css --htmls --dest $(DOCS-PATH) --dest-name output $(DOCS-PATH)/oldabe.scrbl
docs: build-docs
open docs/output/index.html
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)
# NOTE: does not work! Only works when this identical
# command is run directly at the command line
test-integration:
pytest $(INTEGRATION_TESTS_PATH)
test-all: clean-test test-unit test-integration
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) -m pytest
coverage report -m
coverage html
open coverage_html_report/index.html
cover-coveralls: clean-test
coverage run --source $(PACKAGE-NAME) -m pytest
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-integration test-all test test-stop test-debug test-matrix test-tldr test-wiki debug coverage cover-coveralls sdist