mirror of
https://github.com/xlorepdarkhelm/numinar-coding-project.git
synced 2026-08-05 22:21:00 -04:00
112 lines
2.3 KiB
Python
112 lines
2.3 KiB
Python
"""Root noxfile for orchestrating backend and frontend tasks.
|
|
|
|
Run with `nox -s <session>` from the project root.
|
|
"""
|
|
|
|
import nox
|
|
from nox_poetry import Session
|
|
|
|
|
|
python_versions = ["3.13"]
|
|
|
|
|
|
@nox.session(name="pre-commit", python=python_versions[0])
|
|
def precommit(session: Session) -> None:
|
|
"""Lint using pre-commit for the whole project.
|
|
|
|
Args:
|
|
session: The Nox session object.
|
|
"""
|
|
args = session.posargs or [
|
|
"run",
|
|
"--all-files",
|
|
"--hook-stage=manual",
|
|
"--show-diff-on-failure",
|
|
]
|
|
session.install(
|
|
"black",
|
|
"darglint",
|
|
"flake8",
|
|
"flake8-bandit",
|
|
"flake8-bugbear",
|
|
"flake8-docstrings",
|
|
"flake8-rst-docstrings",
|
|
"isort==6.0.1",
|
|
"pep8-naming",
|
|
"pre-commit",
|
|
"pre-commit-hooks",
|
|
"pyupgrade",
|
|
)
|
|
session.run("pre-commit", *args)
|
|
|
|
|
|
backend_sessions = [
|
|
"safety",
|
|
"mypy",
|
|
"tests",
|
|
"coverage",
|
|
"typeguard",
|
|
"xdoctest",
|
|
"docs-build",
|
|
]
|
|
|
|
frontend_sessions = [
|
|
"jest",
|
|
"typecheck",
|
|
"coverage",
|
|
"audit",
|
|
"storybook-build",
|
|
]
|
|
|
|
|
|
def _delegate( # pyright: ignore
|
|
session: nox.Session, subdir: str, session_name: str
|
|
) -> None:
|
|
"""Delegate session execution to a subdirectory noxfile.
|
|
|
|
Args:
|
|
session: The Nox session object.
|
|
subdir: Subdirectory containing the noxfile.
|
|
session_name: Name of the session to run.
|
|
"""
|
|
session.run(
|
|
"nox",
|
|
"-f",
|
|
f"{subdir}/noxfile.py",
|
|
"-s",
|
|
session_name,
|
|
*session.posargs,
|
|
external=True,
|
|
)
|
|
|
|
|
|
for name in backend_sessions:
|
|
func_name = name.replace("-", "_")
|
|
exec(
|
|
f'''
|
|
@nox.session(name={name!r})
|
|
def {func_name}_delegator(session: nox.Session) -> None:
|
|
"""Delegates to backend/{name} session.
|
|
|
|
Args:
|
|
session: The Nox session object.
|
|
"""
|
|
_delegate(session, 'backend', {name!r})
|
|
'''
|
|
)
|
|
|
|
for name in frontend_sessions:
|
|
func_name = name.replace("-", "_")
|
|
exec(
|
|
f'''
|
|
@nox.session(name={name!r})
|
|
def {func_name}_delegator(session: nox.Session) -> None:
|
|
"""Delegates to frontend/{name} session.
|
|
|
|
Args:
|
|
session: The Nox session object.
|
|
"""
|
|
_delegate(session, 'frontend', {name!r})
|
|
'''
|
|
)
|