|
1 | 1 | .PHONY: \ |
2 | | - setup setup-venv setup-requirements setup-pre-commit \ |
3 | | - clean full-clean upgrade \ |
4 | | - lint audit \ |
5 | | - all-tests unittests doctests coverage \ |
| 2 | + clean full-clean \ |
| 3 | + lint check fmt \ |
| 4 | + tests doctests coverage \ |
| 5 | + build publish \ |
6 | 6 | change clog \ |
7 | | - release build publish |
8 | | - |
9 | | - |
10 | | -PYTHON_VERSION := $(shell cat runtime.txt) |
11 | | - |
12 | | -RELEASE_LEVELS := patch minor major |
13 | | - |
14 | | - |
15 | | -# SETUP |
16 | | - |
17 | | -setup: setup-venv setup-requirements setup-pre-commit |
18 | | - |
19 | | -setup-venv: version ?= $(cat runtime.txt) |
20 | | -setup-venv: |
21 | | - python$(PYTHON_VERSION) -m venv --clear --upgrade-deps .venv |
22 | | - |
23 | | -export PATH := $(shell pwd)/.venv/bin:$(PATH) |
24 | | - |
25 | | -setup-requirements: req ?= requirements.txt |
26 | | -setup-requirements: |
27 | | - pip install --isolated --no-input --quiet -r '$(req)' |
28 | | - |
29 | | -setup-pre-commit: |
30 | | - pre-commit install --install-hooks |
| 7 | + release |
31 | 8 |
|
32 | 9 | clean: |
33 | 10 | rm -rf MANIFEST build dist |
34 | 11 |
|
35 | 12 | full-clean: clean |
36 | | - rm -rf .venv .tox .nox .pytest_cache .mypy_cache .coverage* |
37 | | - |
38 | | -upgrade: |
39 | | - pip-compile \ |
40 | | - --upgrade \ |
41 | | - --no-header \ |
42 | | - --strip-extras \ |
43 | | - --annotation-style line \ |
44 | | - --output-file requirements/constraints.txt \ |
45 | | - setup.cfg \ |
46 | | - requirements/*.in |
47 | | - |
| 13 | + rm -rf .venv .tox .nox .pytest_cache .mypy_cache .ruff_cache .coverage* |
48 | 14 |
|
49 | 15 | # LINTING |
50 | 16 |
|
51 | 17 | lint: |
52 | | - pre-commit run --all-files |
| 18 | + hatch run lint:pc |
53 | 19 |
|
54 | | -audit: |
55 | | - safety check --file requirements/constraints.txt |
| 20 | +check: |
| 21 | + hatch run lint:check |
56 | 22 |
|
| 23 | +fix: |
| 24 | + hatch run lint:fix |
| 25 | + hatch run lint:upgrade |
57 | 26 |
|
58 | 27 | # TESTS |
59 | 28 |
|
60 | | -all-tests: |
61 | | - tox $(args) |
| 29 | +test: |
| 30 | + hatch test |
| 31 | + |
| 32 | +coverage: |
| 33 | + hatch test --cover |
62 | 34 |
|
63 | | -doctests: |
64 | | - xdoctest --quiet wtforms_html5 |
| 35 | +version-test: |
| 36 | + hatch test --all --cover |
65 | 37 |
|
66 | | -unittests: |
67 | | - python -m unittest discover |
| 38 | +doctest: |
| 39 | + hatch test -- --xdoctest src/ |
68 | 40 |
|
69 | | -coverage: |
70 | | - coverage erase |
71 | | - coverage run -m unittest discover $(args) |
72 | | - coverage report |
| 41 | +# PACKAGING |
| 42 | + |
| 43 | +build: clean |
| 44 | + hatch build --clean --target wheel |
73 | 45 |
|
| 46 | +publish: build |
| 47 | + hatch publish |
74 | 48 |
|
75 | 49 | # CHANGELOG |
76 | 50 |
|
| 51 | +CHANGE_TYPES := fix rm feat change |
| 52 | + |
77 | 53 | change: issue ?= _$(shell < /dev/urandom tr -dc A-Za-z0-9 | head -c9) |
78 | | -change: type ?= feature |
79 | 54 | change: change_file := changes/$(issue).$(type).md |
80 | 55 | change: |
| 56 | +ifneq ($(filter $(type),$(CHANGE_TYPES)),) |
81 | 57 | touch '$(change_file)' |
82 | 58 | $(EDITOR) '$(change_file)' |
| 59 | +else |
| 60 | + @echo "Given change type '$(type)' is not a suported value: $(CHANGE_TYPES)" |
| 61 | +endif |
83 | 62 |
|
84 | 63 | clog: |
85 | | - towncrier --draft --version=Unreleased |
| 64 | + hatch run project:towncrier build --draft --version Unreleased |
86 | 65 |
|
87 | 66 |
|
88 | | -# PACKAGING |
| 67 | +# RELEASE |
| 68 | + |
| 69 | +RELEASE_LEVELS := patch minor major |
89 | 70 |
|
90 | 71 | release: |
91 | 72 | ifneq ($(filter $(part),$(RELEASE_LEVELS)),) |
92 | | - $(eval version = $(shell \ |
93 | | - .venv/bin/bumpversion --dry-run --allow-dirty --list $(part) \ |
94 | | - | grep '^current_version=' \ |
95 | | - | cut -d= -f2 \ |
96 | | - )) |
97 | | - $(eval new = $(shell \ |
98 | | - .venv/bin/bumpversion --dry-run --allow-dirty --list $(part) \ |
99 | | - | grep '^new_version=' \ |
100 | | - | cut -d= -f2 \ |
| 73 | + # check git status |
| 74 | + @if ! git diff-index --quiet HEAD; then \ |
| 75 | + echo "ERROR: git unclean!"; \ |
| 76 | + exit 1; \ |
| 77 | + fi |
| 78 | + # get next version (for changelog) |
| 79 | + $(eval new_version := $(shell \ |
| 80 | + hatch run project:bumpver update --dry --$(part) 2>&1 \ |
| 81 | + | grep 'New Version:' \ |
| 82 | + | awk '{print $$NF}' \ |
101 | 83 | )) |
102 | | - @echo "bump $(part) -> $(version) => $(new)" |
103 | | - towncrier --yes --version '$(new)' |
| 84 | + @echo "bump -> '$(new_version)'" |
| 85 | + # write changelog |
| 86 | + hatch run project:towncrier --yes --version '$(new_version)' |
104 | 87 | if ! git diff --staged --exit-code; then \ |
105 | | - git commit -m ':memo: add CHANGELOG for $(new)' --no-verify; \ |
| 88 | + git commit -m ':memo: add CHANGELOG for `$(new_version)`' --no-verify; \ |
106 | 89 | fi |
107 | | - bumpversion '$(part)' --commit-args='--no-verify' |
| 90 | + # bump version |
| 91 | + hatch run project:bumpver update '--$(part)' |
108 | 92 | else |
109 | 93 | @echo "Given part '$(part)' is not a suported value: $(RELEASE_LEVELS)" |
110 | 94 | endif |
111 | | - |
112 | | -build: clean |
113 | | - python -m build |
114 | | - |
115 | | -publish: build |
116 | | - python -m twine check dist/* |
117 | | - python -m twine upload dist/* |
0 commit comments