Enable cover tox env on Travis (#628)
Replace fragile app engine sdk download script with gcprepotools script - this ensures the SDK is up-to-date and is a no-op if the SDK is installed and up-to-date. Resolves #617
This commit is contained in:
committed by
GitHub
parent
9c1ece5ce4
commit
499375cea4
@@ -21,6 +21,8 @@ matrix:
|
|||||||
env: TOX_ENV=system-tests
|
env: TOX_ENV=system-tests
|
||||||
- python: 3.4
|
- python: 3.4
|
||||||
env: TOX_ENV=system-tests3
|
env: TOX_ENV=system-tests3
|
||||||
|
- python: 2.7
|
||||||
|
env: TOX_ENV=cover
|
||||||
env:
|
env:
|
||||||
global:
|
global:
|
||||||
- GAE_PYTHONPATH=${HOME}/.cache/google_appengine
|
- GAE_PYTHONPATH=${HOME}/.cache/google_appengine
|
||||||
@@ -33,7 +35,7 @@ install:
|
|||||||
script:
|
script:
|
||||||
- ./scripts/run.sh
|
- ./scripts/run.sh
|
||||||
after_success:
|
after_success:
|
||||||
- if [[ "${TOX_ENV}" == "gae" ]]; then tox -e coveralls; fi
|
- if [[ "${TOX_ENV}" == "cover" ]]; then coveralls; fi
|
||||||
notifications:
|
notifications:
|
||||||
email: false
|
email: false
|
||||||
|
|
||||||
|
|||||||
@@ -1,85 +0,0 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
"""Fetch the most recent GAE SDK and decompress it in the current directory.
|
|
||||||
|
|
||||||
Usage:
|
|
||||||
fetch_gae_sdk.py [<dest_dir>]
|
|
||||||
|
|
||||||
Current releases are listed here:
|
|
||||||
https://www.googleapis.com/storage/v1/b/appengine-sdks/o?prefix=featured
|
|
||||||
"""
|
|
||||||
from __future__ import print_function
|
|
||||||
|
|
||||||
import json
|
|
||||||
import os
|
|
||||||
import StringIO
|
|
||||||
import sys
|
|
||||||
import urllib2
|
|
||||||
import zipfile
|
|
||||||
|
|
||||||
|
|
||||||
_SDK_URL = (
|
|
||||||
'https://www.googleapis.com/storage/v1/b/appengine-sdks/o?prefix=featured')
|
|
||||||
|
|
||||||
|
|
||||||
def get_gae_versions():
|
|
||||||
try:
|
|
||||||
version_info_json = urllib2.urlopen(_SDK_URL).read()
|
|
||||||
except:
|
|
||||||
return {}
|
|
||||||
try:
|
|
||||||
version_info = json.loads(version_info_json)
|
|
||||||
except:
|
|
||||||
return {}
|
|
||||||
return version_info.get('items', {})
|
|
||||||
|
|
||||||
|
|
||||||
def _version_tuple(v):
|
|
||||||
version_string = os.path.splitext(v['name'])[0].rpartition('_')[2]
|
|
||||||
return tuple(int(x) for x in version_string.split('.'))
|
|
||||||
|
|
||||||
|
|
||||||
def get_sdk_urls(sdk_versions):
|
|
||||||
python_releases = [v for v in sdk_versions
|
|
||||||
if v['name'].startswith('featured/google_appengine')]
|
|
||||||
current_releases = sorted(python_releases, key=_version_tuple,
|
|
||||||
reverse=True)
|
|
||||||
return [release['mediaLink'] for release in current_releases]
|
|
||||||
|
|
||||||
|
|
||||||
def main(argv):
|
|
||||||
if len(argv) > 2:
|
|
||||||
print('Usage: {0} [<destination_dir>]'.format(argv[0]))
|
|
||||||
return 1
|
|
||||||
dest_dir = argv[1] if len(argv) > 1 else '.'
|
|
||||||
if not os.path.exists(dest_dir):
|
|
||||||
os.makedirs(dest_dir)
|
|
||||||
|
|
||||||
if os.path.exists(os.path.join(dest_dir, 'google_appengine')):
|
|
||||||
print('GAE SDK already installed at {0}, exiting.'.format(dest_dir))
|
|
||||||
return 0
|
|
||||||
|
|
||||||
sdk_versions = get_gae_versions()
|
|
||||||
if not sdk_versions:
|
|
||||||
print('Error fetching GAE SDK version info')
|
|
||||||
return 1
|
|
||||||
sdk_urls = get_sdk_urls(sdk_versions)
|
|
||||||
for sdk_url in sdk_urls:
|
|
||||||
try:
|
|
||||||
sdk_contents = StringIO.StringIO(urllib2.urlopen(sdk_url).read())
|
|
||||||
break
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
else:
|
|
||||||
print('Could not read SDK from any of ', sdk_urls)
|
|
||||||
return 1
|
|
||||||
sdk_contents.seek(0)
|
|
||||||
try:
|
|
||||||
zip_contents = zipfile.ZipFile(sdk_contents)
|
|
||||||
zip_contents.extractall(dest_dir)
|
|
||||||
except:
|
|
||||||
print('Error extracting SDK contents')
|
|
||||||
return 1
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
sys.exit(main(sys.argv[:]))
|
|
||||||
@@ -16,11 +16,12 @@
|
|||||||
|
|
||||||
set -ev
|
set -ev
|
||||||
|
|
||||||
pip install tox
|
pip install --upgrade pip setuptools tox coveralls
|
||||||
|
|
||||||
# App Engine tests require the App Engine SDK.
|
# App Engine tests require the App Engine SDK.
|
||||||
if [[ "${TOX_ENV}" == "gae" && ! -d ${GAE_PYTHONPATH} ]]; then
|
if [[ "${TOX_ENV}" == "gae" || "${TOX_ENV}" == "cover" ]]; then
|
||||||
python scripts/fetch_gae_sdk.py `dirname ${GAE_PYTHONPATH}`
|
pip install git+https://github.com/GoogleCloudPlatform/python-repo-tools.git
|
||||||
|
gcprepotools download-appengine-sdk `dirname ${GAE_PYTHONPATH}`
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Travis ships with an old version of PyPy, so install at least version 2.6.
|
# Travis ships with an old version of PyPy, so install at least version 2.6.
|
||||||
|
|||||||
19
tox.ini
19
tox.ini
@@ -1,5 +1,5 @@
|
|||||||
[tox]
|
[tox]
|
||||||
envlist = py27,py34,py35,pypy,gae,cover
|
envlist = flake8,py27,py34,py35,pypy,gae,cover
|
||||||
|
|
||||||
[testenv]
|
[testenv]
|
||||||
basedeps = mock>=1.3.0
|
basedeps = mock>=1.3.0
|
||||||
@@ -31,7 +31,7 @@ commands =
|
|||||||
--cov=oauth2client \
|
--cov=oauth2client \
|
||||||
--cov=tests \
|
--cov=tests \
|
||||||
--cov-append \
|
--cov-append \
|
||||||
--gae-sdk={env:GAE_PYTHONPATH} \
|
--gae-sdk={env:GAE_PYTHONPATH:} \
|
||||||
tests/contrib/appengine
|
tests/contrib/appengine
|
||||||
deps = {[testenv]deps}
|
deps = {[testenv]deps}
|
||||||
coverage
|
coverage
|
||||||
@@ -45,17 +45,6 @@ commands =
|
|||||||
deps =
|
deps =
|
||||||
{[coverbase]deps}
|
{[coverbase]deps}
|
||||||
|
|
||||||
[testenv:coveralls]
|
|
||||||
basepython = {[coverbase]basepython}
|
|
||||||
commands =
|
|
||||||
{[coverbase]commands}
|
|
||||||
coverage report --show-missing
|
|
||||||
coveralls
|
|
||||||
deps =
|
|
||||||
{[coverbase]deps}
|
|
||||||
coveralls
|
|
||||||
passenv = {[testenv:system-tests]passenv}
|
|
||||||
|
|
||||||
[testenv:docs]
|
[testenv:docs]
|
||||||
basepython = python2.7
|
basepython = python2.7
|
||||||
deps =
|
deps =
|
||||||
@@ -71,7 +60,7 @@ commands = {toxinidir}/scripts/build_docs.sh
|
|||||||
basepython = python2.7
|
basepython = python2.7
|
||||||
deps = {[testenv]basedeps}
|
deps = {[testenv]basedeps}
|
||||||
commands =
|
commands =
|
||||||
py.test --gae-sdk={env:GAE_PYTHONPATH} tests/contrib/appengine
|
py.test --gae-sdk={env:GAE_PYTHONPATH:} tests/contrib/appengine
|
||||||
|
|
||||||
[testenv:system-tests]
|
[testenv:system-tests]
|
||||||
basepython =
|
basepython =
|
||||||
@@ -111,7 +100,7 @@ deps =
|
|||||||
flake8-import-order
|
flake8-import-order
|
||||||
|
|
||||||
[flake8]
|
[flake8]
|
||||||
exclude = .tox,.git,./*.egg,build,
|
exclude = .tox,.git,./*.egg,build,.cache,env,__pycache__
|
||||||
application-import-names = oauth2client, tests
|
application-import-names = oauth2client, tests
|
||||||
putty-ignore =
|
putty-ignore =
|
||||||
# E402 module level import not at top of file
|
# E402 module level import not at top of file
|
||||||
|
|||||||
Reference in New Issue
Block a user