-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathnoxfile.py
65 lines (48 loc) · 1.56 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
import sys
import nox
PYTHON_VERSIONS = ["3.10", "3.11", "3.12"]
nox.options.reuse_existing_virtualenvs = True
# nox.options.default_venv_backend = "venv"
# Don't run 'update-deps' by default.
nox.options.sessions = [
"lint",
"pytest",
"doc",
]
SUB_REPOS = [
"nua-lib",
"nua-cli",
"nua-agent",
"nua-build",
"nua-orchestrator",
]
PLATFORM_RESTRICT = {"linux": {"nua-orchestrator"}}
@nox.session(python=PYTHON_VERSIONS)
@nox.parametrize("sub_repo", SUB_REPOS)
def pytest(session: nox.Session, sub_repo: str):
for platform, restricted in PLATFORM_RESTRICT.items():
if sys.platform != platform and sub_repo in restricted:
session.skip(f"{restricted} only runs on {platform}")
run_subsession(session, sub_repo)
@nox.session
@nox.parametrize("sub_repo", SUB_REPOS)
def lint(session: nox.Session, sub_repo: str):
# session.install("ruff")
# session.run("ruff", ".")
run_subsession(session, sub_repo)
@nox.session
def doc(session: nox.Session):
print("TODO: do something with the docs")
@nox.session(name="update-deps")
def update_deps(session: nox.Session):
for sub_repo in SUB_REPOS:
with session.chdir(sub_repo):
session.run("poetry", "install", external=True)
session.run("poetry", "update", external=True)
print()
def run_subsession(session, sub_repo):
name = session.name.split("(")[0]
print(f"\nRunning session: {session.name} in subrepo: {sub_repo}\n")
with session.chdir(sub_repo):
session.run("nox", "-e", name, external=True)
print()