2023-08-22 13:45:23 -05:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
|
|
|
import os
|
2023-10-06 14:02:59 -05:00
|
|
|
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")
|
2023-08-22 22:00:29 -05:00
|
|
|
|
|
|
|
|
|
|
|
@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)
|
|
|
|
|
2023-10-06 14:02:59 -05:00
|
|
|
shutil.copyfile("src/viv/viv.py", "docs/viv.py")
|
2023-08-22 13:45:23 -05:00
|
|
|
if session.interactive:
|
2023-10-06 14:02:59 -05:00
|
|
|
session.run("sphinx-autobuild", "docs", "site", "--port", "8787")
|
2023-08-22 13:45:23 -05:00
|
|
|
else:
|
2023-10-06 14:02:59 -05:00
|
|
|
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)
|
|
|
|
|
|
|
|
|
2023-09-27 13:34:10 -05:00
|
|
|
@nox.session(python=["3.8", "3.9", "3.10", "3.11"])
|
|
|
|
def test(session):
|
|
|
|
pdm_install(session, "test")
|
2024-01-02 14:44:38 -06:00
|
|
|
session.run("pytest", "tests/")
|