| 1 |
"""Development automation |
| 2 |
""" |
| 3 |
|
| 4 |
import os |
| 5 |
|
| 6 |
import nox |
| 7 |
|
| 8 |
nox.options.sessions = ["lint", "test", "doctest"] |
| 9 |
nox.options.reuse_existing_virtualenvs = True |
| 10 |
|
| 11 |
|
| 12 |
@nox.session(python="3.12") |
| 13 |
def lint(session): |
| 14 |
session.install("pre-commit") |
| 15 |
|
| 16 |
if session.posargs: |
| 17 |
args = session.posargs |
| 18 |
elif "CI" in os.environ: |
| 19 |
args = ["--show-diff-on-failure"] |
| 20 |
else: |
| 21 |
args = [] |
| 22 |
|
| 23 |
session.run("pre-commit", "run", "--all-files", *args) |
| 24 |
|
| 25 |
|
| 26 |
@nox.session(python=["3.10", "3.11", "3.12", "3.13", "3.14", "pypy3"]) |
| 27 |
def test(session): |
| 28 |
session.install(".") |
| 29 |
session.install("-r", "tests/requirements.txt") |
| 30 |
|
| 31 |
htmlcov_output = os.path.join(session.virtualenv.location, "htmlcov") |
| 32 |
|
| 33 |
session.run( |
| 34 |
"pytest", |
| 35 |
"--cov=installer", |
| 36 |
"--cov-fail-under=100", |
| 37 |
"--cov-report=term-missing", |
| 38 |
f"--cov-report=html:{htmlcov_output}", |
| 39 |
"--cov-context=test", |
| 40 |
"-n", |
| 41 |
"auto", |
| 42 |
*session.posargs, |
| 43 |
) |
| 44 |
|
| 45 |
|
| 46 |
@nox.session(python=["3.10", "3.11", "3.12", "3.13", "3.14", "pypy3"]) |
| 47 |
def doctest(session): |
| 48 |
session.install(".") |
| 49 |
session.install("-r", "docs/requirements.txt") |
| 50 |
|
| 51 |
session.run("sphinx-build", "-b", "doctest", "docs/", "build/doctest") |
| 52 |
|
| 53 |
|
| 54 |
@nox.session(python="3.12", name="update-launchers") |
| 55 |
def update_launchers(session): |
| 56 |
session.install("httpx") |
| 57 |
session.run("python", "tools/update_launchers.py") |
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
@nox.session(python="3.12") |
| 64 |
def docs(session): |
| 65 |
session.install(".") |
| 66 |
session.install("-r", "docs/requirements.txt") |
| 67 |
|
| 68 |
|
| 69 |
session.run("sphinx-build", "-W", "-b", "html", "docs/", "build/docs") |
| 70 |
|
| 71 |
|
| 72 |
@nox.session(name="docs-live", python="3.12") |
| 73 |
def docs_live(session): |
| 74 |
session.install("-e", ".") |
| 75 |
session.install("-r", "docs/requirements.txt") |
| 76 |
session.install("sphinx-autobuild") |
| 77 |
|
| 78 |
|
| 79 |
session.run( |
| 80 |
"sphinx-autobuild", "docs/", "build/docs", |
| 81 |
|
| 82 |
"-a", |
| 83 |
|
| 84 |
"--watch", "src/installer", |
| 85 |
|
| 86 |
"--port", "8765", |
| 87 |
) |
| 88 |
|