Skip to content
Snippets Groups Projects
Commit eaca9d7b authored by Frederik Hennig's avatar Frederik Hennig
Browse files

add noxfile; update dependencies in pyproject.toml

parent c70a1c03
No related branches found
No related tags found
1 merge request!10Introduce Nox for Test Automation
Pipeline #71545 failed
from typing import Sequence
import nox
nox.options.sessions = ["lint", "typecheck", "testsuite", "report_coverage"]
def add_pystencils_git(session: nox.Session):
"""Clone the pystencils 2.0 development branch and install it in the current session"""
cache_dir = session.cache_dir
pystencils_dir = cache_dir / "pystencils"
if not pystencils_dir.exists():
session.run_install(
"git",
"clone",
"--branch",
"v2.0-dev",
"--single-branch",
"git@i10git.cs.fau.de:pycodegen/pystencils.git",
pystencils_dir,
external=True,
)
session.install("-e", str(pystencils_dir))
def editable_install(session: nox.Session, opts: Sequence[str] = ()):
add_pystencils_git(session)
if opts:
opts_str = "[" + ",".join(opts) + "]"
session.install("-e", f".{opts_str}")
@nox.session(tags=["qa", "code-quality"])
def lint(session: nox.Session):
"""Lint code using flake8"""
session.install("flake8")
session.run("flake8", "src/pystencilssfg")
@nox.session(tags=["qa", "code-quality"])
def typecheck(session: nox.Session):
"""Run MyPy for static type checking"""
editable_install(session)
session.install("mypy")
session.run("mypy", "src/pystencilssfg")
@nox.session(tags=["tests"])
def testsuite(session: nox.Session):
"""Run the testsuite and measure coverage."""
editable_install(session, ["testsuite"])
session.run(
"pytest",
"-v",
"--cov=src/pystencilssfg",
"--cov-report=term",
"--cov-config=pyproject.toml",
)
@nox.session(tags=["report"])
def report_coverage(session: nox.Session):
"""Produce HTML and XML coverage reports"""
session.install("coverage[toml]")
session.run("coverage", "html")
session.run("coverage", "xml")
@nox.session(tags=["docs"])
def docs(session: nox.Session):
"""Build the documentation pages"""
editable_install(session, ["docs"])
session.chdir("docs")
session.run("make", "html", external=True)
@nox.session(default=False)
def dev(session: nox.Session):
"""Set up the development environment at .venv"""
session.install("virtualenv")
session.run("virtualenv", ".venv", "--prompt", "pystencils-sfg")
session.run(
".venv/bin/pip",
"install",
"git+https://i10git.cs.fau.de/pycodegen/pystencils.git@v2.0-dev",
external=True,
)
session.run(".venv/bin/pip", "install", "-e", ".[dev]", external=True)
......@@ -23,10 +23,15 @@ requires = [
build-backend = "setuptools.build_meta"
[project.optional-dependencies]
tests = [
"flake8>=6.1.0",
"mypy>=1.7.0",
dev = [
"flake8",
"mypy",
"black",
"clang-format",
]
testsuite = [
"pytest",
"pytest-cov",
"pyyaml",
"requests",
"fasteners",
......@@ -60,7 +65,7 @@ omit = [
[tool.coverage.report]
exclude_also = [
"\\.\\.\\.",
"\\.\\.\\.\n",
"if TYPE_CHECKING:",
"@(abc\\.)?abstractmethod",
]
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment