-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
181 lines (147 loc) · 4.3 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
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
173
174
175
176
177
178
179
180
181
# use this Makefile as base in your project by running
# git remote add make https://github.com/spraakbanken/python-uv-make-conf
# git fetch make
# git merge --allow-unrelated-histories make/main
#
# To later update this makefile:
# git fetch make
# git merge make/main
#
.default: help
.PHONY: help
help:
@echo "usage:"
@echo "dev | install-dev"
@echo " setup development environment"
@echo "install"
@echo " setup production environment"
@echo ""
@echo "info"
@echo " print info about the system and project"
@echo ""
@echo "test"
@echo " run all tests"
@echo ""
@echo "test-w-coverage [cov=] [cov_report=]"
@echo " run all tests with coverage collection. (Default: cov_report='term-missing', cov='--cov=${PROJECT_SRC}')"
@echo ""
@echo "lint"
@echo " lint the code"
@echo ""
@echo "lint-fix"
@echo " lint the code and try to fix it"
@echo ""
@echo "type-check"
@echo " check types"
@echo ""
@echo "fmt"
@echo " format the code"
@echo ""
@echo "check-fmt"
@echo " check that the code is formatted"
@echo ""
@echo "bumpversion [part=]"
@echo " bumps the given part of the version of the project. (Default: part='patch')"
@echo ""
@echo "bumpversion-show"
@echo " shows the bump path that is possible"
@echo ""
@echo "publish [branch=]"
@echo " pushes the given branch including tags to origin, for CI to publish based on tags. (Default: branch='main')"
@echo " Typically used after 'make bumpversion'"
@echo ""
@echo "prepare-release"
@echo " run tasks to prepare a release"
@echo ""
PLATFORM := `uname -o`
REPO := sparv-sbx-word-prediction
PROJECT_SRC := word-prediction-kb-bert/src
ifeq (${VIRTUAL_ENV},)
VENV_NAME = .venv
INVENV = uv run
else
VENV_NAME = ${VIRTUAL_ENV}
INVENV =
endif
default_cov := "--cov=${PROJECT_SRC}/"
cov_report := "term-missing"
cov := ${default_cov}
all_tests := word-prediction-kb-bert/tests
tests := word-prediction-kb-bert/tests
info:
@echo "Platform: ${PLATFORM}"
@echo "INVENV: '${INVENV}'"
dev: install-dev
# setup development environment
install-dev:
uv sync --all-packages --dev
# setup production environment
install:
uv sync --all-packages --no-dev
lock: uv.lock
uv.lock: pyproject.toml
uv lock
.PHONY: test
test:
${INVENV} pytest -vv ${tests}
.PHONY: test-w-coverage
# run all tests with coverage collection
test-w-coverage:
${INVENV} pytest -vv ${cov} --cov-report=${cov_report} ${all_tests}
.PHONY: doc-tests
doc-tests:
${INVENV} pytest ${cov} --cov-report=${cov_report} --doctest-modules ${PROJECT_SRC}
.PHONY: type-check
# check types
type-check:
${INVENV} mypy ${PROJECT_SRC} ${tests}
.PHONY: lint
# lint the code
lint:
${INVENV} ruff check ${PROJECT_SRC} ${tests}
.PHONY: lint-fix
# lint the code (and fix if possible)
lint-fix:
${INVENV} ruff check --fix ${PROJECT_SRC} ${tests}
part := "patch"
bumpversion:
${INVENV} bump-my-version bump ${part}
bumpversion-show:
${INVENV} bump-my-version show-bump
# run formatter(s)
fmt:
${INVENV} ruff format ${PROJECT_SRC} ${tests}
.PHONY: check-fmt
# check formatting
check-fmt:
${INVENV} ruff format --check ${PROJECT_SRC} ${tests}
build:
uvx --from build pyproject-build --installer uv
branch := "main"
publish:
git push -u origin ${branch} --tags
.PHONY: prepare-release
prepare-release: update-changelog tests/requirements-testing.lock
# we use lock extension so that dependabot doesn't pick up changes in this file
tests/requirements-testing.lock: pyproject.toml
uv export --dev --format requirements-txt --no-hashes --no-emit-project --output-file $@
.PHONY: update-changelog
update-changelog: CHANGELOG.md
.PHONY: CHANGELOG.md
CHANGELOG.md:
git cliff --unreleased --prepend $@
# update snapshots for `syrupy`
.PHONY: snapshot-update
snapshot-update:
${INVENV} pytest --snapshot-update
### === project targets below this line ===
.PHONY: kb-bert-prepare-release
kb-bert-prepare-release: word-prediction-kb-bert/CHANGELOG.md
cd word-prediction-kb-bert; $(MAKE) tests/requirements-testing.lock
.PHONY: word-prediction-kb-bert/CHANGELOG.md
word-prediction-kb-bert/CHANGELOG.md:
git cliff --unreleased --include-path "word-prediction-kb-bert/**/*" --include-path "examples/word-prediction-kb-bert/**/*" --prepend $@
kb-bert-bumpversion:
cd word-prediction-kb-bert; $(MAKE) bumpversion $(MFLAGS)
kb-bert-bumpversion-show:
cd word-prediction-kb-bert; $(MAKE) bumpversion-show