Skip to content

Commit 7bd7aeb

Browse files
author
Jon Wayne Parrott
committed
Merge pull request #234 from GoogleCloudPlatform/noxify
Noxify
2 parents 736c565 + 879176b commit 7bd7aeb

File tree

14 files changed

+179
-160
lines changed

14 files changed

+179
-160
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,4 @@ secrets.tar
1818
.cache
1919
junit.xml
2020
credentials.dat
21+
.nox

.travis.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,16 @@ env:
1414
- PATH=${PATH}:${HOME}/gcloud/google-cloud-sdk/bin
1515
- GOOGLE_APPLICATION_CREDENTIALS=${TRAVIS_BUILD_DIR}/testing/resources/service-account.json
1616
- GOOGLE_CLIENT_SECRETS=${TRAVIS_BUILD_DIR}/testing/resources/client-secrets.json
17-
- GAE_PYTHONPATH=${HOME}/.cache/google_appengine
1817
- GAE_ROOT=${HOME}/.cache/
1918
- secure: Orp9Et2TIwCG/Hf59aa0NUDF1pNcwcS4TFulXX175918cFREOzf/cNZNg+Ui585ZRFjbifZdc858tVuCVd8XlxQPXQgp7bwB7nXs3lby3LYg4+HD83Gaz7KOWxRLWVor6IVn8OxeCzwl6fJkdmffsTTO9csC4yZ7izHr+u7hiO4=
2019
before_install:
20+
- pip install --upgrade pip wheel virtualenv
2121
- openssl aes-256-cbc -k "$secrets_password" -in secrets.tar.enc -out secrets.tar -d
2222
- tar xvf secrets.tar
2323
install:
24-
- pip install tox coverage
24+
- pip install nox-automation coverage
2525
script:
2626
- source ${TRAVIS_BUILD_DIR}/testing/resources/test-env.sh
27-
- tox
27+
- nox --stop-on-first-error -s lint travis
28+
after_script:
2829
- coverage report

conftest.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
# Copyright 2016 Google Inc. All Rights Reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
115
import os
216

317
import pytest
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Django==1.9.2
1+
Django==1.9.3
22
mysqlclient==1.3.7
33
wheel==0.29.0
44
gunicorn==19.4.5
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
Flask==0.10.1
22
gcloud==0.10.1
33
gunicorn==19.4.5
4-
oauth2client==2.0.0.post1
4+
oauth2client==2.0.1
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Django==1.9.2
1+
Django==1.9.3
22
mysqlclient==1.3.7
33
wheel==0.29.0
44
gunicorn==19.4.5
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
Django==1.9.2
1+
Django==1.9.3
22
gunicorn==19.4.5

managed_vms/kinto/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
gunicorn==19.4.5
2-
oauth2client==2.0.0.post1
2+
oauth2client==2.0.1
33
kinto==1.11.2

managed_vms/pubsub/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
Flask==0.10.1
22
gcloud==0.10.1
33
gunicorn==19.4.5
4-
oauth2client==2.0.0.post1
4+
oauth2client==2.0.1

managed_vms/sendgrid/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
Flask==0.10.1
2-
sendgrid==1.6.22
2+
sendgrid==2.2.1
33
gunicorn==19.4.5

