Skip to content

Commit

Permalink
ci: fix coverage
Browse files Browse the repository at this point in the history
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
  • Loading branch information
henryiii committed Feb 20, 2024
1 parent ef54d13 commit ffc9be3
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 14 deletions.
8 changes: 5 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ jobs:
matrix:
os: [ubuntu-20.04, windows-latest, macos-latest]
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
tox-version: ["latest", "<4"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
Expand All @@ -37,8 +36,11 @@ jobs:
- name: Install Nox-under-test
run: |
python -m pip install --disable-pip-version-check .
- name: Run tests on ${{ matrix.os }}
run: nox --non-interactive --error-on-missing-interpreter --session "tests(python='${{ matrix.python-version }}', tox_version='${{ matrix.tox-version }}')" -- --full-trace
- name: Run tests on ${{ matrix.os }} (tox <4)
run: nox --non-interactive --error-on-missing-interpreter --session "tests(python='${{ matrix.python-version }}', tox_version='<4')" -- --full-trace
- name: Run tests on ${{ matrix.os }} (tox latest)
run: nox --non-interactive --error-on-missing-interpreter --session "tests(python='${{ matrix.python-version }}', tox_version='latest')" -- --full-trace
if: matrix.python-version != '3.7'
- name: Save coverage report
uses: actions/upload-artifact@v3
with:
Expand Down
14 changes: 5 additions & 9 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,24 +31,21 @@
nox.options.sessions.append("conda_tests")


# Because there is a dependency conflict between argcomplete and the latest tox
# (both depend on a different version of importlibmetadata for Py 3.7) pip
# installs tox 3 as the latest one for Py 3.7.
@nox.session
@nox.parametrize(
"python, tox_version",
[
(python, tox_version)
for python in ("3.7", "3.8", "3.9", "3.10", "3.11", "3.12")
for tox_version in ("latest", "<4")
if (python, tox_version) != ("3.7", "latest")
],
)
def tests(session: nox.Session, tox_version: str) -> None:
"""Run test suite with pytest."""
# Because there is a dependency conflict between
# argcomplete and the latest tox (both depend on
# a different version of importlibmetadata for Py 3.7)
# pip installs tox 3 as the latest one for Py 3.7.
if session.python == "3.7" and tox_version == "latest":
return

session.create_tmp() # Fixes permission errors on Windows
session.install("-r", "requirements-test.txt")
session.install("-e", ".[tox_to_nox]")
Expand All @@ -59,7 +56,6 @@ def tests(session: nox.Session, tox_version: str) -> None:
"--cov=nox",
"--cov-config",
"pyproject.toml",
"--cov-report=",
*session.posargs,
env={
"COVERAGE_FILE": f".coverage.{session.python}.tox.{tox_version.lstrip('<')}"
Expand All @@ -84,7 +80,7 @@ def cover(session: nox.Session) -> None:
if ON_WINDOWS_CI:
return

session.install("coverage[toml]")
session.install("coverage[toml]", "covdefaults")
session.run("coverage", "combine")
session.run("coverage", "report", "--fail-under=100", "--show-missing")
session.run("coverage", "erase")
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,12 @@ log_cli_level = "info"
testpaths = [ "tests" ]

[tool.coverage.run]
branch = true
relative_files = true
omit = [ "nox/_typing.py" ]
plugins = [ "covdefaults" ]

[tool.coverage.report]
exclude_lines = [ "pragma: no cover", "if TYPE_CHECKING:", "@overload" ]
fail_under = 90 # 100 for combined coverage

[tool.mypy]
files = [ "nox/**/*.py", "noxfile.py" ]
Expand Down
1 change: 1 addition & 0 deletions requirements-test.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
covdefaults
flask
myst-parser
pytest>=6.0
Expand Down

0 comments on commit ffc9be3

Please sign in to comment.