File: tox.ini

package info (click to toggle)
python-ansible-compat 25.1.5-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 656 kB
  • sloc: python: 2,522; sh: 26; makefile: 24
file content (183 lines) | stat: -rw-r--r-- 5,331 bytes parent folder | download
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
[tox]
envlist =
  lint
  pkg
  docs
  py
  py-devel
  py310-ansible216
  py310-ansible217
  py311-ansible216
  py311-ansible217
  py312-ansible216
  py312-ansible217
  py312-ansible218
  py313-ansible218

isolated_build = true
skip_missing_interpreters = True
requires =
  tox >= 4.24.1
  tox-uv >= 1.20.1
  setuptools >= 65.3.0 # editable installs

[testenv]
description =
  Run the tests
  devel: ansible devel branch
  ansible216: ansible-core 2.16
  ansible217: ansible-core 2.17
  ansible218: ansible-core 2.18

deps =
  ansible216: ansible-core>=2.16,<2.17
  ansible217: ansible-core>=2.17,<2.18
  ansible218: ansible-core>=2.18,<2.19

  devel: ansible-core @ git+https://github.com/ansible/ansible.git@devel  # GPLv3+
  # avoid installing ansible-core on -devel envs:
  !devel: ansible-core
extras =
  test


commands_pre =
  # safety measure to assure we do not accidentally run tests with broken dependencies
  !{docs}: {envpython} -m pip check
  # cleaning needed to prevent errors between runs
  sh -c "rm -f {envdir}/.coverage.* 2>/dev/null || true"
commands =
  sh -c "ansible --version | head -n 1"
  # 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`
  coverage run -m pytest {posargs:}
  # needed for upload to codecov.io
  {py,py310,py311,py312,py313}: sh -c "coverage combine -q --data-file={envdir}/.coverage {envdir}/.coverage.* && coverage xml --data-file={envdir}/.coverage -o {envdir}/coverage.xml --ignore-errors --fail-under=0 && COVERAGE_FILE={envdir}/.coverage coverage lcov --fail-under=0 --ignore-errors -q && COVERAGE_FILE={envdir}/.coverage coverage report --fail-under=0 --ignore-errors"
  # lcov needed for vscode integration due to https://github.com/ryanluker/vscode-coverage-gutters/issues/403

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
  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
  LANG
  LC_*
setenv =
  ANSIBLE_HOME = {envdir}/.ansible
  ANSIBLE_DEVEL_WARNING='false'
  COVERAGE_FILE = {env:COVERAGE_FILE:{envdir}/.coverage.{envname}}
  COVERAGE_PROCESS_START={toxinidir}/pyproject.toml
  PIP_DISABLE_PIP_VERSION_CHECK = 1
  PIP_CONSTRAINT = {toxinidir}/.config/constraints.txt
  UV_CONSTRAINT = {toxinidir}/.config/constraints.txt
  PRE_COMMIT_COLOR = always
  FORCE_COLOR = 1
allowlist_externals =
  ansible
  git
  sh
# https://tox.wiki/en/latest/upgrading.html#editable-mode
package = editable
uv_seed = true

[testenv:lint]
description = Run all linters
# locked basepython is needed because to keep constrains.txt predictable
basepython = python3.10
deps =
  pip
  pre-commit>=4.0.1
  pre-commit-uv>=1.15.0
skip_install = true
usedevelop = false
commands =
  pre-commit run -a --show-diff-on-failure {posargs:}
  pre-commit run -a pip-compile
passenv =
  {[testenv]passenv}
  PRE_COMMIT_HOME
setenv =
  {[testenv]setenv}
  PIP_CONSTRAINT = /dev/null
  UV_CONSTRAINT = /dev/null

[testenv:deps]
description = Bump all test dependencies
basepython = {[testenv:lint]basepython}
envdir = {toxworkdir}/lint
deps = {[testenv:lint]deps}
skip_install = true
commands =
  pre-commit run -a --hook-stage manual pip-compile-upgrade
  {[testenv:lint]commands}
setenv =
  {[testenv]setenv}
  PIP_CONSTRAINT = /dev/null
  UV_CONSTRAINT = /dev/null

[testenv:pkg]
description =
  Build package, verify metadata, install package and assert behavior when ansible is missing.
deps =
  build >= 0.9.0
  pip
  twine >= 4.0.1
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"
  pip uninstall -y ansible-compat

[testenv:py]
description = Run the tests with {basepython} ansible-core 2.16+
deps =
  {[testenv]deps}
  ansible-core>=2.16

[testenv:rpm]
description = Use packit to build RPM (requires RPM based Linux distro)
deps =
  packitos
commands =
  sh -c "packit build in-mock --root=fedora-40-$(arch)"

[testenv:docs]
description = Build docs
commands =
  mkdocs {posargs:build --strict --site-dir=_readthedocs/html/}
setenv =
  # https://squidfunk.github.io/mkdocs-material/plugins/requirements/image-processing/#troubleshooting
  DYLD_FALLBACK_LIBRARY_PATH = /opt/homebrew/lib:{env:LD_LIBRARY_PATH}
extras = docs
passenv = *

[testenv:smoke]
description = Run ansible-lint and molecule own testing with current code from compat library
commands =
  python3 tools/smoke.py
del_env =
  PIP_CONSTRAINT
  UV_CONSTRAINT
editable = true
skip_install = true