Skip to content

Commit

Permalink
Adding nox configuration for the standard (non-gae) tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Jon Wayne Parrott committed Mar 28, 2016
1 parent 4275c3b commit 055fee1
Show file tree
Hide file tree
Showing 6 changed files with 88 additions and 9 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ secrets.tar
.cache
junit.xml
credentials.dat
.nox
6 changes: 4 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@ env:
- GAE_ROOT=${HOME}/.cache/
- secure: Orp9Et2TIwCG/Hf59aa0NUDF1pNcwcS4TFulXX175918cFREOzf/cNZNg+Ui585ZRFjbifZdc858tVuCVd8XlxQPXQgp7bwB7nXs3lby3LYg4+HD83Gaz7KOWxRLWVor6IVn8OxeCzwl6fJkdmffsTTO9csC4yZ7izHr+u7hiO4=
before_install:
- pip install --upgrade pip wheel virtualenv
- openssl aes-256-cbc -k "$secrets_password" -in secrets.tar.enc -out secrets.tar -d
- tar xvf secrets.tar
install:
- pip install tox coverage
- pip install nox-automation coverage
script:
- source ${TRAVIS_BUILD_DIR}/testing/resources/test-env.sh
- tox
- nox --stop-on-first-error -s lint travis
after_script:
- coverage report
83 changes: 83 additions & 0 deletions nox.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
import fnmatch
import os

import nox

REPO_TOOLS_REQ =\
'git+https://github.com/GoogleCloudPlatform/python-repo-tools.git'


def session_lint(session):
session.install('flake8', 'flake8-import-order')
session.run(
'flake8', '--builtin=gettext', '--max-complexity=10',
'--import-order-style=google',
'--exclude',
'container_engine/django_tutorial/polls/migrations/*,.nox,.cache,env',
*(session.posargs or ['.']))


def list_files(folder, pattern):
for root, folders, files in os.walk(folder):
for filename in files:
if fnmatch.fnmatch(filename, pattern):
yield os.path.join(root, filename)


def session_reqcheck(session):
session.install(REPO_TOOLS_REQ)

if 'update' in session.posargs:
command = 'update-requirements'
else:
command = 'check-requirements'

for reqfile in list_files('.', 'requirements*.txt'):
session.run('gcprepotools', command, reqfile)


COMMON_PYTEST_ARGS = [
'-x', '--no-success-flaky-report', '--cov', '--cov-config',
'.coveragerc', '--cov-append', '--cov-report=']

SAMPLES = [
'bigquery/api',
'blog/introduction_to_data_models_in_cloud_datastore',
'cloud_logging/api',
'compute/api',
'compute/autoscaler/demo',
'datastore/api',
'managed_vms/cloudsql',
'managed_vms/datastore',
'managed_vms/disk',
'managed_vms/extending_runtime',
'managed_vms/hello_world',
'managed_vms/hello_world_compat',
'managed_vms/memcache',
'managed_vms/pubsub',
'managed_vms/static_files',
'managed_vms/storage',
'monitoring/api',
'storage/api',
]


@nox.parametrize('interpreter', ['python2.7', 'python3.4'])
def session_tests(session, interpreter, extra_pytest_args=None):
session.interpreter = interpreter
session.install(REPO_TOOLS_REQ)
session.install('-r', 'requirements-{}-dev.txt'.format(interpreter))

pytest_args = COMMON_PYTEST_ARGS + (extra_pytest_args or [])

for sample in (session.posargs or SAMPLES):
session.run(
'py.test', sample,
*pytest_args,
success_codes=[0, 5]) # Treat no test collected as success.


def session_travis(session):
"""On travis, just run with python3.4 and don't run slow or flaky tests."""
session_tests(
session, 'python3.4', extra_pytest_args=['-m not slow and not flaky'])
File renamed without changes.
File renamed without changes.
7 changes: 0 additions & 7 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,3 @@ whitelist_externals =
bash
find
xargs

[flake8]
exclude=container_engine/django_tutorial/polls/migrations/*

[pytest]
addopts = -x --no-success-flaky-report --cov --cov-config .coveragerc --cov-append --cov-report=

0 comments on commit 055fee1

Please sign in to comment.