-
Notifications
You must be signed in to change notification settings - Fork 0
/
Taskfile.yaml
193 lines (167 loc) · 4.94 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
# https://taskfile.dev
---
version: '3'
dotenv: ['.copier-answers.env', '.env']
.preparation: &preparation
deps:
- poetry:install
- check:prepare
vars:
PACKAGE: cmem_plugin_$project_slug
DIST_DIR: dist
includes:
custom:
taskfile: ./TaskfileCustom.yaml
optional: true
tasks:
default:
summary: |
Just a list of documented tasks
silent: true
cmds:
- task --list
# {{{ preparation tasks
check:prepare:
internal: true
summary: |
prepare check targets by creating appropriate directory
run: once
cmds:
- mkdir -p {{.DIST_DIR}}/coverage
poetry:check:
internal: true
platforms: [darwin, linux]
summary: |
Check poetry versioning plugin. Currently not under Windows
run: once
preconditions:
- sh: '[[ {{.PDV_VERSION}} > {{.PDV_VERSION_MIN}} ]]'
msg: >
This project needs the poetry-dynamic-versioning
plugin > v{{.PDV_VERSION_MIN}}.
You can install it with the following command:
poetry self add "poetry-dynamic-versioning[plugin]"
vars:
PDV_VERSION_MIN: 0.20
PDV_VERSION:
sh: >
poetry self show --addons poetry-dynamic-versioning --tree
| head -1 | cut -d " " -f 2 | cut -d "." -f 1-2
poetry:install:
internal: true
desc: Install dependencies managed by Poetry
run: once
deps:
- poetry:check
cmds:
- poetry install
python:format:
desc: Format Python files
<<: *preparation
cmds:
- poetry run black .
clean:
desc: Removes dist, *.pyc and some caches
cmds:
- rm -rf {{.DIST_DIR}} .mypy_cache .pytest_cache
- find . -name "*.pyc" -print0 | xargs -0 rm || echo ""
# }}}
# {{{ check tasks
check:
desc: Run whole test suite incl. unit and integration tests
deps:
- check:linters
- check:pytest
check:linters:
desc: Run all linter and static code analysis tests
deps:
- check:bandit
- check:flake8
- check:mypy
- check:pylint
- check:safety
check:pytest:
desc: Run unit and integration tests
platforms: [darwin, linux, windows]
<<: *preparation
cmds:
# --memray is not used on windows
- platforms: [windows]
cmd: >
poetry run pytest --junitxml={{.JUNIT_FILE}}
--cov-report term --cov-report xml:{{.COVERAGE_FILE}}
--cov-report html:{{.COVERAGE_DIR}} --cov={{.PACKAGE}}
- platforms: [darwin, linux]
cmd: >
poetry run pytest --memray --junitxml={{.JUNIT_FILE}}
--cov-report term --cov-report xml:{{.COVERAGE_FILE}}
--cov-report html:{{.COVERAGE_DIR}} --cov={{.PACKAGE}}
- cmd: >
poetry run genbadge coverage -l
-i {{.COVERAGE_FILE}} -o {{.BADGE_COVERAGE}}
- cmd: >
poetry run genbadge tests -l
-i {{.JUNIT_FILE}} -o {{.BADGE_TESTS}}
vars:
JUNIT_FILE: ./{{.DIST_DIR}}/junit-pytest.xml
COVERAGE_FILE: ./{{.DIST_DIR}}/coverage.xml
COVERAGE_DIR: ./{{.DIST_DIR}}/coverage
BADGE_COVERAGE: ./{{.DIST_DIR}}/badge-coverage.svg
BADGE_TESTS: ./{{.DIST_DIR}}/badge-tests.svg
check:pylint:
desc: Find code smells, errors and style issues
<<: *preparation
cmds:
- poetry run pylint --exit-zero {{.PACKAGE}}
- poetry run pylint {{.PACKAGE}} {{.XML_PARAMS}}
vars:
FORMAT: --output-format=pylint_junit.JUnitReporter
JUNIT_FILE: ./{{.DIST_DIR}}/junit-pylint.xml
XML_PARAMS: --output={{.JUNIT_FILE}} {{.FORMAT}}
check:mypy:
desc: Find type errors
<<: *preparation
cmds:
- poetry run mypy -p tests -p {{.PACKAGE}} --junit-xml {{.JUNIT_FILE}}
vars:
JUNIT_FILE: ./{{.DIST_DIR}}/junit-mypy.xml
check:safety:
desc: Scan dependencies for vulnerabilities
<<: *preparation
cmds:
# ignore 51358 safety - dev dependency only
# ignore 61489 pillow - dev dependency only
- poetry run safety check -i 51358 -i 61489
check:bandit:
desc: Find common security issues
<<: *preparation
cmds:
- poetry run bandit --exit-zero -r {{.PACKAGE}}
- poetry run bandit --format xml -r {{.PACKAGE}} -o {{.JUNIT_FILE}}
vars:
JUNIT_FILE: ./{{.DIST_DIR}}/junit-bandit.xml
check:flake8:
desc: Enforce standard source code style guide
<<: *preparation
cmds:
- poetry run flake8 --exit-zero tests {{.PACKAGE}} {{.XML_PARAMS}}
- poetry run flake8 --show-source tests {{.PACKAGE}}
vars:
JUNIT_FILE: ./{{.DIST_DIR}}/junit-flake8.xml
XML_PARAMS: --format junit-xml --output-file {{.JUNIT_FILE}}
# }}}
# {{{ build and deploy tasks
deploy:
desc: Install plugin package in Corporate Memory
deps:
- clean
- build
cmds:
- cmemc admin workspace python install dist/*.tar.gz
- cmemc admin workspace python list-plugins
build:
desc: Build a tarball and a wheel package
<<: *preparation
cmds:
- poetry build
# }}}