-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
noxfile.py
96 lines (75 loc) · 2.16 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
from pathlib import Path
from tempfile import TemporaryDirectory
import nox
ROOT = Path(__file__).parent
PYPROJECT = ROOT / "pyproject.toml"
DOCS = ROOT / "docs"
PACKAGE = ROOT / "sphinx_json_schema_spec"
nox.options.sessions = []
def session(default=True, **kwargs):
def _session(fn):
if default:
nox.options.sessions.append(kwargs.get("name", fn.__name__))
return nox.session(**kwargs)(fn)
return _session
@session(python=["3.8", "3.9", "3.10", "3.11", "pypy3"])
def tests(session):
session.install("pytest", ROOT)
session.run("pytest", *session.posargs, PACKAGE)
@session()
def audit(session):
session.install("pip-audit", ROOT)
session.run("python", "-m", "pip_audit")
@session(tags=["build"])
def build(session):
session.install("build", "twine")
with TemporaryDirectory() as tmpdir:
session.run("python", "-m", "build", ROOT, "--outdir", tmpdir)
session.run("twine", "check", "--strict", tmpdir + "/*")
@session(tags=["style"])
def style(session):
session.install("ruff")
session.run("ruff", "check", ROOT)
@session()
def typing(session):
session.install("mypy", "types-docutils", "types-lxml", ROOT)
session.run("python", "-m", "mypy", PACKAGE)
@session(tags=["docs"])
@nox.parametrize(
"builder",
[
nox.param(name, id=name)
for name in [
"dirhtml",
"doctest",
"linkcheck",
"man",
"spelling",
]
],
)
def docs(session, builder):
session.install("-r", DOCS / "requirements.txt")
with TemporaryDirectory() as tmpdir_str:
tmpdir = Path(tmpdir_str)
argv = ["-n", "-T", "-W"]
if builder != "spelling":
argv += ["-q"]
session.run(
"python",
"-m",
"sphinx",
"-b",
builder,
DOCS,
tmpdir / builder,
*argv,
)
@session(tags=["docs", "style"], name="docs(style)")
def docs_style(session):
session.install(
"doc8",
"pygments",
"pygments-github-lexers",
)
session.run("python", "-m", "doc8", "--config", PYPROJECT, DOCS)