forked from canonical/cloud-init
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tox.ini
322 lines (290 loc) · 9.42 KB
/
tox.ini
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
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
[tox]
envlist =
py3,
black,
flake8,
isort,
mypy,
pylint
recreate = True
[doc8]
ignore-path-errors=doc/rtd/topics/faq.rst;D001
[testenv]
basepython = python3
setenv =
LC_ALL = en_US.utf-8
passenv=
PYTEST_ADDOPTS
[format_deps]
black==22.3.0
flake8==4.0.1
hypothesis==6.31.6
hypothesis_jsonschema==0.20.1
isort==5.10.1
mypy==0.950
pylint==2.13.9
pytest==7.0.1
types-jsonschema==4.4.2
types-oauthlib==3.1.6
types-PyYAML==6.0.4
types-requests==2.27.8
types-setuptools==57.4.9
typing-extensions==4.1.1
[files]
schema = cloudinit/config/schemas/schema-cloud-config-v1.json
version = cloudinit/config/schemas/versions.schema.cloud-config.json
[testenv:flake8]
deps =
flake8=={[format_deps]flake8}
commands = {envpython} -m flake8 {posargs:cloudinit/ tests/ tools/ conftest.py setup.py}
[testenv:pylint]
deps =
pylint=={[format_deps]pylint}
-r{toxinidir}/test-requirements.txt
-r{toxinidir}/integration-requirements.txt
commands = {envpython} -m pylint {posargs:cloudinit/ tests/ tools/ conftest.py setup.py}
[testenv:black]
deps =
black=={[format_deps]black}
commands = {envpython} -m black . --check
[testenv:isort]
deps =
isort=={[format_deps]isort}
commands = {envpython} -m isort . --check-only
[testenv:mypy]
deps =
hypothesis=={[format_deps]hypothesis}
hypothesis_jsonschema=={[format_deps]hypothesis_jsonschema}
mypy=={[format_deps]mypy}
pytest=={[format_deps]pytest}
types-jsonschema=={[format_deps]types-jsonschema}
types-oauthlib=={[format_deps]types-oauthlib}
types-pyyaml=={[format_deps]types-PyYAML}
types-requests=={[format_deps]types-requests}
types-setuptools=={[format_deps]types-setuptools}
typing-extensions=={[format_deps]typing-extensions}
commands = {envpython} -m mypy cloudinit/ tests/ tools/
[testenv:check_format]
deps =
black=={[format_deps]black}
flake8=={[format_deps]flake8}
hypothesis=={[format_deps]hypothesis}
hypothesis_jsonschema=={[format_deps]hypothesis_jsonschema}
isort=={[format_deps]isort}
mypy=={[format_deps]mypy}
pylint=={[format_deps]pylint}
pytest=={[format_deps]pytest}
types-jsonschema=={[format_deps]types-jsonschema}
types-oauthlib=={[format_deps]types-oauthlib}
types-pyyaml=={[format_deps]types-PyYAML}
types-requests=={[format_deps]types-requests}
types-setuptools=={[format_deps]types-setuptools}
typing-extensions=={[format_deps]typing-extensions}
-r{toxinidir}/test-requirements.txt
-r{toxinidir}/integration-requirements.txt
commands =
{[testenv:black]commands}
{[testenv:flake8]commands}
{[testenv:isort]commands}
{[testenv:mypy]commands}
{[testenv:pylint]commands}
[testenv:check_format_tip]
deps =
black
flake8
hypothesis
hypothesis_jsonschema
isort
mypy
pylint
pytest
types-jsonschema
types-oauthlib
types-pyyaml
types-requests
types-setuptools
typing-extensions
-r{toxinidir}/test-requirements.txt
-r{toxinidir}/integration-requirements.txt
commands =
{[testenv:check_format]commands}
[testenv:do_format]
deps =
black=={[format_deps]black}
isort=={[format_deps]isort}
commands =
{envpython} -m isort .
{envpython} -m black .
{envpython} -m json.tool --indent 2 {[files]schema} {[files]schema}
{envpython} -m json.tool --indent 2 {[files]version} {[files]version}
[testenv:do_format_tip]
deps =
black
isort
commands =
{[testenv:do_format]commands}
[testenv:py3]
deps =
-r{toxinidir}/test-requirements.txt
commands = {envpython} -m pytest \
--durations 10 \
-m "not hypothesis_slow" \
{posargs:--cov=cloudinit --cov-branch tests/unittests}
# experimental
[testenv:py3-fast]
deps =
-r{toxinidir}/test-requirements.txt
pytest-xdist
commands = {envpython} -m pytest -n auto -m "not hypothesis_slow" -m "not serial"\
{posargs:tests/unittests}
[testenv:hypothesis-slow]
deps =
hypothesis==6.31.6
hypothesis_jsonschema==0.20.1
-r{toxinidir}/test-requirements.txt
commands = {envpython} -m pytest \
-m hypothesis_slow \
{posargs:--hypothesis-show-statistics tests/unittests}
#commands = {envpython} -X tracemalloc=40 -Werror::ResourceWarning:cloudinit -m pytest \
[testenv:py3-leak]
deps = {[testenv:py3]deps}
commands = {envpython} -X tracemalloc=40 -Wall -m pytest \
--durations 10 \
{posargs:--cov=cloudinit --cov-branch \
tests/unittests}
[testenv:lowest-supported]
# Tox is going to install requirements from pip. This is fine for
# testing python version compatibility, but when we build cloud-init, we are
# building against the dependencies in the OS repo, not pip. The OS
# dependencies will generally be older than what is found in pip.
# To obtain these versions, check the versions of these libraries
# in the oldest support Ubuntu distro. Theses versions are from bionic.
deps =
jinja2==2.10
oauthlib==2.0.6
pyserial==3.4
configobj==5.0.6
pyyaml==3.12
requests==2.18.4
jsonpatch==1.16
jsonschema==2.6.0
netifaces==0.10.4
# test-requirements
pytest==3.3.2
pytest-cov==2.5.1
pytest-mock==1.7.1
# Needed by pytest and default causes failures
attrs==17.4.0
responses==0.5.1
commands = {[testenv:py3]commands}
[testenv:doc]
deps =
-r{toxinidir}/doc-requirements.txt
commands =
{envpython} -m sphinx {posargs:-W doc/rtd doc/rtd_html}
doc8 doc/rtd
# linkcheck shows false positives and has noisy output.
# Despite these limitations, it is better than a manual search of the docs.
# suggested workflow is:
#
# tox -e linkcheck | grep broken # takes some time
#
# followed by manual verification of the links reported
[testenv:linkcheck]
deps =
-r{toxinidir}/doc-requirements.txt
commands =
{envpython} -m sphinx {posargs:-b linkcheck doc/rtd doc/rtd_html}
[testenv:tip-flake8]
deps = flake8
commands = {[testenv:flake8]commands}
[testenv:tip-mypy]
deps =
hypothesis
hypothesis_jsonschema
mypy
pytest
types-jsonschema
types-oauthlib
types-PyYAML
types-requests
types-setuptools
commands = {[testenv:mypy]commands}
[testenv:tip-pylint]
deps =
# requirements
pylint
# test-requirements
-r{toxinidir}/test-requirements.txt
-r{toxinidir}/integration-requirements.txt
commands = {[testenv:pylint]commands}
[testenv:tip-black]
deps = black
commands = {[testenv:black]commands}
[testenv:tip-isort]
deps = isort
commands = {[testenv:isort]commands}
[testenv:integration-tests]
commands = {envpython} -m pytest -vv \
--log-cli-level=INFO \
--durations 10 \
{posargs:tests/integration_tests}
deps =
-r{toxinidir}/integration-requirements.txt
passenv = CLOUD_INIT_* PYCLOUDLIB_* SSH_AUTH_SOCK OS_*
[testenv:integration-tests-ci]
commands = {[testenv:integration-tests]commands}
deps = {[testenv:integration-tests]deps}
passenv = CLOUD_INIT_* SSH_AUTH_SOCK OS_* TRAVIS
setenv =
PYTEST_ADDOPTS="-m ci and not adhoc"
[testenv:integration-tests-jenkins]
# Pytest's RC=1 means "Tests were collected and run but some of the tests failed".
# Do not fail in this case, but let Jenkins handle it using the junit report.
allowlist_externals = sh
commands = sh -c "{envpython} -m pytest --log-cli-level=INFO -vv {posargs:tests/integration_tests/none} || [ $? -eq 1 ]"
deps = {[testenv:integration-tests]deps}
passenv = *_proxy CLOUD_INIT_* PYCLOUDLIB_* SSH_AUTH_SOCK OS_* GOOGLE_* GCP_*
setenv =
PYTEST_ADDOPTS="-m not adhoc"
[flake8]
# E203: whitespace before ':', doesn't adhere to pep8 or black formatting
# W503: line break before binary operator
ignore=E203,W503
exclude = .venv,.tox,dist,doc,*egg,.git,build,tools
per-file-ignores =
cloudinit/cmd/main.py:E402
[pytest]
# TODO: s/--strict/--strict-markers/ once pytest version is high enough
testpaths = tests/unittests
addopts = --strict
log_format = %(asctime)s %(levelname)-9s %(name)s:%(filename)s:%(lineno)d %(message)s
log_date_format = %Y-%m-%d %H:%M:%S
markers =
adhoc: only run on adhoc basis, not in any CI environment (travis or jenkins)
allow_all_subp: allow all subp usage (disable_subp_usage)
allow_subp_for: allow subp usage for the given commands (disable_subp_usage)
azure: test will only run on Azure platform
ci: run this integration test as part of CI test runs
ds_sys_cfg: a sys_cfg dict to be used by datasource fixtures
ec2: test will only run on EC2 platform
gce: test will only run on GCE platform
hypothesis_slow: hypothesis test too slow to run as unit test
ibm: test will only run on IBM platform
instance_name: the name to be used for the test instance
integration_cloud_args: args for IntegrationCloud customization
is_iscsi: whether is an instance has iscsi net cfg or not
lxd_config_dict: set the config_dict passed on LXD instance creation
lxd_container: test will only run in LXD container
lxd_setup: specify callable to be called between init and start
lxd_use_exec: `execute` will use `lxc exec` instead of SSH
lxd_vm: test will only run in LXD VM
no_container: test cannot run in a container
not_bionic: test cannot run on the bionic release
oci: test will only run on OCI platform
openstack: test will only run on openstack platform
serial: tests that do not work in parallel, skipped with py3-fast
ubuntu: this test should run on Ubuntu
unstable: skip this test because it is flakey
user_data: the user data to be passed to the test instance
allow_dns_lookup: disable autochecking for host network configuration