-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
194 lines (156 loc) · 4.26 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
182
183
184
185
186
187
188
189
190
191
192
193
194
# 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 := "sblex-server"
PROJECT_SRC := "src/sblex"
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 := tests
tests := tests
info:
@echo "Platform: ${PLATFORM}"
@echo "INVENV: '${INVENV}'"
dev: install-dev
# setup development environment
install-dev:
uv sync --dev
# setup production environment
install:
uv sync --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 pip compile $< --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 ===
serve-dev:
${INVENV} watchfiles "uvicorn --port 8000 sblex.saldo_ws.main:app" src
quick-dev:
${INVENV} watchfiles "python examples/quick_dev.py" examples/quick_dev.py templates
serve-fm-server:
${INVENV} watchfiles "uvicorn --port 8765 sblex.fm_server.main:app" src/sblex/fm_server
.PHONY: lint-deptrac
lint-deptrac:
${INVENV} deptracpy
.PHONY: lint-deptry
lint-deptry:
${INVENV} deptry .
.PHONY: lint-dependencies
lint-dependencies: lint-deptry lint-deptrac
watch-lint-deptrac:
${INVENV} watchfiles "deptracpy" deptracpy.yaml src
run-traefik:
@echo "Remember to set SALDO_WS__APP__ROOT_PATH=/ws/saldo-ws"
traefik --configFile=contrib/traefik/traefik.toml