-
Notifications
You must be signed in to change notification settings - Fork 0
/
Taskfile.yaml
307 lines (254 loc) · 7.19 KB
/
Taskfile.yaml
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
294
295
296
297
298
299
300
301
302
303
304
305
306
307
version: 3
silent: true
vars:
NENV: "node_modules"
VENV: ".venv"
SOURCE_FOLDERS: secret_transfer tests examples
TOML_FILES: pyproject.toml poetry.toml
PYTHON_FILES:
sh: find {{.SOURCE_FOLDERS}} -name '*.py' | tr '\n' ' '
PYTHON_VERSIONS: 3.9 3.10 3.11 3.12
tasks:
_prettier:
internal: true
cmds:
- "{{.NENV}}/.bin/prettier {{.COMMAND}}"
_pyright:
internal: true
cmds:
- "{{.NENV}}/.bin/pyright {{.COMMAND}}"
_with_nvm:
internal: true
cmds:
- "source ${HOME}/.nvm/nvm.sh && nvm install && {{.COMMAND}}"
_python:
internal: true
cmds:
- "poetry run python {{.COMMAND}}"
_toml_sort:
internal: true
cmds:
- "poetry run toml-sort {{.COMMAND}}"
_sort_all:
internal: true
cmds:
- cmd: "poetry run sort-all {{.COMMAND}} || [ {{.IGNORE_ERRORS}} = 'true' ]"
vars:
IGNORE_ERRORS: '{{.IGNORE_ERRORS | default "true"}}'
init:
desc: Initialize project environment
cmds:
- echo 'Installing node dependencies...'
- task: _with_nvm
vars: { COMMAND: "npm install" }
- echo ''
- echo 'Installing husky pre-commit...'
- task: _with_nvm
vars: { COMMAND: "npm run prepare" }
- echo ''
- echo 'Installing python dependencies...'
- poetry install
lint:
desc: Lint project
cmds:
- echo 'Running prettier checks...'
- task: _prettier
vars: { COMMAND: "--check ." }
- echo ''
- echo 'Running poetry checks...'
- poetry check --lock
- echo ''
- echo 'Running black checks...'
- task: _python
vars: { COMMAND: "-m black --check ." }
- echo 'Running toml-sort checks...'
- task: _toml_sort
vars: { COMMAND: "--check {{.TOML_FILES}}" }
- echo ''
- echo 'Running sort-all autofixes...'
- task: _sort_all
vars:
COMMAND: "{{.PYTHON_FILES}}"
IGNORE_ERRORS: "false"
- echo ''
- echo 'Running ruff checks...'
- task: _python
vars: { COMMAND: "-m ruff check {{.SOURCE_FOLDERS}}" }
- echo ''
- echo 'Running pyright checks...'
- task: _pyright
lint-fix:
desc: Lint fix project
cmds:
- echo 'Running prettier fixes...'
- task: _prettier
vars: { COMMAND: "--write ." }
- echo ''
- echo 'Running poetry checks...'
- poetry lock --no-update
- echo ''
- echo 'Running black autofixes...'
- task: _python
vars: { COMMAND: "-m black --safe ." }
- echo ''
- echo 'Running toml-sort autofixes...'
- task: _toml_sort
vars: { COMMAND: "--in-place {{.TOML_FILES}}" }
- echo ''
- echo 'Running sort-all autofixes...'
- task: _sort_all
vars: { COMMAND: "{{.PYTHON_FILES}}" }
- echo ''
- echo 'Running ruff fixes...'
- task: _python
vars: { COMMAND: "-m ruff check --fix {{.SOURCE_FOLDERS}}" }
- echo ''
- echo 'Running pyright checks...'
- task: _pyright
test:
desc: Test project
cmds:
- echo 'Running tests...'
- task: _python
vars: { COMMAND: "-m pytest tests" }
test-unit:
desc: Test unit tests
cmds:
- task: _python
vars: { COMMAND: "-m pytest tests/unit" }
test-integration:
desc: Test unit tests
cmds:
- task: _python
vars: { COMMAND: "-m pytest tests/integration" }
test-external:
desc: Test external tests
cmds:
- task: _python
vars: { COMMAND: "-m pytest tests/external" }
test-e2e:
desc: Test end-to-end tests
cmds:
- task: _python
vars: { COMMAND: "-m pytest -vvv tests/e2e" }
test-coverage:
desc: Collect test coverage data
cmds:
- task: _python
vars: { COMMAND: "-m coverage run -m pytest tests/unit tests/integration" }
test-coverage-report:
desc: Show coverage report in console
cmds:
- task: _python
vars: { COMMAND: "-m coverage report --skip-covered --show-missing" }
test-coverage-html:
desc: Prepare and show coverage report in browser
cmds:
- task: _python
vars: { COMMAND: "-m coverage html" }
- task: _python
vars: { COMMAND: "-m webbrowser -t {{.coverage_html}}" }
vars:
coverage_html:
sh: "[ $(uname) = 'Darwin' ] && echo 'file://$(pwd)/htmlcov/index.html' || echo 'htmlcov/index.html'"
check-version:
desc: Run lints and checks for version
requires:
vars:
- PYTHON_VERSION
cmds:
- echo "Setting pyenv version to {{.PYTHON_VERSION}}..."
- pyenv install --skip-existing {{.PYTHON_VERSION}}
- defer: pyenv local {{.original_python_version}}
- pyenv local {{.PYTHON_VERSION}}
- echo ''
- task: _clean_python
- task: init
- task: lint
- task: test
vars:
original_python_version:
sh: pyenv local
check-all-versions:
desc: Run lints and checks for all versions
requires:
vars:
- PYTHON_VERSIONS
cmds:
- for: { var: PYTHON_VERSIONS }
task: check-version
vars: { PYTHON_VERSION: "{{.ITEM}}" }
- task: _clean_python
- task: init
_clean_python:
internal: true
cmds:
- echo 'Cleaning python dependencies...'
- rm -rf {{.VENV}}
- echo ''
clean:
desc: Clean project environment
cmds:
- echo 'Cleaning node dependencies...'
- rm -rf {{.NENV}}
- echo ''
- task: _clean_python
- echo 'Cleaning dist packages...'
- rm -rf dist
- echo ''
- echo 'Cleaning pytest cache...'
- rm -rf .pytest_cache
- echo ''
- echo 'Cleaning ruff cache...'
- rm -rf .ruff_cache
- echo ''
- echo 'Cleaning coverage data...'
- rm -rf .coverage htmlcov
- echo ''
dependencies-update:
desc: Update dependencies
cmds:
- echo 'Updating node dependencies...'
- task: _with_nvm
vars: { COMMAND: "npm update" }
- echo 'Updating python dependencies...'
- poetry update
dependencies-check:
desc: Check dependencies
cmds:
- echo 'Checking node dependencies...'
- task: _with_nvm
vars: { COMMAND: "npm outdated" }
- task: _with_nvm
vars: { COMMAND: "npm audit" }
- echo 'Checking python dependencies...'
- poetry show --outdated
update-from-template:
desc: Update project from template
cmds:
- echo 'Updating project from template...'
- cookiecutter
--no-input
--overwrite-if-exists
--output-dir ../
{{.TEMPLATE_PATH}}
project_name='Secret Transfer'
project_slug='secret-transfer'
node_version='v21.5.0'
owner_name='Dmitry Ovsiannikov'
owner_github_login='ovsds'
scripts='false'
services=''
vars:
TEMPLATE_PATH: '{{.TEMPLATE_PATH | default "https://github.com/ovsds/template-repository"}}'
# CI tasks
ci-package-build:
desc: Build package (CI-specific)
cmds:
- echo 'Building package...'
- poetry build --no-interaction
ci-package-publish:
desc: Publish package (CI-specific)
cmds:
- echo 'Uploading package...'
- poetry publish --no-interaction