nox.py

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
# Copyright 2016 Google Inc. All Rights Reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
import fnmatch
16+
import os
17+
import tempfile
18+
19+
import nox
20+
21+
REPO_TOOLS_REQ =\
22+
'git+https://github.com/GoogleCloudPlatform/python-repo-tools.git'
23+
24+
COMMON_PYTEST_ARGS = [
25+
'-x', '--no-success-flaky-report', '--cov', '--cov-config',
26+
'.coveragerc', '--cov-append', '--cov-report=']
27+
28+
SAMPLES = [
29+
'bigquery/api',
30+
'blog/introduction_to_data_models_in_cloud_datastore',
31+
'cloud_logging/api',
32+
'compute/api',
33+
'compute/autoscaler/demo',
34+
'datastore/api',
35+
'managed_vms/cloudsql',
36+
'managed_vms/datastore',
37+
'managed_vms/disk',
38+
'managed_vms/extending_runtime',
39+
'managed_vms/hello_world',
40+
'managed_vms/hello_world_compat',
41+
'managed_vms/memcache',
42+
'managed_vms/pubsub',
43+
'managed_vms/static_files',
44+
'managed_vms/storage',
45+
'monitoring/api',
46+
'storage/api',
47+
]
48+
49+
GAE_SAMPLES = [
50+
'appengine/app_identity/signing',
51+
'appengine/bigquery',
52+
'appengine/blobstore',
53+
'appengine/cloudsql',
54+
'appengine/images',
55+
'appengine/localtesting',
56+
'appengine/logging/reading_logs',
57+
'appengine/logging/writing_logs',
58+
'appengine/mailgun',
59+
'appengine/memcache/guestbook',
60+
'appengine/multitenancy',
61+
'appengine/ndb/modeling',
62+
'appengine/ndb/overview',
63+
'appengine/ndb/transactions',
64+
'appengine/storage',
65+
]
66+
67+
68+
def session_lint(session):
69+
session.install('flake8', 'flake8-import-order')
70+
session.run(
71+
'flake8', '--builtin=gettext', '--max-complexity=10',
72+
'--import-order-style=google',
73+
'--exclude',
74+
'container_engine/django_tutorial/polls/migrations/*,.nox,.cache,env',
75+
*(session.posargs or ['.']))
76+
77+
78+
def list_files(folder, pattern):
79+
for root, folders, files in os.walk(folder):
80+
for filename in files:
81+
if fnmatch.fnmatch(filename, pattern):
82+
yield os.path.join(root, filename)
83+
84+
85+
def session_reqcheck(session):
86+
session.install(REPO_TOOLS_REQ)
87+
88+
if 'update' in session.posargs:
89+
command = 'update-requirements'
90+
else:
91+
command = 'check-requirements'
92+
93+
for reqfile in list_files('.', 'requirements*.txt'):
94+
session.run('gcprepotools', command, reqfile)
95+
96+
97+
@nox.parametrize('interpreter', ['python2.7', 'python3.4'])
98+
def session_tests(session, interpreter, extra_pytest_args=None):
99+
session.interpreter = interpreter
100+
session.install(REPO_TOOLS_REQ)
101+
session.install('-r', 'requirements-{}-dev.txt'.format(interpreter))
102+
103+
# extra_pytest_args can be send by another session calling this session,
104+
# see session_travis.
105+
pytest_args = COMMON_PYTEST_ARGS + (extra_pytest_args or [])
106+
107+
# session.posargs is any leftover arguments from the command line, which
108+
# allows users to run a particular test instead of all of them.
109+
for sample in (session.posargs or SAMPLES):
110+
session.run(
111+
'py.test', sample,
112+
*pytest_args,
113+
success_codes=[0, 5]) # Treat no test collected as success.
114+
115+
116+
def session_gae(session, extra_pytest_args=None):
117+
session.interpreter = 'python2.7'
118+
session.install(REPO_TOOLS_REQ)
119+
session.install('-r', 'requirements-python2.7-dev.txt')
120+
121+
# Install the app engine sdk and setup import paths.
122+
gae_root = os.environ.get('GAE_ROOT', tempfile.gettempdir())
123+
session.env['PYTHONPATH'] = os.path.join(gae_root, 'google_appengine')
124+
session.run('gcprepotools', 'download-appengine-sdk', gae_root)
125+
126+
# Create a lib directory to prevent the GAE vendor library from
127+
# complaining.
128+
if not os.path.exists('lib'):
129+
os.makedirs('lib')
130+
131+
pytest_args = COMMON_PYTEST_ARGS + (extra_pytest_args or [])
132+
133+
for sample in (session.posargs or GAE_SAMPLES):
134+
session.run(
135+
'py.test', sample,
136+
*pytest_args,
137+
success_codes=[0, 5]) # Treat no test collected as success.
138+
139+
140+
def session_travis(session):
141+
"""On travis, just run with python3.4 and don't run slow or flaky tests."""
142+
session_tests(
143+
session, 'python3.4', extra_pytest_args=['-m not slow and not flaky'])
144+
session_gae(
145+
session, extra_pytest_args=['-m not slow and not flaky'])

requirements-py27-dev.txt renamed to requirements-python2.7-dev.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
gcloud==0.10.1
22
google-api-python-client==1.5.0
3-
oauth2client==2.0.0.post1
3+
oauth2client==2.0.1
44
requests[security]==2.9.1
55
beautifulsoup4==4.4.1
66
coverage==4.1b2
@@ -21,10 +21,10 @@ PyMySQL==0.7.2
2121
pymemcache==1.3.5
2222
PyCrypto==2.6.1
2323
flaky==3.1.0
24-
Django==1.9.2
24+
Django==1.9.3
2525
twilio==6.3.dev0
26-
sendgrid==1.6.22
26+
sendgrid==2.2.1
2727
Flask-Sockets==0.2.0
2828
mysql-python==1.2.5
29-
pytest==2.8.7
29+
pytest==2.9.0
3030
pytest-cov==2.2.1

requirements-py34-dev.txt renamed to requirements-python3.4-dev.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
gcloud==0.10.1
22
google-api-python-client==1.5.0
3-
oauth2client==2.0.0.post1
3+
oauth2client==2.0.1
44
requests[security]==2.9.1
55
beautifulsoup4==4.4.1
66
coverage==4.1b2
@@ -21,8 +21,8 @@ PyMySQL==0.7.2
2121
pymemcache==1.3.5
2222
PyCrypto==2.6.1
2323
flaky==3.1.0
24-
Django==1.9.2
24+
Django==1.9.3
2525
twilio==6.3.dev0
26-
sendgrid==1.6.22
27-
pytest==2.8.7
26+
sendgrid==2.2.1
27+
pytest==2.9.0
2828
pytest-cov==2.2.1

0 commit comments

Comments
 (0)