-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
104 lines (79 loc) · 2.67 KB
/
Makefile
File metadata and controls
104 lines (79 loc) · 2.67 KB
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
# vim: ft=make ts=4 sw=4 noet
# Copyright © 2025,2026 Ralph Seichter
define usage
Available 'make' targets are:
all …………………… Build everything.
build ……………… Build distribution artifacts.
clean ……………… Cleanup workspace.
cov …………………… Coverage analysis.
docs ………………… Generate documentation.
fla …………………… Run flake8 checks.
fmt …………………… Format source code.
help ………………… Display this text.
lint ………………… Lint YAML files.
mrproper ……… Thoroughly cleanup workspace.
pdocs ……………… Publish documentation.
pypi ………………… Upload artifacts to PyPI.
setver …………… Set version number.
shc …………………… Shell script care.
test ………………… Run unit tests.
endef
pyenv := PYTHONPATH=.:src
sedi := sed -E -i""
ver ?=
.PHONY: all build clean cov dbranch docs fla fmt help lint mrproper pdocs pypi setver shc stamp tagclean test
help:
$(info $(usage))
@exit 0
find_ := find . -regextype posix-extended
clean:
$(find_) '(' -name dist -o -regex '.*\.(bak|log|tmp)' ')' -print0 | xargs -0r rm -rv
mrproper: clean
$(find_) '(' -name 'tmp*' -o -regex '.*/(egg-info|__pycache__)' ')' -print0 | xargs -0r rm -rv
setver:
@if [[ -z "$(ver)" ]]; then echo Usage: make $@ ver="{semantic-version}"; exit 1; fi
$(sedi) 's/^(version =).*/\1 "$(ver)"/i' pyproject.toml src/stown/*.py
$(sedi) 's/^(:revnumber:).*/\1 $(ver)/' docs/stown.adoc
docs:
$(pyenv) python >usage.tmp -m stown -h
catto -r docs/usage.txt usage.tmp
make -C docs
pdocs: docs
scripts/publish.sh docs
lint:
yamllint .github/workflows/*.yml
fmt:
isort src tests
# pre-commit run -a
black -l 120 src tests
fla: fmt
flake8 . --config=.flake8
rev ?= $(shell git rev-parse --short HEAD)
stamp:
$(sedi) 's/^(COMMIT_SHA =).+/\1 "$(rev)"/' src/stown/*.py
build: stamp fmt mrproper
python -m build
all: fla build docs
cov: fmt lint
$(pyenv) coverage run -m unittest discover -s tests
coverage html
coverage report -m
test:
$(pyenv) python -m unittest discover -s tests -f
pypi:
twine check dist/*
twine upload dist/*
shc:
shcare scripts/*
dbranch:
@if [[ -z "$(b)" ]]; then echo Usage: make $@ b="{branch}"; exit 1; fi
git remote | while read -r r; do git push -d "$$r" "$$b"; done
git branch -d "$$b"
dtag:
@if [[ -z "$(t)" ]]; then echo Usage: make $@ t="{tag}"; exit 1; fi
git remote | while read -r r; do git push -d "$$r" "$$t"; done
git tag -d "$$t"
tagclean:
@if [[ -z "$(repo)" ]]; then echo Usage: make $@ repo="{git-remote-repository}"; exit 1; fi
git ls-remote $(repo) --tags '0.*' | awk -F /tags/ '{print $$2}' | \
xargs -r git push -d $(repo)