697af0b17a
This illustrates the use of nox in a simpler project. It can build docs, run linters, and execute unittests simply and effectively. Note we pin the packaging package as newer versions have changed behavior on rolling release distros that don't have proper version. This is necessary to fix gating. The followup change fixes it properly. Change-Id: I795e4d73f60d90b0f027df43a80ebda773ee9194
60 lines
1.8 KiB
Python
60 lines
1.8 KiB
Python
import nox
|
|
|
|
|
|
nox.options.error_on_external_run = True
|
|
nox.options.reuse_existing_virtualenvs = True
|
|
nox.options.sessions = ["tests-3", "tests-2.7", "linters"]
|
|
|
|
|
|
# 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):
|
|
session.install("hacking>=3.2.0,<3.3")
|
|
session.run("flake8")
|
|
|
|
|
|
@nox.session(python="3")
|
|
def docs(session):
|
|
session.install("-r", "requirements.txt")
|
|
session.install("-r", "doc/requirements.txt")
|
|
session.install(".")
|
|
session.run(
|
|
"sphinx-build", "-W",
|
|
"-d", "doc/build/doctrees",
|
|
"-b", "html",
|
|
"doc/source/", "doc/build/html"
|
|
)
|
|
|
|
|
|
@nox.session(python="3")
|
|
def venv(session):
|
|
session.install("-r", "requirements.txt")
|
|
session.install("-r", "test-requirements.txt")
|
|
session.install("-e", ".")
|
|
session.run(*session.posargs)
|
|
|
|
|
|
# This will attempt to run python3 and 2.7 tests by default.
|
|
@nox.session(python=["3", "2.7"])
|
|
def tests(session):
|
|
session.install("-r", "requirements.txt")
|
|
session.install("-r", "test-requirements.txt")
|
|
session.install("-e", ".")
|
|
session.run("stestr", "run", *session.posargs)
|
|
session.run("stestr", "slowest")
|
|
|
|
|
|
@nox.session(python="3")
|
|
def cover(session):
|
|
session.install("-r", "requirements.txt")
|
|
session.install("-r", "test-requirements.txt")
|
|
session.install("-e", ".")
|
|
session.env["PYTHON"] = "coverage run --source bindep --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")
|