chore: update noxfile to reflect breaking changes of nox-poetry

This commit is contained in:
George Rawlinson 2020-12-04 10:04:40 +13:00
parent 79ccdf77c6
commit 2e2a0d17a1
Signed by: grawlinson
GPG key ID: E0959FEA8B550539

View file

@ -4,7 +4,7 @@ from pathlib import Path
from textwrap import dedent from textwrap import dedent
import nox import nox
import nox_poetry import nox_poetry.patch
from nox.sessions import Session from nox.sessions import Session
# package name # package name
@ -21,30 +21,6 @@ nox.options.reuse_existing_virtualenvs = True
locations = ["src", "tests", "noxfile.py", "docs/conf.py"] locations = ["src", "tests", "noxfile.py", "docs/conf.py"]
@nox.session(python=supported_versions)
def tests(session: Session) -> None:
"""Run the test suite.
Args:
session: The Session object.
"""
nox_poetry.install(session, nox_poetry.WHEEL)
nox_poetry.install(session, "pytest", "betamax")
session.run("pytest")
@nox.session(python=latest_version)
def coverage(session: Session) -> None:
"""Generate coverage report.
Args:
session: The Session object.
"""
nox_poetry.install(session, nox_poetry.WHEEL)
nox_poetry.install(session, "pytest", "betamax", "pytest-cov", "coverage[toml]")
session.run("pytest", f"--cov={package}", "tests/")
def activate_virtualenv_in_precommit_hooks(session: Session) -> None: def activate_virtualenv_in_precommit_hooks(session: Session) -> None:
"""Activate virtualenv in hooks installed by pre-commit. """Activate virtualenv in hooks installed by pre-commit.
@ -96,6 +72,40 @@ def activate_virtualenv_in_precommit_hooks(session: Session) -> None:
hook.write_text("\n".join(lines)) hook.write_text("\n".join(lines))
@nox.session(python=latest_version)
def safety(session: Session) -> None:
"""Scan dependencies for insecure packages.
Args:
session: The Session object.
"""
requirements = nox_poetry.export_requirements(session)
session.install(".", "safety")
session.run("safety", "check", f"--file={requirements}", "--bare")
@nox.session(python=supported_versions)
def tests(session: Session) -> None:
"""Run the test suite.
Args:
session: The Session object.
"""
session.install(".", "pytest", "betamax")
session.run("pytest")
@nox.session(python=latest_version)
def coverage(session: Session) -> None:
"""Generate coverage report.
Args:
session: The Session object.
"""
session.install(".", "pytest", "betamax", "pytest-cov", "coverage[toml]")
session.run("pytest", f"--cov={package}", "tests/")
@nox.session(python=latest_version) @nox.session(python=latest_version)
def precommit(session: Session) -> None: def precommit(session: Session) -> None:
"""Lint using pre-commit. """Lint using pre-commit.
@ -107,8 +117,8 @@ def precommit(session: Session) -> None:
"run", "run",
"--all-files", "--all-files",
] # "--show-diff-on-failure"] ] # "--show-diff-on-failure"]
nox_poetry.install( session.install(
session, ".",
"black", "black",
"darglint", "darglint",
"flake8", "flake8",
@ -134,8 +144,7 @@ def docs_build(session: Session) -> None:
session: The Session object. session: The Session object.
""" """
args = session.posargs or ["docs", "docs/_build"] args = session.posargs or ["docs", "docs/_build"]
nox_poetry.install(session, nox_poetry.WHEEL) session.install(".", "sphinx", "sphinx-rtd-theme")
nox_poetry.install(session, "sphinx", "sphinx-rtd-theme")
build_dir = Path("docs", "_build") build_dir = Path("docs", "_build")
if build_dir.exists(): if build_dir.exists():
@ -152,8 +161,7 @@ def docs(session: Session) -> None:
session: The Session object. session: The Session object.
""" """
args = session.posargs or ["--open-browser", "docs", "docs/_build"] args = session.posargs or ["--open-browser", "docs", "docs/_build"]
nox_poetry.install(session, nox_poetry.WHEEL) session.install(".", "sphinx", "sphinx-autobuild", "sphinx-rtd-theme")
nox_poetry.install(session, "sphinx", "sphinx-autobuild", "sphinx-rtd-theme")
build_dir = Path("docs", "_build") build_dir = Path("docs", "_build")
if build_dir.exists(): if build_dir.exists():