-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
101 lines (74 loc) · 2.64 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
.PHONY: help clean test coverage docs servedocs install
.DEFAULT_GOAL := help
define BROWSER_PYSCRIPT
import os, webbrowser, sys
from urllib.request import pathname2url
rel_current_path = sys.argv[1]
abs_current_path = os.path.abspath(rel_current_path)
uri = "file://" + pathname2url(abs_current_path)
webbrowser.open(uri)
endef
export BROWSER_PYSCRIPT
define PRINT_HELP_PYSCRIPT
import re, sys
regex_pattern = r'^([a-zA-Z_-]+):.*?## (.*)$$'
for line in sys.stdin:
match = re.match(regex_pattern, line)
if match:
target, help = match.groups()
print("%-20s %s" % (target, help))
endef
export PRINT_HELP_PYSCRIPT
BROWSER := python -c "$$BROWSER_PYSCRIPT"
COVERAGE_IGNORE_PATHS = "pybary/examples"
PACKAGE_NAME = "pybary"
PACKAGE_VERSION := "$$(poetry version -s)"
help:
@python -c "$$PRINT_HELP_PYSCRIPT" < $(MAKEFILE_LIST)
clean: clean-build clean-pyc clean-test clean-cache ## remove all build, test, coverage, Python artifacts and cache
clean-build: ## remove build artifacts
rm -fr build/ dist/ .eggs/
find . -name '*.egg-info' -o -name '*.egg' -exec rm -fr {} +
clean-pyc: ## remove Python file artifacts
find . -name '*.pyc' -o -name '*.pyo' -o -name '*~' -exec rm -rf {} +
clean-test: ## remove test and coverage artifacts
rm -fr .tox/ .coverage coverage.* htmlcov/ .pytest_cache
clean-cache: ## remove test and coverage artifacts
find . -name '*cache*' -exec rm -rf {} +
test: ## run tests quickly with the default Python
pytest
atest: install ## run tests on every Python version with tox
tox -q
test-watch: ## run tests on watchdog mode
ptw
lint: clean ## perform inplace lint fixes
pip3 install --upgrade ruff
ruff --fix .
pre-commit run --all-files
coverage: clean ## check code coverage quickly with the default Python
pytest --cov=pybary/
coverage run --source "$(PACKAGE_VERSION)" -m pytest
coverage report -m --omit="$(COVERAGE_IGNORE_PATHS)"
coverage html
$(BROWSER) htmlcov/index.html
install: clean ## install the package to the active Python's site-packages
poetry shell
poetry install
echo-version: ## Echo package version
printf "$(PACKAGE_VERSION)"
check-bump: # check if bump version is valid
@if [ "$(v)" != "patch" ] && [ "$(v)" != "minor" ] && [ "$(v)" != "major" ]; then \
echo "Invalid input for 'v': $(v). Please use 'patch', 'minor', or 'major'."; \
exit 1; \
fi; \
bump: ## bump version to user-provided {patch|minor|major} semantic
@$(MAKE) check-bump v=$(v)
poetry version $(v)
git add pyproject.toml
git commit -m "release/ tag v$$(poetry version -s)"
git tag "v$$(poetry version -s)"
git push
git push --tags
poetry version
publish: clean ## build source and publish package
poetry publish --build