-
Notifications
You must be signed in to change notification settings - Fork 81
Expand file tree
/
Copy pathnoxfile.py
More file actions
91 lines (79 loc) · 2.84 KB
/
noxfile.py
File metadata and controls
91 lines (79 loc) · 2.84 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
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", "3.14"])
def tests(session: Session) -> None:
session.install(".[test]")
venvroot = Path(session.bin).parent
(venvroot / "node_modules").mkdir()
with session.chdir(venvroot):
session.run(
"npm", "i", "--no-save", "jsdoc@4.0.0", "typedoc@0.25", external=True
)
session.run(
"pytest",
"--junitxml=test-results.xml",
"--cov=sphinx_js",
"--cov-report",
"xml",
)
def typecheck_ts(session: Session, typedoc: str) -> None:
if typedoc == "0.26":
# Upstream type errors here =(
return
# Typecheck
with session.chdir("sphinx_js/js"):
session.run("npm", "i", f"typedoc@{typedoc}", external=True)
session.run("npm", "i", external=True)
session.run("npx", "tsc", external=True)
@nox.session(python=["3.12"])
@nox.parametrize("typedoc", ["0.25", "0.26", "0.27", "0.28"])
def test_typedoc(session: Session, typedoc: str) -> None:
typecheck_ts(session, typedoc)
# Install python dependencies
session.install(".[test]")
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",
"jsdoc@4.0.0",
f"typedoc@{typedoc}",
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
npx typedoc --version
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(".[test]")
venvroot = Path(session.bin).parent
(venvroot / "node_modules").mkdir()
with session.chdir(venvroot):
session.run(
"npm", "i", "--no-save", "jsdoc@4.0.0", "typedoc@0.25", external=True
)
session.run("pytest", "--junitxml=test-results.xml", "-k", "not js")