viv/noxfile.py

50 lines
1 KiB
Python
Raw Normal View History

2023-08-22 13:45:23 -05:00
#!/usr/bin/env python3
import os
from pathlib import Path
import nox
2023-08-22 21:34:27 -05:00
nox.options.sessions = ["lint"]
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")
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")
session.run("./scripts/generate-svgs.py", external=True)
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")
if not Path("docs/svgs").is_dir():
2023-08-22 13:45:23 -05:00
svgs(session)
2023-08-22 21:34:27 -05:00
session.run("make", "docs", external=True)
2023-08-22 13:45:23 -05:00
if session.interactive:
2023-08-22 21:34:27 -05:00
session.run("mkdocs", "serve")
2023-08-22 13:45:23 -05:00
else:
2023-08-22 21:34:27 -05:00
session.run("mkdocs", "build")
2023-08-22 13:45:23 -05:00
# @nox.session(
# python=["3.8", "3.9", "3.10", "3.11"]
# )
# def test(session):
# pdm_install(session,'test')
# session.run('pytest')
#