From 2edb303afc3c256550a6b801a3d3350b17135561 Mon Sep 17 00:00:00 2001 From: Adi Roiban Date: Tue, 12 Jul 2016 16:19:20 +0100 Subject: [PATCH] Use dedicated scripts for travis install and run. --- .travis.yml | 8 ++++-- .travis/install.sh | 70 ++++++++++++++++++++++++++++++++++++++++++++++ .travis/run.sh | 22 +++++++++++++++ 3 files changed, 98 insertions(+), 2 deletions(-) create mode 100755 .travis/install.sh create mode 100755 .travis/run.sh diff --git a/.travis.yml b/.travis.yml index b7c39444419..bb0d8b0f5e7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -30,8 +30,11 @@ env: global: - TRIAL_REPORTER=text +# Install packages in a virtualenv. +# Install the virtualenv if required. +# Install Python version if required. install: - - pip install tox tox-travis + - ./.travis/install.sh tox tox-travis # FIXME: https://twistedmatrix.com/trac/ticket/8373 @@ -42,5 +45,6 @@ before_script: - git remote set-branches --add origin trunk - git fetch origin trunk +# Run tox from the created virtualenv. script: - - tox + - ./.travis/run.sh diff --git a/.travis/install.sh b/.travis/install.sh new file mode 100755 index 00000000000..7e114c48671 --- /dev/null +++ b/.travis/install.sh @@ -0,0 +1,70 @@ +#!/bin/bash +# +# Copied from +# https://github.com/pyca/cryptography/blob/master/.travis/install.sh +# + +set -e +set -x + +if [[ "$(uname -s)" == 'Darwin' ]]; then + brew update || brew update + + brew outdated openssl || brew upgrade openssl + + # install pyenv + git clone https://github.com/yyuu/pyenv.git ~/.pyenv + PYENV_ROOT="$HOME/.pyenv" + PATH="$PYENV_ROOT/bin:$PATH" + eval "$(pyenv init -)" + + case "${TOXENV}" in + py27) + curl -O https://bootstrap.pypa.io/get-pip.py + python get-pip.py --user + ;; + py33) + pyenv install 3.3.6 + pyenv global 3.3.6 + ;; + py34) + pyenv install 3.4.4 + pyenv global 3.4.4 + ;; + py35) + pyenv install 3.5.1 + pyenv global 3.5.1 + ;; + pypy*) + pyenv install "pypy-$PYPY_VERSION" + pyenv global "pypy-$PYPY_VERSION" + ;; + pypy3) + pyenv install pypy3-2.4.0 + pyenv global pypy3-2.4.0 + ;; + docs) + curl -O https://bootstrap.pypa.io/get-pip.py + python get-pip.py --user + ;; + esac + pyenv rehash + python -m pip install --user virtualenv +else + # temporary pyenv installation to get latest pypy until the travis + # container infra is upgraded + if [[ "${TOXENV}" = pypy* ]]; then + git clone https://github.com/yyuu/pyenv.git ~/.pyenv + PYENV_ROOT="$HOME/.pyenv" + PATH="$PYENV_ROOT/bin:$PATH" + eval "$(pyenv init -)" + pyenv install "pypy-$PYPY_VERSION" + pyenv global "pypy-$PYPY_VERSION" + fi + + pip install virtualenv +fi + +python -m virtualenv ~/.venv +source ~/.venv/bin/activate +pip install $@ diff --git a/.travis/run.sh b/.travis/run.sh new file mode 100755 index 00000000000..bb42d01e956 --- /dev/null +++ b/.travis/run.sh @@ -0,0 +1,22 @@ +#!/bin/bash +# +# Copied from +# https://github.com/pyca/cryptography/blob/master/.travis/run.sh +# +set -e +set -x + +if [[ "$(uname -s)" == "Darwin" ]]; then + # initialize our pyenv + PYENV_ROOT="$HOME/.pyenv" + PATH="$PYENV_ROOT/bin:$PATH" + eval "$(pyenv init -)" +else + if [[ "${TOXENV}" == "pypy" ]]; then + PYENV_ROOT="$HOME/.pyenv" + PATH="$PYENV_ROOT/bin:$PATH" + eval "$(pyenv init -)" + fi +fi +source ~/.venv/bin/activate +tox -- $TOX_FLAGS