-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnoxfile.py
70 lines (55 loc) · 1.91 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
"""Developer task automation."""
import nox
nox.options.default_venv_backend = "uv"
nox.options.sessions = [
"check_code_formatting",
"check_types",
"test_docs_build",
"run_tests",
]
PYTHON = "3.12"
@nox.session(python=PYTHON)
def run_tests(session: nox.Session):
"""Run unit tests."""
session.run_install(
"uv",
"sync",
env={
"UV_PROJECT_ENVIRONMENT": session.virtualenv.location,
"UV_LINK_MODE": "copy",
},
)
pytest_args = session.posargs if session.posargs else []
session.run("pytest", *pytest_args)
@nox.session(python=None)
def format_code(session: nox.Session):
"""Lint code and re-format where necessary."""
session.run("black", "--config=pyproject.toml", ".", external=True)
session.run("ruff", "check", ".", "--config=pyproject.toml", "--fix", external=True)
@nox.session(python=None)
def check_code_formatting(session: nox.Session):
"""Check code for formatting errors."""
session.run("black", "--config=pyproject.toml", "--check", ".", external=True)
session.run("ruff", "check", ".", "--config=pyproject.toml", external=True)
@nox.session(python=None)
def check_types(session: nox.Session):
"""Run static type checking."""
session.run("mypy", "src", "tests", "noxfile.py", external=True)
@nox.session(python=False)
def test_docs_build(session: nox.Session):
"""Ensure docs can be built."""
session.run("mkdocs", "build")
session.run("rm", "-rf", "docs_build", external=True)
@nox.session(python=PYTHON, reuse_venv=True)
def build_and_deploy_docs(session: nox.Session):
"""Deploy docs to GitHub Pages."""
session.run_install(
"uv",
"sync",
env={
"UV_PROJECT_ENVIRONMENT": session.virtualenv.location,
"UV_LINK_MODE": "copy",
},
)
session.run("mkdocs", "gh-deploy")
session.run("rm", "-rf", "docs_build", external=True)