-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnoxfile.py
More file actions
75 lines (59 loc) · 1.92 KB
/
noxfile.py
File metadata and controls
75 lines (59 loc) · 1.92 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
from __future__ import annotations
from pathlib import Path
import nox
PACKAGE_DIR = Path("nestor")
EXCLUDED_TEST_FILE = "__main__.py"
E2E_SCRIPT_PATH = Path("tools") / "e2e_test.py"
SERVE_SMOKE_SCRIPT_PATH = Path("tools") / "serve_smoke_test.py"
nox.options.sessions = ("tests", "serve_smoke", "e2e", "black", "mypy")
def _discover_test_modules() -> list[str]:
modules = sorted(
f"{PACKAGE_DIR.name}.{path.stem}" for path in PACKAGE_DIR.glob("*.py") if path.name != EXCLUDED_TEST_FILE
)
if not modules:
raise RuntimeError(f"No Python files found under {PACKAGE_DIR}/ excluding {EXCLUDED_TEST_FILE}")
return modules
@nox.session
def tests(session: nox.Session) -> None:
session.install("coverage", "httpx", ".")
modules = _discover_test_modules()
session.run(
"coverage",
"run",
"--branch",
"--source",
PACKAGE_DIR.name,
"--omit",
"*/nestor/__main__.py",
"-m",
"unittest",
*modules,
)
session.run(
"coverage",
"report",
"-m",
"--omit",
"*/nestor/__main__.py",
"--fail-under=80",
)
@nox.session
def e2e(session: nox.Session) -> None:
session.install("httpx", ".")
if not E2E_SCRIPT_PATH.exists():
raise RuntimeError(f"E2E test script is missing: {E2E_SCRIPT_PATH}")
session.run("python", str(E2E_SCRIPT_PATH), external=True)
@nox.session
def serve_smoke(session: nox.Session) -> None:
session.install(".")
if not SERVE_SMOKE_SCRIPT_PATH.exists():
raise RuntimeError(f"Serve smoke script is missing: {SERVE_SMOKE_SCRIPT_PATH}")
session.run("python", str(SERVE_SMOKE_SCRIPT_PATH))
@nox.session
def black(session: nox.Session) -> None:
session.install("black")
session.run("black", "--check", ".")
@nox.session
def mypy(session: nox.Session) -> None:
session.install("mypy", ".")
session.run("mypy", "nestor")