-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmakefile
More file actions
172 lines (132 loc) · 3.65 KB
/
makefile
File metadata and controls
172 lines (132 loc) · 3.65 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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
SHELL := /bin/bash
# parameters #
PYLINT_DIRS := disruption_py examples tests
DELETE_OBJS := __pycache__ .pytest_cache
# environment #
GITHUB_ACTIONS ?= 0
ifeq ($(GITHUB_ACTIONS), true)
CHECK_ARG := --check
FORMAT_ARG := --output-format=github
endif
# git #
.PHONY: status fetch
status: fetch
git status
fetch:
git fetch -p -a
# clean #
.PHONY: clean-list clean-delete
clean-list:
echo $(DELETE_OBJS) | xargs -n1 find -name
find -type d -empty
clean-delete:
echo $(DELETE_OBJS) | xargs -n1 find -name | xargs rm -rfv
find -type d -empty -delete
# poetry #
.PHONY: install install-all uninstall reinstall lock update show release
install:
poetry install --with dev
install-all:
poetry install --with dev,docs,lab
uninstall:
poetry env list | cut -d' ' -f1 | xargs poetry env remove
reinstall: uninstall install
lock:
poetry lock
uv lock || true
git status
update:
poetry update
uv lock --upgrade || true
git status
show:
poetry show --latest --why --top-level --with dev,lab,docs
release:
poetry version minor
make lock
git commit -am 'bump version to v$(shell poetry version -s)'
git show
# test #
.PHONY: quick test test-fast
quick:
poetry run pytest -v tests/test_quick.py
test:
poetry run pytest -v --durations=0 tests
test-fast:
GITHUB_ACTIONS=true poetry run pytest -v tests
# lint #
.PHONY: lint check isort black ruff pylint pylint-only pylint-todos shellcheck yamllint toml-sort
lint: isort black ruff pylint shellcheck yamllint toml-sort
check:
make lint GITHUB_ACTIONS=true
black:
@[ "$(GITHUB_ACTIONS)" != "true" ] || \
poetry run black --version
poetry run black $(CHECK_ARG) .
isort:
@[ "$(GITHUB_ACTIONS)" != "true" ] || \
poetry run isort --version
poetry run isort $(CHECK_ARG) --profile black .
pylint:
@[ "$(GITHUB_ACTIONS)" != "true" ] || \
poetry run pylint --version
find $(PYLINT_DIRS) -type f -name '*.py' -not -empty \
| xargs poetry run pylint -v --jobs 4 $(FORMAT_ARG)
pylint-only:
find $(PYLINT_DIRS) -type f -name '*.py' -not -empty \
| xargs poetry run pylint -v --disable=all --enable=$(CODE)
pylint-todos:
CODE=fixme make pylint-only
ruff:
@[ "$(GITHUB_ACTIONS)" != "true" ] || \
poetry run ruff --version
find $(PYLINT_DIRS) -type f -name '*.py' -not -empty \
| xargs poetry run ruff check $(FORMAT_ARG)
shellcheck:
@[ "$(GITHUB_ACTIONS)" != "true" ] || \
shellcheck --version
@KO=0; \
while IFS= read -r -d '' F; \
do \
grep -q '^#!/bin/bash' "$$F" || continue; \
echo "--> $$F"; \
shellcheck "$$F"; \
RC=$$?; \
echo "--> $$F = $$RC"; \
[ "$$RC" -eq 0 ] || KO=1; \
done < <(find -type f -not -path '*/.git/*' -not -path '*/.venv/*' -print0); \
exit "$$KO"
yamllint:
@[ "$(GITHUB_ACTIONS)" != "true" ] || \
poetry run yamllint --version
@KO=0; \
while IFS= read -r -d '' F; \
do \
echo "--> $$F"; \
poetry run yamllint "$$F"; \
RC=$$?; \
echo "--> $$F = $$RC"; \
[ "$$RC" -eq 0 ] || KO=1; \
done < <(find -type f -iname '*.y*ml' -not -empty -not -path '*/.venv/*' -print0); \
exit "$$KO"
toml-sort:
@[ "$(GITHUB_ACTIONS)" != "true" ] || \
poetry run toml-sort --version
@KO=0; \
while IFS= read -r -d '' F; \
do \
echo "--> $$F"; \
poetry run toml-sort $(CHECK_ARG) "$$F"; \
RC=$$?; \
echo "--> $$F = $$RC"; \
[ "$$RC" -eq 0 ] || KO=1; \
done < <(find -maxdepth 1 -type f -iname '*.toml' -not -empty -not -path '*/.venv/*' -print0); \
while IFS= read -r -d '' F; \
do \
echo "--> $$F"; \
poetry run toml-sort $(CHECK_ARG) --all "$$F"; \
RC=$$?; \
echo "--> $$F = $$RC"; \
[ "$$RC" -eq 0 ] || KO=1; \
done < <(find -mindepth 2 -type f -iname '*.toml' -not -empty -not -path '*/.venv/*' -print0); \
exit "$$KO"