-
-
Notifications
You must be signed in to change notification settings - Fork 18
/
noxfile.py
73 lines (56 loc) · 2.29 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
from __future__ import annotations
from glob import glob
from pathlib import Path
from nox import Session, session
ROOT_DIR = Path(__file__).parent
@session(tags=["test"])
def test_python(session: Session) -> None:
"""Run the Python-based test suite"""
install_requirements_file(session, "test-env")
session.install(".[all]")
session.chdir(ROOT_DIR / "tests")
session.env["REACTPY_DEBUG_MODE"] = "1"
posargs = session.posargs[:]
if "--headless" in posargs:
posargs.remove("--headless")
session.env["PLAYWRIGHT_HEADLESS"] = "1"
if "--no-debug-mode" not in posargs:
posargs.append("--debug-mode")
session.run("playwright", "install", "chromium")
# Run tests for each settings file (tests/test_app/settings_*.py)
settings_glob = "test_app/settings_*.py"
settings_files = glob(settings_glob)
assert settings_files, f"No Django settings files found at '{settings_glob}'!"
for settings_file in settings_files:
settings_module = (
settings_file.strip(".py").replace("/", ".").replace("\\", ".")
)
session.run(
"python",
"manage.py",
"test",
*posargs,
"--settings",
settings_module,
)
@session(tags=["test"])
def test_types(session: Session) -> None:
install_requirements_file(session, "check-types")
install_requirements_file(session, "pkg-deps")
session.run("mypy", "--show-error-codes", "src/reactpy_django", "tests/test_app")
@session(tags=["test"])
def test_style(session: Session) -> None:
"""Check that style guidelines are being followed"""
install_requirements_file(session, "check-style")
session.run("ruff", "check", ".")
@session(tags=["test"])
def test_javascript(session: Session) -> None:
install_requirements_file(session, "test-env")
session.chdir(ROOT_DIR / "src" / "js")
session.run("bun", "install", external=True)
session.run("bun", "run", "check", external=True)
def install_requirements_file(session: Session, name: str) -> None:
session.install("--upgrade", "pip", "setuptools", "wheel")
file_path = ROOT_DIR / "requirements" / f"{name}.txt"
assert file_path.exists(), f"requirements file {file_path} does not exist"
session.install("-r", str(file_path))