Repository navigation
Expand file tree
/
Copy pathTaskfile.yml
More file actions
293 lines (257 loc) · 8.23 KB
/
Copy pathTaskfile.yml
File metadata and controls
293 lines (257 loc) · 8.23 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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
# SPDX-FileCopyrightText: 2024 Roy Wright
#
# SPDX-License-Identifier: MIT
version: "3"
includes:
docs:
taskfile: ./taskfiles/Taskfile-docs.yml
dir: .
env:
taskfile: ./taskfiles/Taskfile-env.yml
dir: .
format:
taskfile: ./taskfiles/Taskfile-format.yml
dir: .
git:
taskfile: ./taskfiles/Taskfile-git.yml
dir: .
lint:
taskfile: ./taskfiles/Taskfile-lint.yml
dir: .
metrics:
taskfile: ./taskfiles/Taskfile-metrics.yml
dir: .
release:
taskfile: ./taskfiles/Taskfile-release.yml
dir: .
test:
taskfile: ./taskfiles/Taskfile-test.yml
dir: .
version:
taskfile: ./taskfiles/Taskfile-version.yml
dir: .
vars:
APP_NAME:
sh: python taskfiles/helpers/task-helper.py app-name pyproject.toml
MODULE: version_bumper
SRC: src/
TESTS: tests/
POSSIBLE_TEST_CORES: tests/
TESTS_CORE:
sh:
python taskfiles/helpers/task-helper.py tests-core
"{{.POSSIBLE_TEST_CORES}}"
TEST_TIMEOUT: 30
PARALLEL_JOBS: 1
SCRIPTS: scripts/
PYTHON_VERSIONS:
sh: python taskfiles/helpers/task-helper.py python-versions .python-versions
PYTHON_VERSION:
sh: python taskfiles/helpers/task-helper.py python-version .python-version
EMOJI_REPLACEMENTS_MAP:
"✅:PASS ❌:FAIL ⚠️:WARNING 🔍:SEARCH 📦:PACKAGE 🐧:LINUX 🚀:DEPLOY
🎯:TARGET 🏆:SUCCESS 🎉:COMPLETE 📊:REPORT 🧪:TEST 🔴:HIGH 🟡:MEDIUM 🟢:LOW
📚:DOCS 🌍:SERVER 🏗️:BUILD 📈:BUMP 📝:COMMIT 🐍:PYTHON 📋:LIST ✓:DONE
📁:FOLDER 🌐:NETWORK 🎭:MOCK ⚡:EXECUTE 📤:STDOUT 📥:STDERR 💥:EXCEPTION
🔧:VERSION 📄:FILE 🌳:TREE 🏁:COMPLETE 🔒:LOCK 🔓:UNLOCK 🐛:BUG 🛠️:TOOLS
🚨:0"
tasks:
default:
desc: Show available tasks
cmds:
- echo "Available tasks:"
- task --list --sort none
silent: true
check:
desc: Run all code quality checks
summary:
Runs formatting, linting, complexity checks, pyproject consistency check,
and all tests
deps:
- env:clean:bytecodes
cmds:
- task: lint:fix:emoji
- task: format
- task: lint
- task: metrics:complexity
- task: check-pyproject
- task: test:parallel
build:
desc: Build distribution packages
summary: Creates wheel and source distribution packages in dist/
deps:
- env:clean
cmds:
- echo "Building distribution packages..."
- uv build {{.CLI_ARGS}}
- echo "Build complete! Packages created in dist/"
- cmd: python taskfiles/helpers/task-helper.py ls-al dist/
silent: true
silent: true
make:
desc: Complete build pipeline - run all checks, build, and show version
summary:
Full pipeline - quality checks, compliance, tests with coverage, metrics,
docs, build packages
cmds:
- echo "Starting build pipeline..."
- task: env:check
- task: check
- task: execute-pre-commit
- task: build
- task: env:sync
- task: check-licenses
- task: test:coverage
- task: metrics:summary
- task: docs:build
- task: version:current
- echo "Build pipeline completed successfully!"
silent: true
run:
desc: Run the application module
summary: Executes `python -m version_bumper` with optional CLI arguments
cmds:
- uv run python -m {{.MODULE}} {{.CLI_ARGS}}
main:
desc: Run the application's installed console script
summary:
Executes the version_bumper script in the virtual environment's bin
directory
cmds:
- uv run {{.APP_NAME}} {{.CLI_ARGS}}
deploy:local:
desc: Install the built package locally using pipxu (or pipx fallback)
summary: Builds and installs the package locally for testing
platforms: [linux, darwin]
aliases:
- deploy
deps:
- build
cmds:
- echo "Installing locally..."
- |
if command -v pipxu >/dev/null 2>&1; then
pipxu install --force dist/*.whl
else
pipx install --force dist/*.whl
fi
- echo "Successfully deployed {{.APP_NAME}} locally!"
silent: true
init:
desc: Initialize new project (only run once upon first creation of project).
cmds:
- git init .
- git add docs LICENSES scripts src tests .gitignore
.pre-commit-config.yaml .pymarkdown.json .python-version
.python-versions .shellcheckrc CHANGELOG.md DEV-README.md zensical.toml
pyproject.toml README.md Taskfile.yml taskfiles/ tox.ini
# Realizing the template can mess up formatting of the files
- pre-commit run blacken-docs --all-files >/dev/null || true
- pre-commit run trailing-whitespace --all-files >/dev/null || true
- pre-commit run prettier --all-files >/dev/null || true
- pre-commit run ruff --all-files >/dev/null || true
- git commit -m "Initial Framework."
- pre-commit install
- task: env:install
- task: reuse-enable
status:
# do not run the init task if there is a .git/ directory
- test -d .git
clean:
desc: Remove virtual environments and generated files.
cmds:
- pre-commit clean
- task: env:clean
- rm -rf .tox
- rm -rf .nox
- rm -rf .coverage
- rm -rf coverage.xml
- rm -rf metrics
- rm -rf site
- rm -rf src/*.egg-info
- rm -rf test-install
- rm -rf .*_cache
- rm -f requirements.txt
- rm -f requirements.txt.license
- rm -f requirements/requirements*.txt
- rm -f requirements/requirements*.txt.license
- rm -f reuse.spdx
- rm -f poetry.lock
- rm -f uv.lock
silent: true
# === Project-specific checks ===
check-pyproject:
desc:
Check the consistency between project and tool.poetry in the
pyproject.toml file.
cmds:
- uv run python3 -m check_pyproject --loglevel INFO
check-licenses:
desc: Check that all dependency licenses are acceptable for this project.
cmds:
- task: check-reuse
check-reuse:
desc: Check if project is REUSE compliant.
vars:
REUSE_ENABLED:
sh: uv run toml get --toml-path pyproject.toml 'tool.taskfile.reuse'
cmds:
# add any missing copyrights
- git diff --name-only --cached | xargs -I {} uv run reuse annotate -c
"$(git config --get user.name)" "{}"
# create software bill of materials
- uv run reuse spdx -o reuse.spdx
status:
- test "{{.REUSE_ENABLED}}" = "disabled"
reuse-enable:
desc: Enable using SPDX reuse for enforcing copyright and license.
cmds:
- uv run toml set --toml-path pyproject.toml tool.taskfile.reuse "enabled"
- sed --in-place=.bak '/export SKIP=.*$/d' .git/hooks/pre-commit
reuse-disable:
desc: Disable using SPDX reuse for enforcing copyright and license.
cmds:
- uv run toml set --toml-path pyproject.toml tool.taskfile.reuse
"disabled"
- sed --in-place=.bak '/export SKIP=.*$/d' .git/hooks/pre-commit
- sed --in-place=.bak "/# start templated/a\export SKIP='reuse'"
.git/hooks/pre-commit
pre-commit:
desc: Must pass before allowing version control commit.
# called from the "pre-commit" hook and the "task make"
cmds:
- task: check-pyproject
execute-pre-commit:
# [private] internal task for running the pre-commit utility directly and conditionally skipping reuse hook
vars:
REUSE_ENABLED:
sh: uv run toml get --toml-path pyproject.toml 'tool.taskfile.reuse'
SKIP:
sh:
if test "{{.REUSE_ENABLED}}" = "disabled"; then echo "reuse"; else
echo ""; fi
cmds:
- SKIP="{{.SKIP}}" pre-commit run --all-files || true
# === Task discovery ===
help:
desc: Show available tasks from a namespace (defaults to main)
cmd: taskfile-help namespace {{.CLI_ARGS}}
silent: true
help:*:
desc:
Show available tasks for "all" or the given namespace or for "?" list
available namespaces
vars:
NAMESPACE: "{{index .MATCH 0}}"
cmd: taskfile-help namespace {{.NAMESPACE}}
silent: true
search:
desc: Search for tasks
cmd: taskfile-help search {{.CLI_ARGS}}
silent: true
search:*:
desc: Search for tasks
vars:
PATTERN: "{{index .MATCH 0}}"
cmd: taskfile-help search {{.PATTERN}}
silent: true