-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
160 lines (132 loc) · 3.51 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
# use this Makefile as base in your project by running
# git remote add make https://github.com/spraakbanken/python-pdm-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 := "resource-fula-ordboken"
PROJECT_SRC := "src/resource_fula_ordboken"
ifeq (${VIRTUAL_ENV},)
VENV_NAME = .venv
INVENV = pdm 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:
pdm install --dev
# setup production environment
install:
pdm sync --prod
.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:
pdm build
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
pdm export --dev --format requirements --output $@
.PHONY: update-changelog
update-changelog: CHANGELOG.md
CHANGELOG.md:
git cliff --unreleased --prepend $@
# update snapshots for `syrupy`
.PHONY: snapshot-update
snapshot-update:
${INVENV} pytest --snapshot-update