Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
129 lines (108 loc) · 2.83 KB
/
Copy pathMakefile
File metadata and controls
129 lines (108 loc) · 2.83 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
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
SRC := src
TESTS := tests
SCRIPTS := scripts
ROOT_EC_FILES := $(wildcard *.yaml *.yml *.md) .github
PACKAGE := usbuntu
.PHONY: help
help:
@echo "Available targets:"
@grep -E "^([a-zA-Z_-]+):.*" $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":"}; {printf " \033[36m%s\n\033[0m", $$1}'
@echo ""
@echo "Hints:"
@echo " Use '-n' to do a dry run"
@echo " Use '-k' to ignore failed targets and keep going"
.PHONY: init
init:
@echo
pip install -e .
.PHONY: init-dev
init-dev:
@echo
pip install -e .[dev]
.PHONY: format
format: black isort
.PHONY: isort-check
isort-check:
@echo
@echo --- Isort check ---
isort --check --diff ${SRC} ${TESTS} ${SCRIPTS}
.PHONY: isort
isort:
@echo
@echo --- Isort auto format ---
isort ${SRC} ${TESTS} ${SCRIPTS}
.PHONY: black-check
black-check:
@echo
@echo --- Black check ---
black --check --diff ${SRC} ${TESTS} ${SCRIPTS}
.PHONY: black
black:
@echo
@echo --- Black auto format ---
black ${SRC} ${TESTS} ${SCRIPTS}
.PHONY: ec
ec:
@echo
@echo --- Editorconfig linting checks ---
ec ${SRC} ${TESTS} ${SCRIPTS} ${ROOT_EC_FILES}
.PHONY: docstyle
docstyle:
@echo
@echo --- Darglint docstring checks ---
darglint -v 2 ${SRC} ${TESTS} ${SCRIPTS}
.PHONY: lint
lint:
@echo
@echo --- Flake8 linting checks ---
flake8 ${SRC} ${TESTS} ${SCRIPTS}
.PHONY: mypy
mypy:
@echo
@echo --- Mypy type checks ---
mypy ${SRC} ${TESTS} ${SCRIPTS}
.PHONY: pytest
pytest:
@echo
@echo --- Pytest regression and unit tests ---
pytest --cov ${SRC}/${PACKAGE} ${TESTS}
.PHONY: bandit
bandit:
@echo
@echo --- Bandit security checks ---
bandit -c pyproject.toml -f custom -r ${SRC} ${TESTS} ${SCRIPTS}
.PHONY: man-check
man-check:
@echo
@echo --- Man page and packaged manual up to date ---
python scripts/build_man.py --check
# Build the man page and the packaged manual from docs/MANUAL.md
.PHONY: man
man:
@echo
@echo --- Build the man page ---
python scripts/build_man.py
.PHONY: build
build: clean
@echo
@echo --- Build package wheel ---
python -m build -o build/dist
.PHONY: clean
clean:
@echo
rm -rf build/
find ${SRC} ${TESTS} | grep -E "(\.egg-info|__pycache__|\.pyc|\.pyo$$)" | xargs rm -rf
# Run all checking tools
.PHONY: checks
checks: isort-check black-check ec docstyle lint mypy bandit man-check pytest ruru
# ruru reviews the change on this branch against main: a tamper audit of the tests, fail first for new tests, and
# mutants on the changed lines (https://github.com/jpsanders/ruru-review). On main with nothing changed it passes at
# once. `make checks RURU=:` skips it; RURU_BASE and RURU_MODE override the defaults.
RURU ?= uvx --python 3.14 --from git+https://github.com/jpsanders/ruru-review@main ruru
RURU_BASE ?= origin/main
RURU_MODE ?= gate
.PHONY: ruru
ruru:
@echo
@echo --- ruru: tamper audit, fail first and mutants on the change ---
$(RURU) check --base $(RURU_BASE) --mode $(RURU_MODE)