forked from ansible/ansible-lint
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tox.ini
259 lines (246 loc) · 7.31 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
# spell-checker:ignore linkcheck basepython changedir envdir envlist envname envsitepackagesdir passenv setenv testenv toxinidir toxworkdir usedevelop doctrees envpython posargs
[tox]
minversion = 4.6.3
envlist =
lint
pkg
hook
docs
schemas
py
py-devel
lower
pre
eco
isolated_build = true
skip_missing_interpreters = True
requires =
tox >= 4.6.3
tox-uv >= 1.16.0
setuptools >= 65.3.0 # editable installs
[testenv]
description =
Run the tests under {basepython}
devel: and ansible devel branch
pre: and enable --pre when installing dependencies, testing prereleases
deps =
devel: ansible-core @ git+https://github.com/ansible/ansible.git # GPLv3+
devel: ansible-compat @ git+https://github.com/ansible/ansible-compat.git # GPLv3+
extras =
test
commands_pre =
sh -c "rm -f {envdir}/.coverage.* 2>/dev/null || true"
# safety measure to assure we do not accidentally run tests with broken dependencies
{envpython} -m pip check
{envpython} -m pip freeze
bash ./tools/install-reqs.sh
ansible --version
commands =
sh -c "{envpython} -m pip freeze > {envdir}/log/requirements.txt"
coverage run -m pytest {posargs:\
-n auto \
-ra \
--showlocals \
--doctest-modules \
--durations=10 \
}
{py,py310,py311,py312,py313}: sh -c "coverage combine -a -q --data-file={envdir}/.coverage {toxworkdir}/*/.coverage.* && coverage xml --data-file={envdir}/.coverage -o {envdir}/coverage.xml --fail-under=0"
passenv =
CURL_CA_BUNDLE # https proxies, https://github.com/tox-dev/tox/issues/1437
FORCE_COLOR
HOME
LANG
LC_*
NO_COLOR
PYTEST_* # allows developer to define their own preferences
PYTEST_REQPASS # needed for CI
PYTHON* # PYTHONPYCACHEPREFIX, PYTHONIOENCODING, PYTHONBREAKPOINT,...
PY_COLORS
RTD_TOKEN
REQUESTS_CA_BUNDLE # https proxies
SETUPTOOLS_SCM_DEBUG
SSL_CERT_FILE # https proxies
SSH_AUTH_SOCK # may be needed by git
UV_*
# recreate = True
setenv =
# Avoid runtime warning that might affect our devel testing
devel: ANSIBLE_DEVEL_WARNING = false
COVERAGE_FILE = {env:COVERAGE_FILE:{envdir}/.coverage.{envname}}
COVERAGE_PROCESS_START={toxinidir}/pyproject.toml
PIP_CONSTRAINT = {toxinidir}/.config/constraints.txt
devel,pkg,pre,py310: PIP_CONSTRAINT = /dev/null
PIP_DISABLE_PIP_VERSION_CHECK = 1
PRE_COMMIT_COLOR = always
# Number of expected test passes, safety measure for accidental skip of
# tests. Update value if you add/remove tests. (tox-extra)
PYTEST_REQPASS = 895
FORCE_COLOR = 1
pre: PIP_PRE = 1
allowlist_externals =
bash
find
git
pwd
rm
sh
tox
./tools/test-hook.sh
{toxworkdir}/.pipx/bin/ansible-lint
# https://tox.wiki/en/latest/upgrading.html#editable-mode
package = editable
[testenv:lint]
description = Run all linters
# pip compile includes python version in output constraints, so we want to
# be sure that version does not change randomly.
basepython = python3.10
deps =
pre-commit>=4.0.1
pre-commit-uv>=4.1.4
setuptools>=51.1.1
pytest>=7.2.2 # to updated schemas
skip_install = true
commands_pre =
commands =
{envpython} -m pre_commit run --all-files --show-diff-on-failure {posargs:}
passenv =
{[testenv]passenv}
PRE_COMMIT_HOME
setenv =
{[testenv]setenv}
# avoid messing pre-commit with out own constraints
PIP_CONSTRAINT=
[testenv:lower]
description = Install using lower-constraints.txt file for testing oldest versions.
setenv =
PIP_CONSTRAINT = {toxinidir}/.github/lower-constraints.txt
[testenv:hook]
description = Validate pre-commit hook definition
deps = pre-commit
commands =
./tools/test-hook.sh
setenv =
PIP_CONSTRAINT=/dev/null
[testenv:deps]
description = Bump all test dependencies
# we reuse the lint environment
envdir = {toxworkdir}/lint
skip_install = true
basepython = python3.10
deps =
{[testenv:lint]deps}
setenv =
# without his upgrade would likely not do anything
PIP_CONSTRAINT = /dev/null
commands_pre =
commands =
-pre-commit run --all-files --show-diff-on-failure --hook-stage manual lock
-pre-commit run --all-files --show-diff-on-failure --hook-stage manual deps
# Update pre-commit hooks
-pre-commit autoupdate
# Update npm deps
-sh -c "cd test/schemas && npm run deps"
# We fail if files are modified at the end
git diff --exit-code
[testenv:docs]
description = Builds docs
extras =
docs
setenv =
# Disable colors until markdown-exec supports it:
# https://github.com/pawamoy/markdown-exec/issues/11
NO_COLOR = 1
TERM = dump
skip_install = false
usedevelop = true
commands_pre =
ansible-lint --version
commands =
mkdocs {posargs:build --strict --site-dir=_readthedocs/html/}
[testenv:redirects]
description = Update documentation redirections for readthedocs
deps =
readthedocs-cli
commands =
# This assumes you loaded RTD_TOKEN in your environment
rtd projects ansible-lint redirects sync -f docs/redirects.yml --wet-run
[testenv:schemas]
description = Rebuild and test JSON Schemas
deps =
check-jsonschema>=0.26.3
setenv =
# without this upgrade would likely not do anything
PIP_CONSTRAINT = /dev/null
skip_install = true
changedir = test/schemas
commands_pre =
npm install
commands =
npm test
allowlist_externals =
npm
[testenv:eco]
description = Perform ecosystem impact (downstream testing) https://github.com/ansible/ansible-lint/discussions/1403
deps =
{[testenv]deps}
extras =
test
commands =
sh -c tools/test-eco.sh
allowlist_externals =
{[testenv]allowlist_externals}
setenv =
PYTEST_REQPASS=7
[testenv:pkg]
description =
Build package, verify metadata, install package and assert behavior when ansible is missing.
deps =
build >= 0.9.0
twine >= 4.0.1
pip
pipx
skip_install = true
# Ref: https://twitter.com/di_codes/status/1044358639081975813
commands_pre =
commands =
# Testing pipx usage
bash -c "PIPX_BIN_DIR={toxworkdir}/.pipx/bin PIPX_HOME={toxworkdir}/.pipx pipx install --force -e ."
# Testing that calling the pipx installation does return 0 return code and no output in stderr
bash -c "if stderr=$({toxworkdir}/.pipx/bin/ansible-lint --version >/dev/null) && test -z \"$stderr\"; then echo "ok"; fi"
# build wheel and sdist using PEP-517
{envpython} -c 'import os.path, shutil, sys; \
dist_dir = os.path.join("{toxinidir}", "dist"); \
os.path.isdir(dist_dir) or sys.exit(0); \
print("Removing \{!s\} contents...".format(dist_dir), file=sys.stderr); \
shutil.rmtree(dist_dir)'
{envpython} -m build --outdir {toxinidir}/dist/ {toxinidir}
# Validate metadata using twine
python3 -m twine check --strict {toxinidir}/dist/*
# Install the wheel
sh -c 'python3 -m pip install "ansible-lint @ file://$(echo {toxinidir}/dist/*.whl)"'
# Uninstall it
python3 -m pip uninstall -y ansible-lint
[testenv:clean]
description = Remove temporary files
skip_install = true
deps =
commands_pre =
commands_post =
commands =
find . -type d \( -name __pycache__ -o -name .mypy_cache \) -delete
find . -type f \( -name '*.py[co]' -o -name ".coverage*" -o -name coverage.xml \) -delete
[testenv:coverage]
description = Combines and displays coverage results
skip_install = true
usedevelop = false
setenv =
COVERAGE_PROCESS_START={toxinidir}/pyproject.toml
commands_pre =
commands =
python3 -m coverage --version
# needed by codecov github actions, also ignored result to reach report one.
python3 -m coverage xml --fail-under=0
# just for humans running it:
python3 -m coverage report
deps =
coverage[toml]>=7.0.5