-
Notifications
You must be signed in to change notification settings - Fork 110
/
tox.ini
188 lines (173 loc) · 6.13 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
# Recommended usage of this file is detailed in https://github.com/ansible/eda-partner-testing/blob/main/README.md.
# The linter paths can be changed, but may result in false passes.
# {posargs} in this case would be the path to collection root relative from the .github/workflows dir (`../..`)
# cspell: ignore TOXPYTHON setenv passenv REQPASS PYTHONPYCACHEPREFIX PYTHONIOENCODING PYTHONBREAKPOINT notest envdir envname toxworkdir junitxml
[tox]
envlist =
lint
darglint
docs
build
unit
sanity
integration
staging
coverage
skipsdist = true # this repo is not a python package
isolated_build = true
requires =
tox >= 4.6.3
tox-extra == 2.0.2 # bindep check
setuptools >= 65.3.0 # editable installs
ignore_basepython_conflict = false
[testenv]
description =
Run unit tests
py{39,310,311,312,313}: with {basepython}
deps = -r .config/requirements-test.in
commands_pre =
bash -c 'test "$(basename $(cd ../.. && pwd))" == ansible_collections || { echo "Repository must be cloned inside a directory structure like ansible_collections/ansible/eda in order allow ansible-test to run."; exit 3;}'
commands =
echo "Implicit tox environment should not be called directly (safety measure to avoid running wrong tests due to typos)"
false
; tox -e sanity,unit,integration {posargs}
allowlist_externals =
bash
sh
isolated_build = true
; # See https://stackoverflow.com/a/76884052/99834
; py310: true
setenv =
; COVERAGE_FILE = {env:COVERAGE_FILE:{envdir}/.coverage.{envname}}
; COVERAGE_PROCESS_START={toxinidir}/pyproject.toml
PIP_CONSTRAINT = {toxinidir}/.config/constraints.txt
lint,build: PIP_CONSTRAINT = /dev/null
PIP_NO_BUILD_ISOLATION = 1
PYTHONUNBUFFERED = 1
passenv =
ANSIBLE_FORCE_COLOR
CI
CURL_CA_BUNDLE # https proxies, https://github.com/tox-dev/tox/issues/1437
FORCE_COLOR
GH_*
GITHUB_*
HOME
LANG
LC_*
NO_COLOR
PYTEST_* # allows developer to define their own preferences
PYTEST_REQPASS # needed for CI
PYTHON* # PYTHONPYCACHEPREFIX, PYTHONIOENCODING, PYTHONBREAKPOINT,...
PY_COLORS
READTHEDOCS*
REQUESTS_CA_BUNDLE # https proxies
RTD_TOKEN
SETUPTOOLS_SCM_DEBUG
SSH_AUTH_SOCK # may be needed by git
SSL_CERT_FILE # https proxies
# https://tox.wiki/en/latest/upgrading.html#editable-mode
package = editable
[testenv:py{39,310,311,312,313}]
description =
Run all test types: sanity, unit, integration
py{39,310,311,312,313}: with {basepython}
[testenv:changelog]
deps = antsibull-changelog
description = Builds documentation with changelog
commands =
antsibull-changelog generate
[testenv:lint]
deps = pre-commit
description = Run linters
commands = pre-commit run -a
[testenv:darglint]
deps = darglint
description = Run darglint
commands = darglint -s numpy -z full extensions/eda/plugins
[testenv:deps]
description = Bump all test dependencies
# we reuse the lint environment
envdir = {toxworkdir}/lint
skip_install = true
deps =
{[testenv:lint]deps}
setenv =
# without his upgrade would likely not do anything
PIP_CONSTRAINT = /dev/null
commands_pre =
commands =
pre-commit run --hook-stage=manual deps
[testenv:integration,py{39,310,311,312,313}-integration]
deps = -r .config/requirements-test.in
description =
Run integration tests
py{39,310,311,312,313}: with {basepython}
commands =
# risky: not safe for development it affects user setup
ansible-galaxy collection install .
# use same coverage location as ansible-test:
coverage run --data-file=tests/output/coverage/integration.coverage -m pytest tests/integration -vvv -s --junitxml=tests/output/junit/integration.xml {posargs}
[testenv:staging,py311-staging]
basepython = python3.11
setenv =
EDA_CONTROLLER_HOST = https://localhost:8443
EDA_CONTROLLER_USERNAME = admin
EDA_CONTROLLER_PASSWORD = testpass
EDA_CONTROLLER_VERIFY_SSL = False
deps =
docker
ansible-core >= 2.16,<2.17
description =
Run Ansible integration tests against staging instance (AAP 2.5, python3.11, ansible-core 2.16)
commands_pre =
commands =
./tests/run-staging {posargs:}
allowlist_externals =
./tests/run-staging
[testenv:unit,py{39,310,311,312,313}-unit]
description =
Run unit tests
py{39,310,311,312,313}: with {basepython}
commands =
# fail-fast if psycopg in not properly installed.
python3 -c "import psycopg"
sh -c "ansible-test units --color --requirements --target-python default -v --num-workers 1 --coverage --truncate 0 {posargs}"
ansible-test coverage report --requirements --omit '.tox/*,tests/*' --color --all --show-missing -v --truncate 0
ansible-test coverage combine --export={envdir}
[testenv:sanity,py{39,310,311,312,313}-sanity,py{39,310,311}-sanity-ansible2.15,py{310,311,312}-sanity-ansible{2.16,2.17,2.18}]
deps =
py{39,310,311}-sanity-ansible2.15: ansible-core>=2.15,<2.16
py{310,311,312}-sanity-ansible2.16: ansible-core>=2.16,<2.17
py{310,311,312}-sanity-ansible2.17: ansible-core>=2.17,<2.18
py{310,311,312}-sanity-ansible2.18: ansible-core>=2.18,<2.19
-r .config/requirements-test.in
description =
Run ansible-test sanity (via docker)
py{39,310,311,312,313}: with {basepython}
commands =
ansible --version
ansible-test sanity -v --docker --color --requirements --coverage --truncate 0 --junit {posargs}
[testenv:coverage,py{39,310,311,312,313}-coverage]
description = Produce final coverage report for GHA
deps = -r .config/requirements-test.in
commands =
ansible-test coverage report --requirements --omit '.tox/*,tests/*' --color --all --show-missing -v --truncate 0
# produces: tests/output/coverage/coverage.combined
ansible-test coverage combine --export={envdir}
# produces tests/output/reports/coverage.xml
ansible-test coverage xml --requirements
[testenv:docs,py{39,310,311,312,313}-docs]
description = Generate plugins documentation under /docs directory using antsibull-docs
# When run under RTD it will reuse their pre-created environment and save time.
env_dir = {env:READTHEDOCS_VIRTUALENV_PATH:{work_dir}/docs}}
deps =
ansible-core
-r .config/requirements-docs.in
commands_pre =
# --force must remain here or we risk on building docs for older version
ansible-galaxy collection install --force .
commands =
./docs/build.sh
allowlist_externals =
./docs/build.sh
bash