-
Notifications
You must be signed in to change notification settings - Fork 0
/
Taskfile.yaml
179 lines (153 loc) · 4.52 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
# 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
PWD:
sh: pwd
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:
summary: |
prepare check targets by creating appropriate directory
run: once
cmds:
- mkdir -p {{.DIST_DIR}}/coverage
poetry:install:
desc: Install dependencies managed by Poetry.
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]"
cmds:
- poetry check
- poetry install
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
python:format:
desc: Format Python files.
<<: *preparation
cmds:
- poetry run black .
poetry:update:
desc: Update dependencies managed by Poetry to their newest versions.
run: once
cmds:
- poetry update
poetry:shell:
desc: Open a poetry shell.
interactive: true
cmds:
- poetry shell
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.
deps:
- check:bandit
- check:flake8
- check:mypy
- check:pylint
- check:pytest
- check:safety
check:pytest:
desc: Run pytest suite.
<<: *preparation
cmds:
- poetry run pytest --memray --junitxml={{.JUNIT_FILE}} --cov-report term --cov-report xml:{{.COVERAGE_FILE}} --cov-report html:{{.COVERAGE_DIR}} --cov={{.PACKAGE}}
- poetry run genbadge coverage -l -i {{.COVERAGE_FILE}} -o {{.BADGE_COVERAGE}}
- 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: Check source code with pylint.
<<: *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: Check source code with mypy.
<<: *preparation
cmds:
- poetry run mypy -p tests -p {{.PACKAGE}} --junit-xml {{.JUNIT_FILE}}
vars:
JUNIT_FILE: ./{{.DIST_DIR}}/junit-mypy.xml
check:safety:
desc: Check source code with safety.
<<: *preparation
cmds:
# ignore 48547 rdflib - json-ld not in use
# ignore 51358 safety - dev dependency only
# ignore 52322 gitpython - dev dependency only
# ignore 51457 py - dev dependency only
- poetry run safety check -i 48547 -i 51358 -i 52322 -i 51457
check:bandit:
desc: Check source code with bandit.
<<: *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: Check source code with flake8.
<<: *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 tarball and a wheel package.
<<: *preparation
cmds:
- poetry build
# }}}