From e67b11dba9a9cceb1e501f3069b866cc782d8302 Mon Sep 17 00:00:00 2001 From: Danny Hermes Date: Mon, 27 Oct 2014 16:24:50 -0700 Subject: [PATCH 1/3] Introducing custom pip install in tox to be used with cached wheels. In addition: - Removes used of "pip install" in Travis config with our custom pip install. - Introducing tox environment "coveralls" to encourage all Python dependencies to be contained in "tox.ini". - Puts LICENSE header back on update_docs.sh and cleaned up some bash long line / syntax with shellchecker. See https://github.com/GoogleCloudPlatform/gcloud-python-wheels/pull/1#issuecomment-60648806 step 2 for context. --- .travis.yml | 12 +++++------- scripts/custom_pip_install.sh | 4 ++++ scripts/update_docs.sh | 28 ++++++++++++++++++++++++---- tox.ini | 16 ++++++++++++++++ 4 files changed, 49 insertions(+), 11 deletions(-) create mode 100755 scripts/custom_pip_install.sh diff --git a/.travis.yml b/.travis.yml index b74e2f4e7e1d..ae36331de133 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,15 +1,13 @@ language: python -# command to install dependencies + install: - - pip install tox - - pip install coveralls -# run tests + - scripts/custom_pip_install.sh tox + script: - tox -e py26 - tox -e py27 - tox -e lint - tox -e regression -after_success: - - tox -e cover - - coveralls - scripts/update_docs.sh +after_success: + - tox -e coveralls diff --git a/scripts/custom_pip_install.sh b/scripts/custom_pip_install.sh new file mode 100755 index 000000000000..078bf3f5131c --- /dev/null +++ b/scripts/custom_pip_install.sh @@ -0,0 +1,4 @@ +#!/bin/bash +# Temporarily perform default pip install before initial +# wheelhouse is built. +pip install "$@" diff --git a/scripts/update_docs.sh b/scripts/update_docs.sh index 67c0bc276ec8..19bb4016f1b5 100755 --- a/scripts/update_docs.sh +++ b/scripts/update_docs.sh @@ -1,17 +1,37 @@ #!/bin/bash +# Copyright 2014 Google Inc. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + set -ev -# If merging to master and not a pull request, update docs. -if [ "${TRAVIS_BRANCH}" == "master" ] && [ "${TRAVIS_PULL_REQUEST}" == "false" ]; then +if [[ "${TRAVIS_BRANCH}" == "master" ]] && \ + [[ "${TRAVIS_PULL_REQUEST}" == "false" ]]; then # Generate new set of json files in docs/json/master. tox -e docs - git submodule add -b gh-pages https://${GH_OAUTH_TOKEN}@github.com/${GH_OWNER}/${GH_PROJECT_NAME} ghpages + git submodule add -b gh-pages \ + "https://${GH_OAUTH_TOKEN}@github.com/${GH_OWNER}/${GH_PROJECT_NAME}" \ + ghpages cp -R docs/_build/html/* ghpages/ cd ghpages git add . # Commit to gh-pages branch to apply changes. git config user.name "selfiebot" git commit -m "Update docs after merge to master." - git push https://${GH_OAUTH_TOKEN}@github.com/${GH_OWNER}/${GH_PROJECT_NAME} HEAD:gh-pages + git push \ + "https://${GH_OAUTH_TOKEN}@github.com/${GH_OWNER}/${GH_PROJECT_NAME}" \ + HEAD:gh-pages +else + echo "Not in master on a non-pull request. Doing nothing." fi diff --git a/tox.ini b/tox.ini index 768d3ca1aa71..8bc9aeab5f93 100644 --- a/tox.ini +++ b/tox.ini @@ -11,6 +11,8 @@ deps = protobuf==2.6.0 [testenv] +install_command = + {toxinidir}/scripts/custom_pip_install.sh {opts} {packages} commands = nosetests deps = @@ -29,6 +31,20 @@ deps = coverage nosexcover +[testenv:coveralls] +basepython = + python2.7 +commands = + nosetests --with-xunit --with-xcoverage --cover-package=gcloud \ + --nocapture --cover-erase --cover-tests --cover-branches + coveralls +deps = + coverage + coveralls + nose + nosexcover + unittest2 + [testenv:docs] basepython = python2.7 From 8c9aaaaa22e886b94a279a923b72d8d7c546154c Mon Sep 17 00:00:00 2001 From: Danny Hermes Date: Mon, 27 Oct 2014 22:53:19 -0700 Subject: [PATCH 2/3] Removing overlap with tox.cover config in tox coveralls. --- tox.ini | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/tox.ini b/tox.ini index 8bc9aeab5f93..47107fc31bb6 100644 --- a/tox.ini +++ b/tox.ini @@ -23,8 +23,7 @@ deps = basepython = python2.7 commands = - nosetests --with-xunit --with-xcoverage --cover-package=gcloud \ - --nocapture --cover-erase --cover-tests --cover-branches + nosetests --with-xunit --with-xcoverage --cover-package=gcloud --nocapture --cover-erase --cover-tests --cover-branches deps = nose unittest2 @@ -32,18 +31,13 @@ deps = nosexcover [testenv:coveralls] -basepython = - python2.7 +basepython = {[testenv:cover]basepython} commands = - nosetests --with-xunit --with-xcoverage --cover-package=gcloud \ - --nocapture --cover-erase --cover-tests --cover-branches + {[testenv:cover]commands} coveralls deps = - coverage + {[testenv:cover]deps} coveralls - nose - nosexcover - unittest2 [testenv:docs] basepython = From 5c346cf8bc522249482e2829a15d0a6137642933 Mon Sep 17 00:00:00 2001 From: Danny Hermes Date: Tue, 28 Oct 2014 09:29:52 -0700 Subject: [PATCH 3/3] Fixing comment description in update_docs.sh. --- scripts/update_docs.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/update_docs.sh b/scripts/update_docs.sh index 19bb4016f1b5..6deb9e3dd69c 100755 --- a/scripts/update_docs.sh +++ b/scripts/update_docs.sh @@ -18,7 +18,7 @@ set -ev if [[ "${TRAVIS_BRANCH}" == "master" ]] && \ [[ "${TRAVIS_PULL_REQUEST}" == "false" ]]; then - # Generate new set of json files in docs/json/master. + # Build new docset in docs/_build from master. tox -e docs git submodule add -b gh-pages \ "https://${GH_OAUTH_TOKEN}@github.com/${GH_OWNER}/${GH_PROJECT_NAME}" \