-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnoxfile.py
103 lines (84 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
94
95
96
97
98
99
100
101
102
103
"""
Nox automation tasks for pyrrhic
"""
import os
from pathlib import Path
import nox
# GitHub Actions
ON_CI = bool(os.getenv("CI"))
# Git info
DEFAULT_BRANCH = "master"
# Python to use for non-test sessions
DEFAULT_PYTHON: str = "3.10"
# Global project stuff
PROJECT_ROOT = Path(__file__).parent.resolve()
SOURCE_FILES = (
"noxfile.py",
"pyrrhic",
"test",
)
@nox.session(python=DEFAULT_PYTHON)
def dev(session: nox.Session) -> None:
"""
Sets up a python dev environment for the project if one doesn't already exist.
"""
session.run("python", "-m", "venv", os.path.join(PROJECT_ROOT, ".venv"))
session.run(
"flit",
"install",
"--symlink",
"--python",
os.path.join(PROJECT_ROOT, ".venv", "bin", "python"),
external=True,
silent=True,
)
@nox.session(python=["3.10"])
def test(session: nox.Session) -> None:
"""
Runs the test suite.
"""
session.install(
".",
"pytest",
"pytest-cov",
"flake8",
)
session.run("flake8", *SOURCE_FILES)
session.run("pytest", "-v", "-v", "--cov=pyrrhic", "--cov-branch")
@nox.session(python=DEFAULT_PYTHON)
def coverage(session: nox.Session):
"""Upload coverage data."""
session.install("coverage[toml]", "codecov")
session.run("coverage", "xml", "--fail-under=0")
session.run("codecov", *session.posargs)
@nox.session(python=DEFAULT_PYTHON)
def mypy(session: nox.Session) -> None:
"""Type-check using mypy."""
args = session.posargs or ["pyrrhic", "test"]
session.install("mypy")
session.run("mypy", "--ignore-missing-imports", "--show-error-codes", *args)
@nox.session(python=DEFAULT_PYTHON)
def lint(session: nox.Session) -> None:
"""Lint using flake8."""
args = session.posargs or ["pyrrhic", "test"]
session.install(
"flake8",
"flake8-black",
"flake8-import-order",
)
session.run("flake8", *args)
@nox.session(python=DEFAULT_PYTHON)
def sphinx(session: nox.Session) -> None:
"""Generate Sphinx documentation from source files."""
session.install(".", "sphinx")
session.run(
"sphinx-apidoc",
"--force",
"--implicit-namespaces",
"--module-first",
"--separate",
"-o",
"docs/reference/",
"pyrrhic",
)
session.run("sphinx-build", "-W", "--keep-going", "-b", "html", "docs/", "docs/_build/")