forked from mozilla/sphinx-js
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathnoxfile.py
79 lines (70 loc) · 2.58 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
from pathlib import Path
from textwrap import dedent
import nox
from nox.sessions import Session
PROJECT_ROOT = Path(__file__).parent
@nox.session(python=["3.10", "3.11", "3.12", "3.13"])
def tests(session: Session) -> None:
session.install("-r", "requirements_dev.txt")
venvroot = Path(session.bin).parent
(venvroot / "node_modules").mkdir()
with session.chdir(venvroot):
session.run(
"npm", "i", "--no-save", "[email protected]", "[email protected]", external=True
)
session.run(
"pytest",
"--junitxml=test-results.xml",
"--cov=sphinx_js",
"--cov-report",
"xml",
)
@nox.session(python=["3.12"])
@nox.parametrize("typedoc", ["0.25", "0.26", "0.27"])
def test_typedoc(session: Session, typedoc: str) -> None:
# Install python dependencies
session.install("-r", "requirements_dev.txt")
venvroot = Path(session.bin).parent
node_modules = (venvroot / "node_modules").resolve()
node_modules.mkdir()
with session.chdir(venvroot):
# Install node dependencies
session.run(
"npm",
"i",
"--no-save",
"tsx",
f"typedoc@{typedoc}",
external=True,
)
session.run("npx", "tsc", "--version", external=True)
session.run("npx", "typedoc", "--version", external=True)
# Run typescript tests
test_file = (PROJECT_ROOT / "tests/test.ts").resolve()
register_import_hook = PROJECT_ROOT / "sphinx_js/js/registerImportHook.mjs"
ts_tests = Path(venvroot / "ts_tests")
# Write script to a file so that it is easy to rerun without reinstalling dependencies.
ts_tests.write_text(
dedent(
f"""\
#!/bin/sh
TYPEDOC_NODE_MODULES={venvroot} node --import {register_import_hook} --import {node_modules/"tsx/dist/loader.mjs"} --test {test_file}
"""
)
)
ts_tests.chmod(0o777)
session.run(ts_tests, external=True)
# Run Python tests
session.run("pytest", "--junitxml=test-results.xml", "-k", "not js")
@nox.session(python=["3.12"])
def test_sphinx_6(session: Session) -> None:
session.install("sphinx<7")
session.install("-r", "requirements_dev.txt")
venvroot = Path(session.bin).parent
(venvroot / "node_modules").mkdir()
with session.chdir(venvroot):
session.run(
"npm", "i", "--no-save", "[email protected]", "[email protected]", external=True
)
session.run("pytest", "--junitxml=test-results.xml", "-k", "not js")