-
Notifications
You must be signed in to change notification settings - Fork 4
/
noxfile.py
86 lines (67 loc) · 2.09 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
# Standard Library
import os
import sys
from pathlib import Path
# Third Party Library
import nox
sys.path.insert(0, "")
# First Party Library
from jsonpath_build import build_lark_parser # noqa: E402
nox.options.stop_on_first_error = True
pythons = ["3.10", "3.11", "3.12", "3.13"]
os.environ.update({"PDM_IGNORE_SAVED_PYTHON": "1"})
os.environ.pop("PYTHONPATH", None)
lark_parser_path = Path("jsonpath/lark_parser.py")
def get_nox_session_pybin(session):
return session.bin + "/python"
@nox.session(python=pythons, venv_backend="venv")
@nox.parametrize(
"parser_backend",
[
"standalone",
"parser",
],
)
def coverage_test(session, parser_backend):
session.run(
"pdm",
"sync",
"--no-editable",
"-v",
"-G",
"test",
"-G",
"parser",
external=True,
)
if parser_backend == "standalone":
if not lark_parser_path.exists():
pybin_path = get_nox_session_pybin(session)
build_lark_parser(pybin_path)
session.run("python", "-m", "pip", "uninstall", "lark", "-y")
else:
if lark_parser_path.exists():
lark_parser_path.unlink()
session.run("pytest", "-vv", "--cov=jsonpath", "--cov-append", *session.posargs)
@nox.session(python=pythons, venv_backend="venv")
def coverage_report(session):
session.run("pdm", "sync", "--no-editable", "-v", "-G", "test", external=True)
session.run("coverage", "report")
session.run("coverage", "xml")
session.run("coverage", "html")
session.log(
f">> open file:/{(Path() / 'htmlcov/index.html').absolute()} to see coverage"
)
@nox.session(venv_backend="venv")
def build(session):
if not lark_parser_path.exists():
build_lark_parser()
session.run("pdm", "build", external=True)
@nox.session(python=pythons[-1:], venv_backend="venv")
def build_readme(session):
session.run(
"pdm", "sync", "--no-editable", "-v", "-G", "build_readme", external=True
)
session.run(
"python", "scripts/build_readme.py", "README.template.rst", "README.rst"
)