-
Notifications
You must be signed in to change notification settings - Fork 1
/
noxfile.py
66 lines (47 loc) · 1.67 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
from pathlib import Path
from nox import Session, parametrize, session
ROOT = Path(".")
REQUIREMENTS_DIR = ROOT / "requirements"
@session
def format(session: Session) -> None:
install_requirements(session, "style")
session.run("black", ".")
session.run("isort", ".")
@session
def test(session: Session) -> None:
session.notify("test_style")
session.notify("test_types")
session.notify("test_coverage")
session.notify("test_suite")
@session
def test_style(session: Session) -> None:
install_requirements(session, "style")
session.run("black", "--check", ".")
session.run("isort", "--check", ".")
session.run("flake8", ".")
@session
def test_types(session: Session) -> None:
install_requirements(session, "types")
session.run("mypy", "--strict", "reactpy_flake8")
@session
@parametrize("flake8_version", ["3", "4", "5", "6"])
def test_suite(session: Session, flake8_version: str) -> None:
install_requirements(session, "test-env")
session.install(f"flake8=={flake8_version}.*")
session.install(".")
session.run("pytest", "tests")
@session
def test_coverage(session: Session) -> None:
install_requirements(session, "test-env")
session.install("-e", ".")
posargs = session.posargs[:]
if "--no-cov" in session.posargs:
posargs.remove("--no-cov")
session.log("Coverage won't be checked")
session.install(".")
else:
posargs += ["--cov=reactpy_flake8", "--cov-report=term"]
session.install("-e", ".")
session.run("pytest", "tests", *posargs)
def install_requirements(session: Session, name: str) -> None:
session.install("-r", str(REQUIREMENTS_DIR / f"{name}.txt"))