-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnoxfile.py
62 lines (48 loc) · 1.64 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
"""Nox sessions."""
from pathlib import Path
import nox
from nox.sessions import Session
project = "robolearn"
package = "robolearn"
package_path = f"{project}/{package}"
tests_path = f"{project}/tests"
# NOTE: Dev Requirements are defined in setup.py
# however we explicitly list just those needed for tests here as our
# workflow only install reqs needed for a specific session, not all dev reqs.
test_reqs = ["coverage", "pytest", "pygments"]
python_versions = ["3.9", "3.8", "3.7"]
nox.options.sessions = (
"pre-commit",
"tests",
)
@nox.session(name="pre-commit", python="3.9")
def precommit(session: Session) -> None:
"""Lint using pre-commit."""
session.install(
"black",
"flake8",
"flake8-bugbear",
"pep8-naming",
"pre-commit",
"pre-commit-hooks",
"reorder-python-imports",
)
session.run("pre-commit", "run", "--all-files", "--show-diff-on-failure")
@nox.session(python=python_versions)
def tests(session: Session) -> None:
"""Run the test suite."""
session.install(".")
session.install(*test_reqs)
session.run("pip", "install", ".[dev]")
try:
session.run("coverage", "run", "-m", "pytest", *session.posargs)
finally:
session.notify("coverage_report")
@nox.session
def coverage_report(session: Session) -> None:
"""Generate coverage report from tests output."""
session.install("coverage[toml]")
if any(Path().glob(".coverage.*")):
session.run("coverage", "combine")
session.run("coverage", "report") # show coverage report in CLI
session.run("coverage", "xml") # save report to xml for upload to codecov