-
Notifications
You must be signed in to change notification settings - Fork 0
/
Taskfile.yml
261 lines (241 loc) · 5.4 KB
/
Taskfile.yml
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
---
version: '3'
vars:
NAME: laflem
VENV_DIR: venv
CHECKS_DIR: .checks
PYTHON_BIN: "{{ .VENV_DIR }}/bin/python3"
PIP_BIN: "{{ .VENV_DIR }}/bin/pip3"
PYTEST_BIN: "{{ .VENV_DIR }}/bin/pytest"
PYLINT_BIN: "{{ .VENV_DIR }}/bin/pylint"
BLACK_BIN: "{{ .VENV_DIR }}/bin/black"
TWINE_BIN: "{{ .VENV_DIR }}/bin/twine"
FLEM_BIN: "{{ .VENV_DIR }}/bin/laflem"
COVERAGE_BIN: "{{ .VENV_DIR }}/bin/coverage"
tasks:
venv:
run: once
internal: true
desc: Setup the python virtual environment
cmds:
- >
python3
-m venv
{{ .VENV_DIR }}
status:
- test -f "{{ .VENV_DIR }}/bin/activate"
uninstall-package:
run: once
internal: true
desc: Uninstall a package
cmds:
- >
{{ .PIP_BIN }}
uninstall
--yes
{{ .PACKAGE }}
status:
- >
! {{ .PIP_BIN }}
list
| grep
{{ .PACKAGE }}
install-dependencies:
deps: [ venv ]
internal: false
desc: Install a package
cmds:
- >
{{ .PIP_BIN }}
install
{{ .PACKAGE }}
install:
run: once
deps: [ venv ]
desc: Install application dependencies
cmds:
- task: install-dependencies
vars:
PACKAGE: '.'
- task: uninstall-package
vars:
PACKAGE: "{{ .NAME }}"
sources:
- setup.py
- lib/**/*
generates:
- "{{ .VENV_DIR }}/*"
install-dev:
run: once
deps: [ venv ]
desc: Install application dependencies for development
cmds:
- task: install-dependencies
vars:
PACKAGE: '.[dev]'
sources:
- setup.py
generates:
- "{{ .VENV_DIR }}/*"
build:
deps: [ venv, install-dev ]
desc: Build and compile the application
cmds:
- rm -rf dist
- >
{{ .PYTHON_BIN }}
-m build
sources:
- setup.py
- lib/**/*
- configs/**/*
generates:
- dist/**/*
check_folder:
internal: true
run: once
desc: Create the check results directory
cmds:
- >
mkdir
-p
"{{ .CHECKS_DIR }}"
status:
- test -d "{{ .CHECKS_DIR }}"
lint:
deps: [ venv, install-dev, check_folder ]
desc: Run pylint on the application
cmds:
- >
{{ .BLACK_BIN }}
--check
lib setup.py
|
tee
"{{ .CHECKS_DIR }}/black.result.txt"
- >
{{ .PYLINT_BIN }}
lib setup.py
|
tee
"{{ .CHECKS_DIR }}/pylint.result.txt"
sources:
- lib/**/*
- tests/**/*
- setup.py
generates:
- "{{ .CHECKS_DIR }}/black.result.txt"
- "{{ .CHECKS_DIR }}/pylint.result.txt"
test:
deps: [ venv, install-dev, build, check_folder ]
desc: Run tests on the application
cmds:
- task: install-dependencies
vars:
PACKAGE: dist/{{ .NAME }}-*.tar.gz
- >
{{ .PYTHON_BIN }}
-m pytest
-v
-n 4
--cov={{ .NAME }}
--junitxml="{{ .CHECKS_DIR }}/result.xml"
--html="{{ .CHECKS_DIR }}/report.html"
"tests/{{ .NAME }}"
- >
{{ .COVERAGE_BIN }}
html
-d "{{ .CHECKS_DIR }}/htmlcov"
- >
{{ .COVERAGE_BIN }}
xml
-o "{{ .CHECKS_DIR }}/coverage.xml"
- task: uninstall-package
vars:
PACKAGE: "{{ .NAME }}"
#- open "{{ .CHECKS_DIR }}/report.html"
#- open "{{ .CHECKS_DIR }}/htmlcov/index.html"
sources:
- lib/**/*
- tests/**/*
- setup.py
generates:
- "{{ .CHECKS_DIR }}/result.xml"
- "{{ .CHECKS_DIR }}/coverate.xml"
package_check:
internal: true
deps: [ venv, install-dev, build ]
desc: Run package checks before publishing
cmds:
- >
{{ .TWINE_BIN }}
check
dist/*
check:
deps: [ lint, package_check ]
desc: Run all checks before publishing
publish:
internal: true
deps: [ venv, install-dev, build, check ]
desc: Publish the package to the repository
cmds:
- >
{{ .TWINE_BIN }}
upload
--config-file .pypirc
-r "{{ .REPOSITORY }}"
dist/*
publish-dev:
desc: Publish the package to the test repository
cmds:
- task: publish
vars:
REPOSITORY: testpypi
publish-prod:
desc: Publish the package to the production repository
cmds:
- task: publish
vars:
REPOSITORY: pypi
clean:
desc: Clean all the crappy files
cmds:
- >
rm
-rf
build
dist
"{{ .VENV_DIR }}"
.task
lib/*.egg-info
"{{ .CHECKS_DIR }}"
.pytest_cache
.coverage
run-dev:
deps: [ install ]
desc: Run the application in development mode
env:
PYTHONPATH: lib
cmds:
- >
{{ .PYTHON_BIN }}
-c "import sys; sys.argv[0] = '{{ .NAME }}'; from {{ .NAME }} import main; main()"
{{ .CLI_ARGS }}
run:
deps: [ build ]
desc: Run the application in production mode
cmds:
- task: uninstall-package
vars:
PACKAGE: "{{ .NAME }}"
- task: install-dependencies
vars:
PACKAGE: dist/{{ .NAME }}-*.tar.gz
- >
{{ .FLEM_BIN }} {{ .CLI_ARGS }}
- task: uninstall-package
vars:
PACKAGE: "{{ .NAME }}"
ci:
deps: [ check, test ]
desc: Run all checks and tests in CI mode