-
Notifications
You must be signed in to change notification settings - Fork 0
/
noxfile.py
105 lines (82 loc) · 2.99 KB
/
noxfile.py
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
import os
import shutil
import sys
from pathlib import Path
import nox
PACKAGE = "pysmooth"
PYTHON_VERSIONS = ["3.10", "3.11"]
os.environ["PDM_IGNORE_SAVED_PYTHON"] = "1"
os.environ["PDM_IGNORE_ACTIVE_VENV"] = "0"
nox.needs_version = ">=2024.4.15"
nox.options.sessions = (
"mypy",
"tests",
)
locations = (
"src",
"tests",
)
@nox.session
def lint(session: nox.Session) -> None:
"""Lint using ruff."""
args = session.posargs or locations
session.install("ruff")
session.run("ruff", *args)
@nox.session(python="3.10")
def mypy(session: nox.Session) -> None:
"""Type-check using mypy."""
session.run_always("pdm", "install", "--no-self", "--no-default", "--dev", external=True)
session.run(
"mypy",
"--install-types",
"--non-interactive",
f"--python-executable={sys.executable}",
"noxfile.py",
external=True,
)
@nox.session(python=PYTHON_VERSIONS)
def lockfile(session: nox.Session) -> None:
"""Run the test suite."""
session.run_always("pdm", "lock", external=True)
@nox.session(python=PYTHON_VERSIONS)
def tests(session: nox.Session) -> None:
"""Run the test suite."""
session.run_always("pdm", "install", "--fail-fast", "--frozen-lockfile", "--dev", external=True)
session.run(
"coverage", "run", "--parallel", "-m", "pytest", "--numprocesses", "auto", "--random-order", external=True
)
@nox.session(python=PYTHON_VERSIONS)
def coverage(session: nox.Session) -> None:
"""Produce the coverage report."""
args = session.posargs or ["report"]
session.install("coverage[toml]", "codecov", external=True)
if not session.posargs and any(Path().glob(".coverage.*")):
session.run("coverage", "combine")
session.run("coverage", "json", "--fail-under=0")
session.run("codecov", *args)
@nox.session(python=PYTHON_VERSIONS)
def docs(session: nox.Session) -> None:
"""Build and serve the documentation with live reloading on file changes."""
args = session.posargs or ["--open-browser", "docs", "docs/_build"]
session.install(".")
session.install("sphinx", "sphinx-autobuild", "sphinx-click", "sphinx-rtd-theme")
build_dir = Path("docs", "_build")
if build_dir.exists():
shutil.rmtree(build_dir)
session.run("sphinx-autobuild", *args)
@nox.session(name="docs-build", python=PYTHON_VERSIONS)
def docs_build(session: nox.Session) -> None:
"""Build the documentation."""
args = session.posargs or ["docs", "docs/_build"]
session.install(".")
session.install("sphinx", "sphinx-click", "sphinx-rtd-theme")
build_dir = Path("docs", "_build")
if build_dir.exists():
shutil.rmtree(build_dir)
session.run("sphinx-build", *args)
@nox.session(python=PYTHON_VERSIONS)
def typeguard(session: nox.Session) -> None:
"""Runtime type checking using Typeguard."""
session.install(".")
session.install("pytest", "typeguard", "pygments", "hypothesis")
session.run("pytest", f"--typeguard-packages={PACKAGE}", *session.posargs)