-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnoxfile.py
More file actions
115 lines (89 loc) · 2.68 KB
/
Copy pathnoxfile.py
File metadata and controls
115 lines (89 loc) · 2.68 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
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
106
107
108
109
110
111
112
113
114
115
"""fakester Nox sessions."""
import os
import nox
nox.options.default_venv_backend = "uv"
nox.options.reuse_existing_virtualenvs = True
nox.options.error_on_external_run = True
DEFAULT_PATHS = ["src/", "tests/", "noxfile.py"]
@nox.session()
def tests(session: nox.Session) -> None:
"""Run tests."""
dirs = session.posargs or ["tests/"]
session.run_install(
"uv",
"sync",
"--frozen",
"--no-dev",
"--group",
"tests",
env={"UV_PROJECT_ENVIRONMENT": session.virtualenv.location},
)
session.run("coverage", "run", "-m", "pytest", *dirs)
if os.environ.get("CI") != "true":
session.notify("coverage_report")
@nox.session()
def coverage_report(session: nox.Session) -> None:
"""Report coverage. Can only be run after `tests` session."""
session.install("coverage[toml]")
session.run("coverage", "combine")
session.run("coverage", "xml")
session.run("coverage", "report")
@nox.session()
def docs(session: nox.Session) -> None:
"""Build docs."""
session.run_install(
"uv",
"sync",
"--frozen",
"--only-group",
"docs",
env={"UV_PROJECT_ENVIRONMENT": session.virtualenv.location},
)
session.run("mkdocs", "build", "--strict")
@nox.session(tags=["check"])
def code_style_checks(session: nox.Session) -> None:
"""Check code style."""
dirs = session.posargs or DEFAULT_PATHS
session.run_install(
"uv",
"sync",
"--frozen",
"--only-group",
"lint",
env={"UV_PROJECT_ENVIRONMENT": session.virtualenv.location},
)
session.run("black", "--check", "--diff", *dirs)
session.run("isort", "--check", "--diff", *dirs)
session.run("ruff", "check", "--diff", *dirs)
session.run("interrogate", *dirs)
session.run("yamllint", ".")
@nox.session(tags=["check"])
def type_checks(session: nox.Session) -> None:
"""Run type checks."""
dirs = session.posargs or DEFAULT_PATHS
session.run_install(
"uv",
"sync",
"--frozen",
"--no-dev",
"--group",
"typing",
"--group",
"tests",
"--group",
"nox",
env={"UV_PROJECT_ENVIRONMENT": session.virtualenv.location},
)
session.run("mypy", *dirs)
@nox.session(tags=["check"])
def django_checks(session: nox.Session) -> None:
"""Run Django checks."""
session.run_install(
"uv",
"sync",
"--frozen",
"--no-dev",
env={"UV_PROJECT_ENVIRONMENT": session.virtualenv.location},
)
session.run("src/manage.py", "check", external=True)
session.run("src/manage.py", "makemigrations", "--check", external=True)