Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use new Nox #6175

Merged
merged 3 commits into from
Oct 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions .kokoro/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ fi

cd "$PACKAGE"

python3.6 -m pip install --quiet nox-automation
# Remove old nox
python3.6 -m pip uninstall --yes --quiet nox-automation

nox
# Install nox
python3.6 -m pip install --upgrade --quiet nox
python3.6 -m nox --version

python3.6 -m nox
39 changes: 8 additions & 31 deletions api_core/nox.py → api_core/noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import nox # pytype: disable=import-error


@nox.session
def default(session):
"""Default unit test session.

Expand Down Expand Up @@ -52,57 +51,37 @@ def default(session):
)


@nox.session
@nox.parametrize('py', ['2.7', '3.5', '3.6', '3.7'])
def unit(session, py):
@nox.session(python=['2.7', '3.5', '3.6', '3.7'])
def unit(session):
"""Run the unit test suite."""

# Run unit tests against all supported versions of Python.
session.interpreter = 'python{}'.format(py)

# Set the virtualenv dirname.
session.virtualenv_dirname = 'unit-' + py

default(session)


@nox.session
@nox.parametrize('py', ['2.7', '3.5', '3.6', '3.7'])
def unit_grpc_gcp(session, py):
@nox.session(python=['2.7', '3.5', '3.6', '3.7'])
def unit_grpc_gcp(session):
"""Run the unit test suite with grpcio-gcp installed."""

# Run unit tests against all supported versions of Python.
session.interpreter = 'python{}'.format(py)

# Set the virtualenv dirname.
session.virtualenv_dirname = 'unit-grpc-gcp-' + py

# Install grpcio-gcp
session.install('grpcio-gcp')

default(session)


@nox.session
@nox.session(python='3.6')
def lint(session):
"""Run linters.

Returns a failure if the linters find linting errors or sufficiently
serious code quality issues.
"""
session.interpreter = 'python3.6'
session.install('flake8', 'flake8-import-order')
session.install('.')
session.run('flake8', 'google', 'tests')


@nox.session
@nox.session(python='3.6')
def lint_setup_py(session):
"""Verify that setup.py is valid (including RST check)."""
session.interpreter = 'python3.6'

# Set the virtualenv dirname.
session.virtualenv_dirname = 'setup'

session.install('docutils', 'Pygments')
session.run(
Expand All @@ -111,25 +90,23 @@ def lint_setup_py(session):

# No 2.7 due to https://github.com/google/importlab/issues/26.
# No 3.7 because pytype supports up to 3.6 only.
@nox.session
@nox.session(python='3.6')
def pytype(session):
"""Run type-checking."""
session.interpreter = 'python3.6'
session.install('.',
'grpcio >= 1.8.2',
'grpcio-gcp >= 0.2.2',
'pytype >= 2018.9.26')
session.run('pytype')


@nox.session
@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.interpreter = 'python3.6'
session.install('coverage', 'pytest-cov')
session.run('coverage', 'report', '--show-missing', '--fail-under=100')
session.run('coverage', 'erase')
25 changes: 6 additions & 19 deletions asset/nox.py → asset/noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,7 @@

import nox


@nox.session
def default(session):
return unit(session, 'default')


@nox.session
@nox.parametrize('py', ['2.7', '3.5', '3.6', '3.7'])
def unit(session, py):
"""Run the unit test suite."""

# Run unit tests against all supported versions of Python.
if py != 'default':
session.interpreter = 'python{}'.format(py)

# Set the virtualenv directory name.
session.virtualenv_dirname = 'unit-' + py

# Install all test dependencies, then install this package in-place.
session.install('pytest')
session.install('-e', '.')
Expand All @@ -45,10 +28,14 @@ def unit(session, py):
session.run('py.test', '--quiet', os.path.join('tests', 'unit'))


@nox.session
@nox.session(python=['2.7', '3.5', '3.6', '3.7'])
def unit(session):
"""Run the unit test suite."""
default(session)

@nox.session(python='3.6')
def lint_setup_py(session):
"""Verify that setup.py is valid (including RST check)."""
session.interpreter = 'python3.6'
session.install('docutils', 'pygments')
session.run('python', 'setup.py', 'check', '--restructuredtext',
'--strict')
31 changes: 10 additions & 21 deletions automl/nox.py → automl/noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,35 +18,24 @@
import nox


@nox.session
def default(session):
return unit(session, 'default')
# Install all test dependencies, then install this package in-place.
session.install('pytest')
session.install('-e', '.')

# Run py.test against the unit tests.
session.run('py.test', '--quiet', os.path.join('tests', 'unit'))

@nox.session
@nox.parametrize('py', ['2.7', '3.5', '3.6', '3.7'])
def unit(session, py):
"""Run the unit test suite."""

# Run unit tests against all supported versions of Python.
if py != 'default':
session.interpreter = 'python{}'.format(py)

# Set the virtualenv directory name.
session.virtualenv_dirname = 'unit-' + py

# Install all test dependencies, then install this package in-place.
session.install('pytest')
session.install('-e', '.')

# Run py.test against the unit tests.
session.run('py.test', '--quiet', os.path.join('tests', 'unit'))
@nox.session(python=['2.7', '3.5', '3.6', '3.7'])
def unit(session):
"""Run the unit test suite."""
default(session)


@nox.session
@nox.session(python='3.6')
def lint_setup_py(session):
"""Verify that setup.py is valid (including RST check)."""
session.interpreter = 'python3.6'
session.install('docutils', 'pygments')
session.run('python', 'setup.py', 'check', '--restructuredtext',
'--strict')
54 changes: 12 additions & 42 deletions bigquery/nox.py → bigquery/noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
)


@nox.session
def default(session):
"""Default unit test session.

