-
Notifications
You must be signed in to change notification settings - Fork 0
/
noxfile.py
100 lines (74 loc) · 2.24 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
"""fakester Nox sessions."""
import os
import nox
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/"]
# fmt: off
session.install(
"--no-deps",
"-r", "requirements/main.txt",
"-r", "requirements/dev.txt",
)
# fmt: on
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."""
# fmt: off
session.install(
"--no-deps",
"-r", "requirements/dev.txt",
)
# fmt: on
session.run("mkdocs", "build", "--strict")
@nox.session()
def code_style_checks(session: nox.Session) -> None:
"""Check code style."""
dirs = session.posargs or DEFAULT_PATHS
# fmt: off
session.install(
"black", "isort", "ruff", "interrogate",
"-c", "requirements/constraints.txt",
)
# fmt: on
session.run("black", "--check", "--diff", *dirs)
session.run("isort", "--check", "--diff", *dirs)
session.run("ruff", "check", "--diff", *dirs)
session.run("interrogate", *dirs)
@nox.session()
def type_checks(session: nox.Session) -> None:
"""Run type checks."""
dirs = session.posargs or DEFAULT_PATHS
# fmt: off
session.install(
"--no-deps",
"-r", "requirements/main.txt",
"-r", "requirements/dev.txt",
)
# fmt: on
session.run("mypy", *dirs)
@nox.session()
def django_checks(session: nox.Session) -> None:
"""Run Django checks."""
# fmt: off
session.install(
"--no-deps",
"-r", "requirements/main.txt",
)
# fmt: on
session.run("src/manage.py", "check", external=True)
session.run("src/manage.py", "makemigrations", "--check", external=True)