forked from IABTechLab/fideslang
-
Notifications
You must be signed in to change notification settings - Fork 0
/
noxfile.py
90 lines (70 loc) · 2.31 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
import nox
nox.options.sessions = []
nox.options.reuse_existing_virtualenvs = True
# These should match what is in the `pr_checks.yml` file for CI runs
TESTED_PYTHON_VERSIONS = ["3.9", "3.10", "3.11"]
TESTED_PYDANTIC_VERSIONS = ["2.3.0", "2.4.2", "2.5.3", "2.6.4", "2.7.1"]
TESTED_PYYAML_VERSIONS = ["5.4.1", "6.0.1"]
def install_requirements(session: nox.Session) -> None:
session.install("-r", "requirements.txt")
session.install("-r", "dev-requirements.txt")
@nox.session(python=TESTED_PYTHON_VERSIONS)
@nox.parametrize("pydantic_version", TESTED_PYDANTIC_VERSIONS)
@nox.parametrize("pyyaml_version", TESTED_PYYAML_VERSIONS)
def tests(session: nox.Session, pydantic_version: str, pyyaml_version: str) -> None:
install_requirements(session)
session.install(".")
session.install(f"pydantic=={pydantic_version}")
session.install(f"pyyaml=={pyyaml_version}")
if session.posargs:
test_args = session.posargs
else:
test_args = [""]
session.run("pytest", *test_args)
@nox.session()
def pytest(session: nox.Session) -> None:
"""Runs the pytest suite with default versions."""
install_requirements(session)
session.install(".")
session.run("pytest")
@nox.session()
def black(session: nox.Session) -> None:
install_requirements(session)
session.run("black", "--check", "src/")
@nox.session()
def mypy(session: nox.Session) -> None:
install_requirements(session)
session.run("mypy")
@nox.session()
def pylint(session: nox.Session) -> None:
install_requirements(session)
session.run("pylint", "--jobs", "0", "src/")
@nox.session()
def xenon(session: nox.Session) -> None:
install_requirements(session)
session.run(
"xenon",
"src",
"--max-absolute",
"B",
"--max-modules",
"B",
"--max-average",
"A",
"--ignore",
"data,tests,docs",
"--exclude",
"src/fideslang/_version.py",
)
@nox.session()
def static_checks(session: nox.Session) -> None:
"""Run the static checks."""
session.notify("black")
session.notify("xenon")
session.notify("pylint")
session.notify("mypy")
@nox.session()
def check_all(session: nox.Session) -> None:
"""Run static checks as well as tests."""
session.notify("static_checks")
session.notify("tests")