summaryrefslogtreecommitdiffstats
path: root/tox.ini
diff options
context:
space:
mode:
Diffstat (limited to 'tox.ini')
-rw-r--r--tox.ini231
1 files changed, 231 insertions, 0 deletions
diff --git a/tox.ini b/tox.ini
new file mode 100644
index 0000000..173880c
--- /dev/null
+++ b/tox.ini
@@ -0,0 +1,231 @@
+# 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
+ eco
+isolated_build = true
+skip_missing_interpreters = True
+requires =
+ tox >= 4.6.3
+ setuptools >= 65.3.0 # editable installs
+
+[testenv]
+description =
+ Run the tests under {basepython} and
+ devel: ansible devel branch
+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 .tox/.coverage.* 2>/dev/null || true"
+ bash ./tools/install-reqs.sh
+commands =
+ # safety measure to assure we do not accidentally run tests with broken dependencies
+ {envpython} -m pip check
+ coverage run -m pytest {posargs:\
+ -n auto \
+ -ra \
+ --showlocals \
+ --doctest-modules \
+ --durations=10 \
+ }
+ sh -c "coverage combine -a -q --data-file=.coverage .tox/.coverage.*"
+
+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_*
+# recreate = True
+setenv =
+ # Avoid runtime warning that might affect our devel testing
+ devel: ANSIBLE_DEVEL_WARNING = false
+ COVERAGE_FILE = {env:COVERAGE_FILE:{toxworkdir}/.coverage.{envname}}
+ COVERAGE_PROCESS_START={toxinidir}/pyproject.toml
+ PIP_CONSTRAINT = {toxinidir}/.config/requirements.txt
+ devel,pkg: PIP_CONSTRAINT = /dev/null
+ PIP_DISABLE_PIP_VERSION_CHECK = 1
+ PRE_COMMIT_COLOR = always
+ FORCE_COLOR = 1
+allowlist_externals =
+ bash
+ find
+ git
+ pwd
+ rm
+ sh
+ tox
+ ./tools/test-hook.sh
+# 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.9
+deps =
+ pre-commit>=2.6.0
+ setuptools>=51.1.1
+ pytest>=7.2.2 # to updated schemas
+skip_install = true
+commands_pre =
+ {[testenv]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: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.9
+deps =
+ {[testenv:lint]deps}
+setenv =
+ # without his upgrade would likely not do anything
+ PIP_CONSTRAINT = /dev/null
+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 up
+ # 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 =
+ mkdocs build {posargs:}
+
+[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
+setenv =
+ # without his 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
+skip_install = true
+# Ref: https://twitter.com/di_codes/status/1044358639081975813
+commands_pre =
+ {[testenv]commands_pre}
+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 "ansible-lint[lock] @ 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 =
+ find . -type f -name '*.py[co]' -delete -o -type d -name __pycache__ -name coverage.xml -name .coverage
+ rm -rf .mypy_cache
+
+[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