-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Makefile
116 lines (96 loc) · 3.54 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
.PHONY: environment
environment: ## create environment
pyenv install -s 3.9.19
pyenv virtualenv 3.9.19 injectable
pyenv local injectable
.PHONY: requirements
requirements: ## install all requirements
pip install ".[docs,test,build]"
.PHONY: flake-check
flake-check: ## check PEP-8 and other standards with flake8
@echo ""
@echo "\033[33mFlake 8 Standards\033[0m"
@echo "\033[33m=================\033[0m"
@echo ""
@python -m flake8 && echo "\n\n\033[32mSuccess\033[0m\n" || (echo \
"\n\n\033[31mFailure\033[0m\n\n\033[34mManually fix the offending \
issues\033[0m\n" && exit 1)
.PHONY: black-check
black-check: ## check Black code style
@echo ""
@echo "\033[33mBlack Code Style\033[0m"
@echo "\033[33m================\033[0m"
@echo ""
@python -m black --target-version=py39 --check --exclude="build/|buck-out/|dist/|_build/\
|pip/|env/|\.pip/|\.git/|\.hg/|\.mypy_cache/|\.tox/|\.venv/" . \
&& echo "\n\n\033[32mSuccess\033[0m\n" || (echo "\n\n\033[31mFailure\033[0m\n\n\
\033[34mRun \"\e[4mmake black\e[24m\" to apply style formatting to your code\
\033[0m\n" && exit 1)
.PHONY: black
black: ## apply the Black code style to code
black --target-version=py39 --exclude="build/|buck-out/|dist/|_build/|pip/|env/|\.pip/|\.git/\
|\.hg/|\.mypy_cache/|\.tox/|\.venv/" .
.PHONY: tests
tests: ## run tests with pytest
pip install -e .[test]
python -m pytest --cov=injectable --cov-report term --cov-report html:htmlcov \
--cov-report xml:coverage.xml tests
.PHONY: unit-tests
unit-tests: ## run unit tests with pytest
pip install -e .[test]
python -m pytest --cov=injectable --cov-report term --cov-report \
html:tests/unit/htmlcov --cov-report xml:tests/unit/coverage.xml tests/unit
.PHONY: fixes-tests
fixes-tests: ## run fixes tests with pytest
pip install -e .[test]
python -m pytest --cov=injectable --cov-report term --cov-report \
html:tests/fixes/htmlcov --cov-report xml:tests/fixes/coverage.xml tests/fixes
.PHONY: examples-tests
examples-tests: ## run examples tests with pytest
pip install -e .[test]
python -m pytest --cov=injectable --cov-report term --cov-report \
html:tests/examples/htmlcov --cov-report xml:tests/examples/coverage.xml \
tests/examples
.PHONY: checks
checks: black-check flake-check ## perform code standards and style checks
.PHONY: package
package:
pip install -e .[build]
flit build
.PHONY: docs
docs:
make html -B
cp -a build/html/. docs
CURRENT_VERSION = 4.0.1
.PHONY: bump-patch-version
bump-patch-version:
bump2version --allow-dirty --current-version $(CURRENT_VERSION) patch
.PHONY: bump-minor-version
bump-minor-version:
bump2version --allow-dirty --current-version $(CURRENT_VERSION) minor
.PHONY: bump-major-version
bump-major-version:
bump2version --allow-dirty --current-version $(CURRENT_VERSION) major
SPHINXOPTS =
SPHINXBUILD = sphinx-build
SOURCEDIR = docs
BUILDDIR = build
.PHONY: Makefile
# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
.PHONY: clean
clean: ## delete all compiled python files
find . -name "*.py[co]" -delete
find . -name "*~" -delete
find . -name "__pycache__" -delete
.DEFAULT_GOAL := help
# Inspired by <http://marmelab.com/blog/2016/02/29/auto-documented-makefile.html>
.PHONY: help
help:
@echo "\n$$(tput bold)Available rules:$$(tput sgr0)"
@echo
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort \
| awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
@echo