Skip to content

Commit

Permalink
ci: try manually fixing the coverage files on Windows
Browse files Browse the repository at this point in the history
Signed-off-by: Henry Schreiner <[email protected]>
  • Loading branch information
henryiii committed Feb 23, 2024
1 parent 4a9e9bb commit fe2b906
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
17 changes: 15 additions & 2 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@

from __future__ import annotations

import contextlib
import functools
import os
import platform
import shutil
import sqlite3
import sys

import nox
Expand Down Expand Up @@ -49,9 +51,13 @@ def tests(session: nox.Session, tox_version: str) -> None:
if session.python == "3.7" and tox_version == "latest":
return

coverage_file = (
f".coverage.{sys.platform}.{session.python}.tox{tox_version.lstrip('<')}"
)

session.create_tmp() # Fixes permission errors on Windows
session.install("-r", "requirements-test.txt")
session.install(".[tox_to_nox]")
session.install("-e.[tox_to_nox]")
if tox_version != "latest":
session.install(f"tox{tox_version}")
session.run(
Expand All @@ -62,10 +68,17 @@ def tests(session: nox.Session, tox_version: str) -> None:
"--cov-report=",
*session.posargs,
env={
"COVERAGE_FILE": f".coverage.{sys.platform}.{session.python}.tox{tox_version.lstrip('<')}",
"COVERAGE_FILE": coverage_file,
},
)

if sys.platform.startswith("win"):
with contextlib.closing(
sqlite3.connect(coverage_file)
) as con, con:
con.execute("UPDATE file SET path = REPLACE(path, '\\', '/')")
con.execute("DELETE FROM file WHERE SUBSTR(path, 2, 1) == ':'")


@nox.session(python=["3.7", "3.8", "3.9", "3.10"], venv_backend="conda")
def conda_tests(session: nox.Session) -> None:
Expand Down
8 changes: 1 addition & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -97,20 +97,14 @@ log_cli_level = "info"
testpaths = [ "tests" ]

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

[tool.coverage.report]
exclude_lines = [ "pragma: no cover", "if TYPE_CHECKING:", "@overload" ]

[tool.coverage.paths]
source = [
"nox",
"*.nox/*/lib*/python*/site-packages/nox",
"*.nox\\*\\Lib\\site-packages\\nox",
]

[tool.mypy]
files = [ "nox/**/*.py", "noxfile.py" ]
python_version = "3.7"
Expand Down

0 comments on commit fe2b906

Please sign in to comment.