-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathnoxfile.py
93 lines (78 loc) · 2.39 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
87
88
89
90
91
92
93
import os
import nox
# nox options
nox.options.reuse_existing_virtualenvs = True
nox.options.venv_backend = "virtualenv"
# Environment variables to control CI behaviour for nox sessions
PYBOP_SCHEDULED = int(os.environ.get("PYBOP_SCHEDULED", 0))
PYBAMM_VERSION = os.environ.get("PYBAMM_VERSION", None)
@nox.session
def unit(session):
session.install("-e", ".[all,dev]", silent=False)
if PYBOP_SCHEDULED:
session.run("pip", "install", f"pybamm=={PYBAMM_VERSION}", silent=False)
session.run("pytest", "--unit", "-n", "auto")
@nox.session
def coverage(session):
session.install("-e", ".[all,dev]", silent=False)
if PYBOP_SCHEDULED:
session.run("pip", "install", f"pybamm=={PYBAMM_VERSION}", silent=False)
session.run(
"pytest",
"--unit",
"--integration",
"--plots",
"--cov",
"--cov-report=xml",
)
@nox.session
def integration(session):
session.run_always("pip", "install", "-e", ".[all,dev]")
session.install("pytest", "pytest-mock")
session.run("pytest", "--integration", "-n", "auto")
@nox.session
def examples(session):
session.run_always("pip", "install", "-e", ".[all,dev]")
session.install("pytest", "pytest-mock")
session.run("pytest", "--examples", "-n", "auto")
@nox.session
def notebooks(session):
"""Run the examples tests for Jupyter notebooks."""
session.install("-e", ".[all,dev]", silent=False)
if PYBOP_SCHEDULED:
session.run("pip", "install", f"pybamm=={PYBAMM_VERSION}", silent=False)
session.run(
"pytest", "--notebooks", "--nbmake", "examples/", "-n", "auto", external=True
)
@nox.session
def docs(session):
"""
Build the documentation and load it in a browser tab, rebuilding on changes.
Credit: PyBaMM Team
"""
envbindir = session.bin
session.install("-e", ".[all,docs]", silent=False)
session.chdir("docs")
# Local development
if session.interactive:
session.run(
"sphinx-autobuild",
"-j",
"auto",
"--open-browser",
"-qT",
".",
f"{envbindir}/../tmp/html",
)
# Runs in CI only, treating warnings as errors
else:
session.run(
"sphinx-build",
"-j",
"auto",
"-b",
"html",
"--keep-going",
".",
"_build/html",
)