engagement/noxfile.py
Jeremy Stanley 87ca6bc531 Update project boilerplate
Switch from tox to nox, use updated pyproject packaging standards,
add placeholder testing for future expansion.

Change-Id: I51c0b0d345af88659b7d84730b5bbe42b92c240b
2025-03-25 14:43:48 +00:00

64 lines
1.9 KiB
Python

import nox
nox.options.error_on_external_run = True
nox.options.reuse_existing_virtualenvs = True
nox.options.sessions = ["tests-3", "linters"]
# Convenience wrapper for stats generation
@nox.session(python="3")
def stats(session):
session.install(".")
session.run("engagement-stats", *session.posargs)
# Note setting python this way seems to give us a target name without
# python specific suffixes while still allowing us to force a specific
# version using --force-python.
@nox.session(python="3")
def linters(session):
# TODO: switch this line to 'session.install("--group", "test-linters")'
session.install(".[test-linters]")
session.run("flake8")
@nox.session(python="3")
def docs(session):
# TODO: switch this line to 'session.install("--group", "build-docs")'
session.install(".[build-docs]")
session.run(
"sphinx-build", "-W",
"-d", "doc/build/doctrees",
"-b", "html",
"doc/source/", "doc/build/html"
)
@nox.session(python="3")
def venv(session):
# TODO: switch to 'session.install("-e", ".", "--group", "test-unit")'
session.install("-e", ".[test-unit]")
session.run(*session.posargs)
# This will attempt to run python3 tests by default.
@nox.session(python=["3"])
def tests(session):
# TODO: switch to 'session.install("-e", ".", "--group", "test-unit")'
session.install("-e", ".[test-unit]")
session.run("stestr", "run", *session.posargs)
session.run("stestr", "slowest")
@nox.session(python="3")
def cover(session):
# TODO: switch to 'session.install("-e", ".", "--group", "test-cover")'
session.install("-e", ".[test-cover]")
session.env["PYTHON"] = "coverage run --source engagement --parallel-mode"
session.run("stestr", "run", *session.posargs)
session.run("stestr", "slowest")
session.run("coverage", "combine")
session.run("coverage", "html", "-d", "cover")
session.run("coverage", "xml", "-o", "cover/coverage.xml")