From 7551f2b5e5f864b411e522facb2a10b3a933f054 Mon Sep 17 00:00:00 2001 From: Sorin Sbarnea Date: Wed, 30 Nov 2022 17:34:39 +0000 Subject: [PATCH] Upgrade tox config (#193) --- .github/workflows/tox.yml | 12 ++++-------- pyproject.toml | 1 + tox.ini | 14 ++++++-------- 3 files changed, 11 insertions(+), 16 deletions(-) diff --git a/.github/workflows/tox.yml b/.github/workflows/tox.yml index 33733109..63f055a0 100644 --- a/.github/workflows/tox.yml +++ b/.github/workflows/tox.yml @@ -29,7 +29,7 @@ jobs: env: - TOXENV: lint - TOXENV: docs - - TOXENV: packaging + - TOXENV: pkg env: TOX_PARALLEL_NO_SPINNER: 1 FORCE_COLOR: 1 @@ -58,7 +58,7 @@ jobs: key: ${{ matrix.name }}-pip-${{ hashFiles('setup.cfg', 'tox.ini', 'pyproject.toml', '.pre-commit-config.yaml') }} - name: Install tox - run: python3 -m pip install --upgrade tox + run: python3 -m pip install --upgrade 'tox>=4.0.0rc1' - name: Log installed dists run: python -m pip freeze --all @@ -119,7 +119,7 @@ jobs: python-version: "3.10" - name: py311 tox_env: py311,py311-devel - python-version: "~3.11.0-0" # see https://github.com/actions/setup-python/issues/213#issuecomment-1146676713 + python-version: "3.11" # macos - name: py38@macos tox_env: py38,py38-ansible29 # 2.14(devel) does not support 3.8 @@ -162,7 +162,7 @@ jobs: key: ${{ runner.os }}-${{ matrix.name }}-pip-${{ hashFiles('constraints.txt', 'setup.cfg', 'tox.ini', 'pyproject.toml', '.pre-commit-config.yaml', 'pytest.ini') }} - name: Install tox - run: python3 -m pip install --upgrade tox 'coverage[toml]' + run: python3 -m pip install --upgrade "tox>=4.0.0rc1" - name: Log installed dists run: python3 -m pip freeze --all @@ -173,10 +173,6 @@ jobs: - name: "Test with tox: ${{ matrix.tox_env }}" run: python3 -m tox -e ${{ matrix.tox_env }} - - name: Combine coverage data - # produce a single .coverage file at repo root - run: coverage combine .tox/.coverage.* - - name: Upload coverage data if: "runner.os == 'Linux'" uses: codecov/codecov-action@v3 diff --git a/pyproject.toml b/pyproject.toml index e5b00c9b..f1035e73 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -12,6 +12,7 @@ branch = true [tool.coverage.report] exclude_lines = ["pragma: no cover", "if TYPE_CHECKING:"] +skip_covered = true [tool.isort] profile = "black" diff --git a/tox.ini b/tox.ini index f9da4ba8..0da92528 100644 --- a/tox.ini +++ b/tox.ini @@ -1,8 +1,8 @@ [tox] -minversion = 3.16.1 +minversion = 4.0.0rc1 envlist = lint - packaging + pkg docs # matrix assumed current (implicit) is 2.13: py38{,-ansible29} @@ -10,9 +10,6 @@ envlist = py310{,-devel} py311{,-devel} isolated_build = true -requires = - setuptools >= 41.4.0 - pip >= 19.3.0 skip_missing_interpreters = True skipsdist = true @@ -41,10 +38,11 @@ deps = --editable .[test] commands = - ansible --version + 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 xml || true && coverage report" commands_pre = # safety measure to assure we do not accidentally run tests with broken dependencies {envpython} -m pip check @@ -99,8 +97,7 @@ skip_install = true commands = {[testenv:lint]commands} --hook-stage manual -[testenv:packaging] -basepython = python3 +[testenv:pkg] description = Build package, verify metadata, install package and assert behavior when ansible is missing. deps = @@ -122,6 +119,7 @@ commands = twine check --strict {toxinidir}/dist/* # Install the wheel sh -c "python3 -m pip install {toxinidir}/dist/*.whl" + pip uninstall -y ansible-compat [testenv:py{39,38,37,36}] description = Run the tests with {basepython} ansible-core 2.11+