viv/noxfile.py

62 lines
1.3 KiB
Python
Raw Normal View History

2023-08-22 13:45:23 -05:00
#!/usr/bin/env python3
import os
import shutil
2023-08-22 13:45:23 -05:00
from pathlib import Path
import nox
2023-08-24 10:24:58 -05:00
nox.options.sessions = ["lint", "typecheck"]
2023-08-22 13:45:23 -05:00
nox.options.reuse_existing_virtualenvs = True
os.environ.update({"PDM_IGNORE_SAVED_PYTHON": "1"})
2023-08-22 21:34:27 -05:00
def pdm_install(session, group):
2023-08-22 13:45:23 -05:00
session.run_always("pdm", "install", "-G", group, external=True, silent=True)
@nox.session
def lint(session):
2023-08-22 21:34:27 -05:00
pdm_install(session, "dev")
2023-08-22 13:45:23 -05:00
session.run("pre-commit", "run")
@nox.session
def typecheck(session):
pdm_install(session, "dev")
2023-08-22 13:45:23 -05:00
session.run("mypy", "src/")
2023-08-22 21:34:27 -05:00
2023-08-22 13:45:23 -05:00
@nox.session
def svgs(session):
pdm_install(session, "docs")
2023-08-22 22:47:33 -05:00
session.run(
"./scripts/generate-svgs.py", external=True, env={"FORCE_COLOR": "true"}
)
2023-08-22 13:45:23 -05:00
2023-08-22 21:34:27 -05:00
2023-08-22 13:45:23 -05:00
@nox.session
def docs(session):
2023-08-22 21:34:27 -05:00
pdm_install(session, "docs")
2023-08-22 22:53:25 -05:00
Path("docs").mkdir(exist_ok=True)
2023-08-22 21:34:27 -05:00
if not Path("docs/svgs").is_dir():
2023-08-22 13:45:23 -05:00
svgs(session)
shutil.copyfile("src/viv/viv.py", "docs/viv.py")
2023-08-22 13:45:23 -05:00
if session.interactive:
session.run("sphinx-autobuild", "docs", "site", "--port", "8787")
2023-08-22 13:45:23 -05:00
else:
session.run("sphinx-build", "docs", "site")
2023-08-22 13:45:23 -05:00
2023-08-23 02:35:05 -05:00
@nox.session
def release(session):
session.run("./scripts/release.py", external=True)
2024-07-12 11:40:33 -05:00
@nox.session(python=["3.8", "3.9", "3.10", "3.11", "3.12"])
def test(session):
pdm_install(session, "test")
session.run("pytest", "tests/")