Expand All @@ -40,14 +39,14 @@ def default(session):
session.install('-e', local_dep)

# Pyarrow does not support Python 3.7
if session.interpreter == 'python3.7':
if session.python == '3.7':
dev_install = '.[pandas]'
else:
dev_install = '.[pandas, pyarrow]'
session.install('-e', dev_install)

# IPython does not support Python 2 after version 5.x
if session.interpreter == 'python2.7':
if session.python == '2.7':
session.install('ipython==5.5')
else:
session.install('ipython')
Expand All @@ -67,35 +66,20 @@ def default(session):
)


@nox.session
@nox.parametrize('py', ['2.7', '3.5', '3.6', '3.7'])
def unit(session, py):
@nox.session(python=['2.7', '3.5', '3.6', '3.7'])
def unit(session):
"""Run the unit test suite."""

# Run unit tests against all supported versions of Python.
session.interpreter = 'python{}'.format(py)

# Set the virtualenv dirname.
session.virtualenv_dirname = 'unit-' + py

default(session)


@nox.session
@nox.parametrize('py', ['2.7', '3.6'])
def system(session, py):
@nox.session(python=['2.7', '3.6'])
def system(session):
"""Run the system test suite."""

# Sanity check: Only run system tests if the environment variable is set.
if not os.environ.get('GOOGLE_APPLICATION_CREDENTIALS', ''):
session.skip('Credentials must be set via environment variable.')

# Run the system tests against latest Python 2 and Python 3 only.
session.interpreter = 'python{}'.format(py)

# Set the virtualenv dirname.
session.virtualenv_dirname = 'sys-' + py

# Use pre-release gRPC for system tests.
session.install('--pre', 'grpcio')

Expand All @@ -108,7 +92,7 @@ def system(session, py):
session.install('-e', '.[pandas]')

# IPython does not support Python 2 after version 5.x
if session.interpreter == 'python2.7':
if session.python == '2.7':
session.install('ipython==5.5')
else:
session.install('ipython')
Expand All @@ -122,21 +106,14 @@ def system(session, py):
)


@nox.session
@nox.parametrize('py', ['2.7', '3.6'])
def snippets(session, py):
@nox.session(python=['2.7', '3.6'])
def snippets(session):
"""Run the system test suite."""

# Sanity check: Only run system tests if the environment variable is set.
if not os.environ.get('GOOGLE_APPLICATION_CREDENTIALS', ''):
session.skip('Credentials must be set via environment variable.')

# Run the system tests against latest Python 2 and Python 3 only.
session.interpreter = 'python{}'.format(py)

# Set the virtualenv dirname.
session.virtualenv_dirname = 'snip-' + py

# Install all test dependencies, then install local packages in place.
session.install('mock', 'pytest')
for local_dep in LOCAL_DEPS:
Expand All @@ -150,14 +127,13 @@ def snippets(session, py):
'py.test', os.path.join('docs', 'snippets.py'), *session.posargs)


@nox.session
@nox.session(python='3.6')
def lint(session):
"""Run linters.

Returns a failure if the linters find linting errors or sufficiently
serious code quality issues.
"""
session.interpreter = 'python3.6'

session.install('flake8', *LOCAL_DEPS)
session.install('.')
Expand All @@ -167,28 +143,22 @@ def lint(session):
'flake8', os.path.join('docs', 'snippets.py'))


@nox.session
@nox.session(python='3.6')
def lint_setup_py(session):
"""Verify that setup.py is valid (including RST check)."""
session.interpreter = 'python3.6'

# Set the virtualenv dirname.
session.virtualenv_dirname = 'setup'

session.install('docutils', 'Pygments')
session.run(
'python', 'setup.py', 'check', '--restructuredtext', '--strict')


@nox.session
@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.interpreter = 'python3.6'

session.install('coverage', 'pytest-cov')
session.run('coverage', 'report', '--show-missing', '--fail-under=100')
session.run('coverage', 'erase')
Loading