Skip to content

Commit

Permalink
Update tox.ini (#4190)
Browse files Browse the repository at this point in the history
the devel check is disabled, will be replaced by a milestone later

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
cidrblock and pre-commit-ci[bot] authored Jun 4, 2024
1 parent 904d615 commit 0db2098
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 131 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/tox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ jobs:
docs
pkg
eco
py311-devel
build:
name: ${{ matrix.name }}
Expand Down Expand Up @@ -155,7 +154,7 @@ jobs:

- name: Check for expected number of coverage.xml reports
run: |
JOBS_PRODUCING_COVERAGE=4
JOBS_PRODUCING_COVERAGE=3
if [ "$(find . -name coverage.xml | wc -l | bc)" -ne "${JOBS_PRODUCING_COVERAGE}" ]; then
echo "::error::Number of coverage.xml files was not the expected one (${JOBS_PRODUCING_COVERAGE}): $(find . -name coverage.xml |xargs echo)"
exit 1
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@ site
src/molecule/_version.py
.vscode
test/resources/.extensions/
venv
21 changes: 11 additions & 10 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,20 @@ default = "molecule.driver.delegated:Delegated"
testinfra = "molecule.verifier.testinfra:Testinfra"
ansible = "molecule.verifier.ansible:Ansible"

[tool.coverage.run]
source = ["src"]
# branch = true
parallel = true
concurrency = ["multiprocessing", "thread"]
data_file = ".tox/.coverage"
relative_files = true

[tool.coverage.report]
exclude_lines = ["pragma: no cover", "if TYPE_CHECKING:"]
omit = ["test/*"]
exclude_also = ["if TYPE_CHECKING:", "pragma: no cover"]
fail_under = 88
ignore_errors = true
show_missing = true
skip_covered = true
skip_empty = true
sort = "Cover"

[tool.coverage.run]
branch = false # https://github.com/nedbat/coveragepy/issues/605
concurrency = ["multiprocessing", "thread"]
parallel = true
source_pkgs = ["molecule"]

[tool.black]
skip-string-normalization = false
Expand Down
195 changes: 76 additions & 119 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,145 +1,113 @@
[tox]
minversion = 4.2.2
envlist =
lint
requires =
tox>=4.11.3
env_list =
py
deps
docs
lint
milestone
pkg
# do not put specific python versions here, but use them when calling tox
py
py-{devel}

# do not enable skip missing to avoid CI false positives
skip_missing_interpreters = False
isolated_build = True
eco
skip_missing_interpreters = true

[testenv]
# both options needed to workaround https://github.com/tox-dev/tox/issues/2197
usedevelop = true
skip_install = false

commands_pre =
sh -c "rm -f {envdir}/.coverage.* 2>/dev/null || true"
commands =
ansibledevel: ansible-galaxy install git+https://github.com/ansible-collections/community.general.git
# failsafe as pip may install incompatible dependencies
pip check
# failsafe for preventing changes that may break pytest collection
sh -c "PYTEST_ADDOPTS= python3 -m pytest -p no:cov --collect-only >>/dev/null"
# html report is used by Zuul CI to display reports
coverage run -m pytest {env:_EXTRAS} {env:PYTEST_ADDOPTS:} {posargs}
sh -c "coverage combine -a -q --data-file={envdir}/.coverage {toxworkdir}/*/.coverage.* && coverage xml --data-file={envdir}/.coverage -o {envdir}/coverage.xml --fail-under=0"
passenv =
description = Run pytest under {basepython}
package = editable
extras =
test
pass_env =
CI
CONTAINER_*
DISPLAY
DOCKER_*
GITHUB_*
HOME
PIP_*
PODMAN_*
PUBLISH
PYTEST_*
SSH_AUTH_SOCK
TERM
setenv =
ANSIBLE_CONFIG={toxinidir}/.ansible.cfg
ANSIBLE_DISPLAY_FAILED_STDERR=1
ANSIBLE_NOCOWS=1
ANSIBLE_VERBOSITY=1
COVERAGE_FILE = {env:COVERAGE_FILE:{envdir}/.coverage.{envname}}
COVERAGE_PROCESS_START={toxinidir}/pyproject.toml
MOLECULE_NO_LOG=0
PIP_CONSTRAINT = {toxinidir}/.config/constraints.txt
lint,devel,deps,pkg,pre,ansibledevel: PIP_CONSTRAINT = /dev/null
PIP_DISABLE_PIP_VERSION_CHECK=1
PYTHONDONTWRITEBYTECODE=1
PYTHONUNBUFFERED=1
# Temporare remove "-n auto" as it seems to break coverage on this project.
_EXTRAS=-l
deps =
devel: git+https://github.com/ansible/ansible#egg=ansible-core
# pytest-molecule not used but we want to check that it does not conflict
devel: git+https://github.com/ansible-community/pytest-molecule#egg=pytest-molecule
extras =
test
USER
set_env =
!milestone: PIP_CONSTRAINT = {toxinidir}/.config/constraints.txt
COVERAGE_COMBINED = {envdir}/.coverage
COVERAGE_FILE = {env:COVERAGE_FILE:{envdir}/.coverage.{envname}}
COVERAGE_PROCESS_START = {toxinidir}/pyproject.toml
FORCE_COLOR = 1
PRE_COMMIT_COLOR = always
TERM = xterm-256color
commands_pre =
sh -c "rm -f {envdir}/.coverage* 2>/dev/null || true"
commands =
python -c 'import pathlib; pathlib.Path("{env_site_packages_dir}/cov.pth").write_text("import coverage; coverage.process_startup()")'
coverage run -m pytest {posargs:-n auto}
coverage combine -q --data-file={env:COVERAGE_COMBINED}
coverage xml --data-file={env:COVERAGE_COMBINED} -o {envdir}/coverage.xml --fail-under=0
coverage lcov --data-file={env:COVERAGE_COMBINED} -o {toxinidir}/.coverage/lcov.info --fail-under=0
coverage report --data-file={env:COVERAGE_COMBINED}
allowlist_externals =
bash
find
git
rm
sh

[testenv:deps]
description = Bump all test dependencies
# we reuse the lint environment
envdir = {toxworkdir}/lint
description = Bump all dependencies
base_python = python3.10
skip_install = true
basepython = python3.10
deps =
{[testenv:lint]deps}
setenv =
# without his upgrade would likely not do anything
PIP_CONSTRAINT = /dev/null
{[testenv:lint]deps}
extras =
set_env =
PIP_CONSTRAINT = /dev/null
commands_pre =
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
# We fail if files are modified at the end
git diff --exit-code

[testenv:lint]
description = Runs all linting tasks
# python pinned in order to have pip-compile output reproducible
basepython = python3.10
commands =
# to run a single linter you can do "pre-commit run flake8"
python3 -m pre_commit run {posargs:--all --show-diff-on-failure}
deps =
pre-commit>=2.21.0
check-jsonschema>=0.20.0
jsonschema>=4.17.3
setenv =
{[testenv]setenv}
skip_install = true
usedevelop = false
-pre-commit run --all-files --show-diff-on-failure --hook-stage manual deps
-pre-commit autoupdate
git diff --exit-code
env_dir = {toxworkdir}/lint

[testenv:docs]
description = Build documentation
passenv = *
usedevelop = true
commands =
linkchecker -q -f linkcheckerrc docs
mkdocs {posargs:build -c --strict}
description = Builds docs
package = editable
skip_install = false
extras =
docs
set_env =
NO_COLOR = 1
TERM = dump
commands =
mkdocs build {posargs:}

[testenv:lint]
description = Enforce quality standards under {basepython}
skip_install = true
deps =
pre-commit
set_env =
PIP_CONSTRAINT = /dev/null
commands =
pre-commit run --show-diff-on-failure --all-files

[testenv:milestone]
description =
Run tests with ansible-core milestone branch and without dependencies constraints
deps =
ansible-core@ https://github.com/ansible/ansible/archive/milestone.tar.gz
set_env =
{[testenv]set_env}
PIP_CONSTRAINT = /dev/null

[testenv:pkg]
description =
Do packaging/distribution. If tag is not present or PEP440 compliant upload to
PYPI could fail
# `usedevelop = true` overrides `skip_install` instruction, it's unwanted
usedevelop = false
# don't install molecule itself in this env
Do packaging/distribution
skip_install = true
deps =
build >= 0.9.0
build>=0.9
twine >= 4.0.2 # pyup: ignore
setenv =
set_env =
commands =
rm -rfv {toxinidir}/dist/
python3 -m build \
--outdir {toxinidir}/dist/ \
{toxinidir}
# metadata validation
sh -c "python3 -m twine check --strict {toxinidir}/dist/*"
python -m build --outdir {toxinidir}/dist/ {toxinidir}
sh -c "python -m twine check --strict {toxinidir}/dist/*"

[testenv:snap]
description = Builds a snap package
usedevelop = false
skip_install = true
commands =
sh -c "type snapcraft && snapcraft build"

[testenv:eco]
description = Smoketest of combining all known to be maintained plugins (ecosystem)
Expand All @@ -162,15 +130,4 @@ commands =
pipdeptree --reverse -e pip,pbr,six,setuptools,toml,urllib3
molecule --version
molecule drivers
bash ./tools/smoketest.sh

[testenv:coverage]
description = Combines and displays coverage results
commands =
-sh -c "coverage combine --append .tox/.coverage.*"
# needed by codecov github actions:
coverage xml -i
# just for humans running it:
coverage report -i
deps =
coverage[toml]
sh -c ./tools/smoketest.sh

0 comments on commit 0db2098

Please sign in to comment.