Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@nox.session(python=["2.7", "3.5", "3.6", "3.7"])
def unit(session):
"""Run the unit test suite."""
default(session)
@nox.session(python='python3.8')
def test(session):
"""Run all the tests."""
session.install('-rrequirements-dev.txt')
session.install('-e', '.')
run_pytest(session)
@nox.session(python=python)
def publish(session):
print("REMINDER: Has the changelog been updated?")
session.run("rm", "-rf", "dist", "build", external=True)
publish_deps = ["setuptools", "wheel", "twine"]
session.install(*publish_deps)
session.run("make", "build_frontend", external=True)
session.run("python", "setup.py", "--quiet", "sdist", "bdist_wheel")
session.run("python", "-m", "twine", "upload", "dist/*")
publish_docs(session)
@nox.session(python="3.7")
def lint_setup_py(session):
"""Verify that setup.py is valid (including RST check)."""
session.install("docutils", "pygments")
session.run("python", "setup.py", "check", "--restructuredtext", "--strict")
@nox.session(python="3.7")
def lint(session):
"""Run linters.
Returns a failure if the linters find linting errors or sufficiently
serious code quality issues.
"""
session.install("flake8", BLACK_VERSION, *LOCAL_DEPS)
session.run("black", "--check", *BLACK_PATHS)
session.run("flake8", "google", "tests")
@nox.session(python="3.7")
def lint(session):
"""Run linters.
Returns a failure if the linters find linting errors or sufficiently
serious code quality issues.
"""
session.install("flake8", "black", *LOCAL_DEPS)
session.run(
"black",
"--check",
"google",
"tests",
"docs",
)
session.run("flake8", "google", "tests")
@nox.session(python='3.9')
def bundle(session):
"""Bundle the distribution."""
session.install('-e', '.', 'pyinstaller')
session.run('rm', '-rf', 'build', 'dist', 'py-terraform-provider-b2.egg-info', external=True)
session.run('pyinstaller', '--onefile', 'py-terraform-provider-b2.spec')
# Set outputs for GitHub Actions
if CI:
asset_path = glob('dist/*')[0]
print('::set-output name=asset_path::', asset_path, sep='')
name, ext = os.path.splitext(os.path.basename(asset_path))
system = platform.system().lower()
asset_name = '{}-{}{}'.format(name, system, ext)
print('::set-output name=asset_name::', asset_name, sep='')
@nox.session(python=_PYTHON_VERSIONS)
@nox.parametrize('coverage', [False, True])
def runtests(session, coverage):
'''
runtests.py session with zeromq transport and default crypto
'''
session.notify(
'runtests-parametrized-{}(coverage={}, crypto=None, transport=\'zeromq\')'.format(
session.python,
coverage
)
@nox.session(python="3.6")
def docs(session):
# RTD uses pip for managing dependencies, so we mirror that approach
session.install(".")
session.install("-r", "docs/requirements.txt")
session.run(
"sphinx-build",
"-b",
"html",
"docs",
"docs/_build",
"-W",
env={"TAMR_CLIENT_BETA": "1", "TAMR_CLIENT_DOCS": "1"},
)
@nox.session(python='3.6')
def cover(session):
"""Run the final coverage report.
This outputs the coverage report aggregating coverage from the unit
test runs (not system test runs), and then erases coverage data.
"""
session.install('coverage', 'pytest-cov')
session.run('coverage', 'report', '--show-missing', '--fail-under=100')
session.run('coverage', 'erase')