-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnoxfile.py
63 lines (49 loc) · 1.63 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
"""Nox sessions."""
from pathlib import Path
from typing import no_type_check
import nox
_package = "banquo"
_python_versions = ["3.11"]
nox.options.sessions = (
"safety",
"typeguard",
"tests",
"docs",
)
@no_type_check
@nox.session(python=_python_versions)
def safety(session: nox.Session) -> None:
"""Scan dependencies for insecure packages."""
session.install(".[test]")
session.run("safety", "scan", "--full-report")
@no_type_check
@nox.session(python=_python_versions)
def typeguard(session: nox.Session) -> None:
"""Runtime type checking using Typeguard."""
session.install(".[test]")
session.run("pytest", f"--typeguard-_packages={_package}", *session.posargs)
@no_type_check
@nox.session(python=_python_versions)
def tests(session: nox.Session) -> None:
"""Run the test and xdoctest suites."""
session.install(".[test]")
session.run(
"pytest", "--cov=banquo", "--cov-report=xml", "--xdoctest", *session.posargs
)
@no_type_check
@nox.session
def docs(session: nox.Session) -> None:
"""Build documentation."""
with open(Path("docs/requirements.txt")) as f:
requirements = f.read().splitlines()
session.install(".[docs]")
session.install(*requirements)
session.chdir("docs")
session.run("rm", "-rf", "_build/", external=True)
build_dir = Path("docs", "_build", "html")
if "serve" in session.posargs:
sphinx_args = ["-W", ".", "--watch", ".", "--open-browser", str(build_dir)]
session.run("sphinx-autobuild", *sphinx_args)
else:
sphinx_args = ["-W", ".", str(build_dir)]
session.run("sphinx-build", *sphinx_args)