forked from omry/omegaconf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
noxfile.py
75 lines (57 loc) · 2.45 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
# type: ignore
import os
import nox
DEFAULT_PYTHON_VERSIONS = ["3.6", "3.7", "3.8", "3.9"]
PYTHON_VERSIONS = os.environ.get(
"NOX_PYTHON_VERSIONS", ",".join(DEFAULT_PYTHON_VERSIONS)
).split(",")
def deps(session, editable_installl):
session.install("--upgrade", "setuptools", "pip")
extra_flags = ["-e"] if editable_installl else []
session.install("-r", "requirements/dev.txt", *extra_flags, ".", silent=True)
@nox.session(python=PYTHON_VERSIONS)
def omegaconf(session):
deps(session, editable_installl=False) # ensure we test the regular install
session.run("pytest")
@nox.session(python=PYTHON_VERSIONS)
def benchmark(session):
deps(session, editable_installl=True)
session.run("pytest", "benchmark/benchmark.py")
@nox.session
def docs(session):
deps(session, editable_installl=True)
session.chdir("docs")
session.run("sphinx-build", "-W", "-b", "doctest", "source", "build")
session.run("sphinx-build", "-W", "-b", "html", "source", "build")
@nox.session(python=PYTHON_VERSIONS)
def coverage(session):
# For coverage, we must use the editable installation because
# `coverage run -m pytest` prepends `sys.path` with "." (the current
# folder), so that the local code will be used in tests even if we set
# `editable_installl=False`. This would cause problems due to potentially
# missing the generated grammar files.
deps(session, editable_installl=True)
session.run("coverage", "erase")
session.run("coverage", "run", "--append", "-m", "pytest", silent=True)
session.run("coverage", "report", "--fail-under=100")
# report to coveralls
session.run("coveralls", success_codes=[0, 1])
session.run("coverage", "erase")
@nox.session(python=PYTHON_VERSIONS)
def lint(session):
deps(session, editable_installl=True)
session.run("mypy", ".", "--strict", silent=True)
session.run("isort", ".", "--check", silent=True)
session.run("black", "--check", ".", silent=True)
session.run("flake8")
@nox.session(python=PYTHON_VERSIONS)
def test_jupyter_notebook(session):
if session.python not in DEFAULT_PYTHON_VERSIONS:
session.skip(
"Not testing Jupyter notebook on Python {}, supports [{}]".format(
session.python, ",".join(DEFAULT_PYTHON_VERSIONS)
)
)
deps(session, editable_installl=False)
session.install("jupyter", "nbval")
session.run("pytest", "--nbval", "docs/notebook/Tutorial.ipynb", silent=True)