1
|
|
|
"""Nox tool configuration file. |
2
|
|
|
|
3
|
|
|
Nox is Tox tool replacement. |
4
|
|
|
""" |
5
|
|
|
import nox |
6
|
|
|
|
7
|
|
|
nox.options.keywords = "not docs" |
8
|
|
|
|
9
|
|
|
|
10
|
|
|
def base_install(session): |
11
|
|
|
"""Create basic environment setup for tests and linting.""" |
12
|
|
|
session.install("-r", "test_requirements.txt") |
13
|
|
|
session.install("-e", ".") |
14
|
|
|
return session |
15
|
|
|
|
16
|
|
|
|
17
|
|
|
@nox.session(python="3.10") |
18
|
|
|
def lint(session): |
19
|
|
|
"""Run linting check locally.""" |
20
|
|
|
session = base_install(session) |
21
|
|
|
session.run("pre-commit", "run", "-a") |
22
|
|
|
|
23
|
|
|
|
24
|
|
|
@nox.session(python=["3.7", "3.8", "3.9", "3.10"]) |
25
|
|
|
def tests(session): |
26
|
|
|
"""Run test suite with pytest.""" |
27
|
|
|
session = base_install(session) |
28
|
|
|
session.run( |
29
|
|
|
"pytest", |
30
|
|
|
"--cov-report=html", |
31
|
|
|
"--cov-report=xml", |
32
|
|
|
"--cov-branch", |
33
|
|
|
"--cov-fail-under=100", |
34
|
|
|
) |
35
|
|
|
|
36
|
|
|
|
37
|
|
|
@nox.session(python=["3.7", "3.8", "3.9", "3.10"]) |
38
|
|
|
def safety_tests(session): |
39
|
|
|
"""Run safety tests.""" |
40
|
|
|
session = base_install(session) |
41
|
|
|
session.run("safety", "check", "--full-report") |
42
|
|
|
|
43
|
|
|
|
44
|
|
|
@nox.session(python="3.10") |
45
|
|
|
def documentation_tests(session): |
46
|
|
|
"""Run documentation tests.""" |
47
|
|
|
return docs(session, batch_run=True) |
48
|
|
|
|
49
|
|
|
|
50
|
|
|
@nox.session(python="3.10") |
51
|
|
|
def docs(session, batch_run: bool = False): |
52
|
|
|
"""Build the documentation or serve documentation interactively.""" |
53
|
|
|
session.run("rm", "-rf", "docs/_build", external=True) |
54
|
|
|
session.install("-r", "docs/requirements.txt") |
55
|
|
|
session.install(".") |
56
|
|
|
session.cd("docs") |
57
|
|
|
sphinx_args = ["-b", "html", "-W", ".", "_build/html"] |
58
|
|
|
|
59
|
|
|
if not session.interactive or batch_run: |
60
|
|
|
sphinx_cmd = "sphinx-build" |
61
|
|
|
else: |
62
|
|
|
sphinx_cmd = "sphinx-autobuild" |
63
|
|
|
sphinx_args.extend( |
64
|
|
|
[ |
65
|
|
|
"--open-browser", |
66
|
|
|
"--port", |
67
|
|
|
"9812", |
68
|
|
|
"--watch", |
69
|
|
|
"../cookiecutter", |
70
|
|
|
] |
71
|
|
|
) |
72
|
|
|
|
73
|
|
|
session.run(sphinx_cmd, *sphinx_args) |
74
|
|
|
|