forked from kuchtact/WiPPLPy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnoxfile.py
More file actions
68 lines (55 loc) · 1.7 KB
/
noxfile.py
File metadata and controls
68 lines (55 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import nox
supported_python_versions = ("3.9", "3.10", "3.11", "3.12")
maxpython = max(supported_python_versions)
# Set the default backend to conda if available, because it is probably
# needed to install MDSplus installation anyway. The next choice is uv
# because it has excellent performance when resolving requirements.
nox.options.default_venv_backend = "mamba|conda"
def install_environment(session, environment_path="mamba_environment.yml"):
session.run(
*[
session.venv_backend,
"env",
"update",
"--verbose",
"--prefix",
session.virtualenv.location,
"--file",
environment_path,
],
silent=False,
)
session.run(
*[
session.venv_backend,
"list",
"--prefix",
session.virtualenv.location,
]
)
test_specifiers: list = [
nox.param("run all tests", id="all"),
nox.param("with code coverage", id="cov"),
]
with_coverage: tuple[str, ...] = (
"--cov=wipplpy",
"--cov-report=xml",
"--cov-config=pyproject.toml",
"--cov-append",
"--cov-report",
"xml:coverage.xml",
)
@nox.session(python=supported_python_versions)
@nox.parametrize("test_specifier", test_specifiers)
def tests(session, test_specifier):
"""Run tests with pytest."""
install_environment(session)
options = []
if test_specifier == "with code coverage":
options += with_coverage
session.run("pytest", *options)
@nox.session(python=maxpython)
def docs(session):
"""Build documentation with Sphinx."""
session.install("sphinx")
session.run("sphinx-build", "-b", "html", "docs/source/", "docs/build/")