diff options
Diffstat (limited to 'tox.ini')
-rw-r--r-- | tox.ini | 191 |
1 files changed, 191 insertions, 0 deletions
@@ -0,0 +1,191 @@ +[tox] +minversion = 4.0.0 +envlist = + lint + pkg + docs + py + py-devel + py39-ansible212 + py39-ansible213 + py39-ansible214 + py39-ansible215 + py310-ansible212 + py310-ansible213 + py310-ansible214 + py310-ansible215 + py311-ansible212 + py311-ansible213 + py311-ansible214 + py311-ansible215 + py312-ansible216 + +isolated_build = true +skip_missing_interpreters = True +requires = + tox >= 4.6.3 + setuptools >= 65.3.0 # editable installs + +[testenv] +description = + Run the tests + devel: ansible devel branch + ansible212: ansible-core 2.12 + ansible213: ansible-core 2.13 + ansible214: ansible-core 2.14 + ansible215: ansible-core 2.15 + ansible216: ansible-core 2.16 + +deps = + ansible212: ansible-core>=2.12,<2.13 + ansible213: ansible-core>=2.13,<2.14 + ansible214: ansible-core>=2.14,<2.15 + ansible215: ansible-core>=2.15,<2.16 + ansible216: ansible-core>=2.16,<2.17 + + devel: ansible-core @ git+https://github.com/ansible/ansible.git@c5d18c39d81e2b3b10856b2fb76747230e4fac4a # GPLv3+ + # avoid installing ansible-core on -devel envs: + !devel: ansible-core +extras = + test + +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:} + sh -c "coverage combine -a -q --data-file=.coverage {toxworkdir}/.coverage.*" + # needed for upload to codecov.io + -sh -c "COVERAGE_FILE= coverage xml --ignore-errors -q --fail-under=0" + # needed for vscode integration due to https://github.com/ryanluker/vscode-coverage-gutters/issues/403 + -sh -c "COVERAGE_FILE= coverage lcov --ignore-errors -q --fail-under=0" + sh -c "COVERAGE_FILE= coverage report" + # We fail if files are modified at the end + git diff --exit-code + +commands_pre = + # safety measure to assure we do not accidentally run tests with broken dependencies + {envpython} -m pip check + # cleaning needed to prevent errors between runs + sh -c "rm -f .coverage {toxworkdir}/.coverage.* 2>/dev/null || true" +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 +setenv = + ANSIBLE_DEVEL_WARNING='false' + COVERAGE_FILE = {env:COVERAGE_FILE:{toxworkdir}/.coverage.{envname}} + COVERAGE_PROCESS_START={toxinidir}/pyproject.toml + PIP_DISABLE_PIP_VERSION_CHECK = 1 + PIP_CONSTRAINT = {toxinidir}/requirements.txt + PRE_COMMIT_COLOR = always + PYTEST_REQPASS = 93 + FORCE_COLOR = 1 +allowlist_externals = + ansible + git + sh +# https://tox.wiki/en/latest/upgrading.html#editable-mode +package = editable + +[testenv:lint] +description = Run all linters +# locked basepython is needed because to keep constrains.txt predictable +basepython = python3.10 +deps = + pre-commit>=2.6.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 + +[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 + +[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 +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.12+ +deps = + {[testenv]deps} + ansible-core>=2.12 + +[testenv:rpm] +description = Use packit to build RPM (requires RPM based Linux distro) +deps = + packitos +commands = + packit build in-mock + +[testenv:docs] +description = Build docs +commands = + mkdocs {posargs:build} --strict +extras = docs +passenv = * + +[testenv:smoke] +description = Run ansible-lint own testing with current code from compat library +commands_pre = + ansible localhost -m ansible.builtin.git -a 'repo=https://github.com/ansible/ansible-lint dest={envdir}/tmp/ansible-lint' + pip install -e "{envdir}/tmp/ansible-lint[test]" +commands = + bash -c "pip freeze|grep ansible" + pytest -k role +deps = + ansible-core +setenv = + {[testenv]setenv} + PIP_CONSTRAINT = /dev/null + PYTEST_REQPASS = 0 +changedir = {envdir}/tmp/ansible-lint +allowlist_externals = + pwd + bash |