-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathnoxfile.py
79 lines (68 loc) · 2.11 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
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]", silent=False)
if PYBOP_SCHEDULED:
session.run("pip", "install", f"pybamm=={PYBAMM_VERSION}", silent=False)
session.install("pytest", "pytest-mock", silent=False)
session.run("pytest", "--unit")
@nox.session
def coverage(session):
session.install("-e", ".[all]", silent=False)
if PYBOP_SCHEDULED:
session.run("pip", "install", f"pybamm=={PYBAMM_VERSION}", silent=False)
session.install("pytest", "pytest-cov", "pytest-mock", silent=False)
session.run(
"pytest",
"--unit",
"--examples",
"--cov",
"--cov-report=xml",
)
@nox.session
def notebooks(session):
"""Run the examples tests for Jupyter notebooks."""
session.install("-e", ".[all]", silent=False)
if PYBOP_SCHEDULED:
session.run("pip", "install", f"pybamm=={PYBAMM_VERSION}", silent=False)
session.install("pytest", "nbmake", silent=False)
session.run("pytest", "--nbmake", "--examples", "examples/", 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",
)