forked from ansible/ansible-lint
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtox.ini
184 lines (176 loc) · 5.04 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
[tox]
minversion = 3.16.1
envlist =
lint
packaging
py310-{core,devel}
py{39,38}-{core,ansible29,devel}
py{37,36}-{core,ansible29}
isolated_build = true
requires =
setuptools >= 41.4.0
pip >= 19.3.0
skip_missing_interpreters = True
# `usedevelop = true` overrides `skip_install` instruction, it's unwanted
usedevelop = false
[testenv]
description =
Run the tests under {basepython} and
devel: ansible devel branch
ansible29: ansible 2.9
core: ansible-core 2.11+
extras =
yamllint
core: core
test
deps =
ansible29: ansible>=2.9,<2.10
py: ansible-core>=2.11
devel: ansible-core @ git+https://github.com/ansible/ansible.git # GPLv3+
commands =
# safety measure to assure we do not accidentally run tests with broken dependencies
{envpython} -m pip check
# We add coverage options but not making them mandatory as we do not want to force
# pytest users to run coverage when they just want to run a single test with `pytest -k test`
{envpython} -m pytest \
--junitxml "{toxworkdir}/junit.{envname}.xml" \
{posargs:\
--cov ansiblelint \
--cov "{envsitepackagesdir}/ansiblelint" \
--cov-report term-missing:skip-covered \
--cov-report xml:.test-results/pytest/cov.xml \
--no-cov-on-fail}
install_command =
{envpython} -m \
pip install \
{opts} \
{packages}
passenv =
CURL_CA_BUNDLE # https proxies, https://github.com/tox-dev/tox/issues/1437
FORCE_COLOR
HOME
NO_COLOR
PYTEST_* # allows developer to define their own preferences
PY_COLORS
REQUESTS_CA_BUNDLE # https proxies
SSL_CERT_FILE # https proxies
LANG
LC_ALL
LC_CTYPE
# recreate = True
setenv =
COVERAGE_FILE = {env:COVERAGE_FILE:{toxworkdir}/.coverage.{envname}}
PIP_CONSTRAINT = {toxinidir}/constraints.txt
PIP_DISABLE_PIP_VERSION_CHECK = 1
PRE_COMMIT_COLOR = always
FORCE_COLOR = 1
allowlist_externals =
sh
[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.9
deps =
pre-commit>=2.6.0
pip-tools>=6.2.0
setuptools>=51.1.1
skip_install = true
commands =
{envpython} -m pre_commit run --all-files --show-diff-on-failure {posargs:}
passenv =
{[testenv]passenv}
PRE_COMMIT_HOME
[testenv:deps]
description = Bump all test depeendencies
# we reuse the lint environment
envdir = {toxworkdir}/lint
skip_install = true
deps =
pre-commit>=2.14.0
setenv =
# without his upgrade would likely not do anything
PIP_CONSTRAINT = /dev/null
commands =
# manual hook calls the optional pip-compile-upgrade hook
{[testenv:lint]commands} --hook-stage manual pip-compile-upgrade
{[testenv:lint]commands} --hook-stage manual pip-compile-docs-upgrade
[testenv:docs]
description = Builds docs
basepython = python3
deps =
-r{toxinidir}/docs/requirements.in
setenv =
PIP_CONSTRAINT = {toxinidir}/docs/requirements.txt
commands =
# Build the html docs with Sphinx:
{envpython} -m sphinx \
-j auto \
-b html \
--color \
-a \
-n \
-W --keep-going \
-d "{temp_dir}/.doctrees" \
. \
"{envdir}/html"
# Print out the output docs dir and a way to serve html:
-{envpython} -c \
'import pathlib; docs_dir = pathlib.Path(r"{envdir}") / "html"; index_file = docs_dir / "index.html"; '\
'print("\n" + "=" * 120 + f"\n\nDocumentation available under `file://\{index_file\}`\n\nTo serve docs, use `python3 -m http.server --directory \{docs_dir\} 0`\n\n" + "=" * 120)'
changedir = {toxinidir}/docs
[testenv:linkcheck-docs]
description = Linkcheck The Docs
basepython = {[testenv:docs]basepython}
deps = {[testenv:docs]deps}
setenv =
{[testenv:docs]setenv}
commands =
{envpython} -m sphinx \
-j auto \
-b linkcheck \
-a \
-n \
-W --keep-going \
{tty:--color} \
-d "{temp_dir}/.doctrees" \
. \
"{envdir}/html"
changedir = {[testenv:docs]changedir}
[testenv:eco]
description = Perform ecosystem impact (downstream testing) https://github.com/ansible-community/ansible-lint/discussions/1403
commands =
ansible-playbook -i localhost, playbooks/eco.yml
extras =
yamllint
community
setenv =
ANSIBLE_FORCE_COLOR=1
ANSIBLE_NOCOWS=1
ANSIBLE_PYTHON_INTERPRETER=auto_silent
NO_COLOR=1
[testenv:packaging]
basepython = python3
description =
Build package, verify metadata, install package and assert behavior when ansible is missing.
deps =
build >= 0.7.0, < 0.8.0
twine
skip_install = true
# Ref: https://twitter.com/di_codes/status/1044358639081975813
commands =
# 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
twine check --strict {toxinidir}/dist/*
# Install the wheel
sh -c "python3 -m pip install {toxinidir}/dist/*.whl"
# Re-assure ansible is not installed
{envpython} tools/check-missing-ansible.py