Skip to content

Commit

Permalink
Refactor travis tests and pypi deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
show0k committed Dec 13, 2017
1 parent 3b0f5f0 commit 3546c9e
Show file tree
Hide file tree
Showing 4 changed files with 112 additions and 154 deletions.
53 changes: 23 additions & 30 deletions .travis.yml
@@ -1,13 +1,13 @@
# Language is set to c because python isn't supported on the OSX Virtual Machines
# on Travis. Anyway, python is install from conda.
language: c
language: generic

env:
global:
# - USE_SSH_FORWARDING=true

# Directory of setup.py
- SETUP_DIR=$TRAVIS_BUILD_DIR/.
# PyPi credentials foru ploads to Pypi on release.
# PyPi credentials for uploads to PyPi on release.
- PYPI_USERNAME=pierre-rouanet
# PYPI_PASSWD encrypted below > travis encrypt PYPI_PASSWD=XXXXXX --add
- secure: "ovWnNtOxp9SzfayLkI/NbeQld76FatyUm7Bdj6d9XWxokQpj130pf5uBwrUs32TCDmWJxfIC/8Jn7IA4kMWLzH/hN+M6AIc290EiSmLNaNU4HOh6hdx6qERHLSoPFVHgI1xPTEUouNWXkP3LR8nFja/iK1ai4ecGUBoIrtG0TW4=" # Used to built the repo URL https://github.com/$GH_USERNAME/$GH_USERNAME.git
Expand All @@ -20,41 +20,42 @@ env:
- secure: "TgJGS9wFmr9zrUSMFDSH/p4sj77+6FwGUpQin4Sfl97cEXoHjeKrDsJvkEV8HZG2mAHnMyMeEqnzJbmCdhCB+9GAu31hdpXies6fA0tFDgtMUbf2lD16M7pL8jJ3zTxR4FCXLLd6ST3x+HLSrPfITkbNvOt1jmgVXdVTHKsSLRM="

# V-REP conf
- VREP_VERSION=3_1_2
- VREP_ROOT_DIR=$TRAVIS_BUILD_DIR/vrep
# - VREP_VERSION=3_1_2
# - VREP_ROOT_DIR=$TRAVIS_BUILD_DIR/vrep

# travis encrypt id_rsa_encrypted_key=...
# openssl aes-256-cbc -k $id_rsa_encrypted_key -in ../id_rsa -out id_rsa.enc
# Key of encrypted id_rsa, ssh private key
- id_rsa_encrypted_key=fze16fz1ra6!
# - id_rsa_encrypted_key=fze16fz1ra6!


matrix:
# Don't wait for allowed failures
fast_finish: true

include:
# hack to use MAC-OSX VM
- os: osx
python: 2.7 # For travis UI only
language: objective-c
env: TRAVIS_OS_NAME=osx TRAVIS_PYTHON_VERSION=2.7

- os: osx
python: 3.5 # For travis UI only
language: objective-c
env: TRAVIS_OS_NAME=osx TRAVIS_PYTHON_VERSION=3.5

- os: osx
python: 3.6 # For travis UI only
language: objective-c
env: TRAVIS_OS_NAME=osx TRAVIS_PYTHON_VERSION=3.6

# Remove OSX builds temporally as they are very slow to startup
# - os: osx
# python: 2.7 # For travis UI only
# osx_image: xcode6.4
# env: TRAVIS_OS_NAME=osx TRAVIS_PYTHON_VERSION=2.7

# - os: osx
# python: 3.6 # For travis UI only
# osx_image: xcode6.4
# env: TRAVIS_OS_NAME=osx TRAVIS_PYTHON_VERSION=3.6

# Linux VM
# Python 3.4 is not supported anymore by conda
# https://github.com/ContinuumIO/anaconda-issues/issues/6615

- python: 2.7
os: linux
language: python
env: UPDATE_DOC=true
env:
- UPDATE_DOC=true
- PEP8_CAUSE_FAILLURE=true

- python: 3.5
language: python
Expand All @@ -64,23 +65,15 @@ matrix:
language: python
os: linux

- python: 3.5
language: python
os: linux
env: PEP8_CAUSE_FAILLURE=true

addons:
apt:
packages:
# Spoof x11 for starting vrep in travis (issues with network)
- xvfb
# For building the pdf documentation
- texlive
- texlive-latex-extra
- dvipng

before_install:
- rvm get head
- . ./ci/before_install.sh

install:
Expand Down
91 changes: 33 additions & 58 deletions ci/after_success_release.sh
Expand Up @@ -3,69 +3,44 @@ set -e
set -x
echo "Running after_success_release.sh on $TRAVIS_OS_NAME"

# Exit if commit is untrusted
if [[ "$TRAVIS" == "true" ]]; then
if [ "$TRAVIS_PULL_REQUEST" != "false" -o "$TRAVIS_BRANCH" != "master" ]; then
echo "This is an untrusted commit. No deployment will be done."
else
echo "Installing wheel..."
pip install -q wheel --user || exit
echo "Installing twine..."
pip install -q twine --user || exit
echo "Installing wheel..."
pip install -q wheel || exit
echo "Installing twine..."
pip install -q twine || exit

echo "Creating distribution files..."
if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then

python setup.py -q sdist bdist_wheel

echo "Creating distribution files..."
if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
echo "Created the following distribution files:"
ls -l dist

# remove error on python 3.4
# ValueError: invalid prefix: filename '/home/travis/miniconda3/lib/python3.4/site-packages/pypot/__init__.py' doesn't start with 'build/bdist.linux-x86_64/dumb'
if [[ "$TRAVIS_PYTHON_VERSION" == "3.4" ]];then
set +e
fi
# This release build creates the source distribution. All other release builds
# should not.
python setup.py -q sdist bdist_egg
# Test dist files
for f in dist/*; do
pip install "$f"
done

echo "Created the following distribution files:"
ls -l dist
# These should get created on linux:
# ...-cp27-none-linux-x86_64.whl
# ....linux-x86_64.tar.gz
# ...-py2.7-linux-x86_64.egg
# ....tar.gz

set +x
set +e
# Test dist files
for f in dist/*; do
pip install $f
done
echo "Uploading Linux egg to PyPi..."
twine upload dist/*.egg -u "${PYPI_USERNAME}" -p "${PYPI_PASSWD}"
echo "Uploading source package to PyPi..."
twine upload dist/*.tar.gz -u "${PYPI_USERNAME}" -p "${PYPI_PASSWD}"

# We can't upload the wheel to PyPi because PyPi rejects linux platform wheel
# files.
# See: https://bitbucket.org/pypa/pypi-metadata-formats/issue/15/enhance-the-platform-tag-definition-for
elif [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
python setup.py bdist_wheel || exit
echo "Created the following distribution files:"
ls -l dist

elif [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
python setup.py bdist bdist_wheel || exit
echo "Created the following distribution files:"
ls -l dist
set +x
set +e
# Test dist files
for f in dist/*; do
pip install $f
done
echo "Uploading OS X egg to PyPi..."
twine upload dist/*.egg -u "${PYPI_USERNAME}" -p "${PYPI_PASSWD}"
echo "Uploading OS X Wheel package to PyPi..."
twine upload dist/*.whl -u "${PYPI_USERNAME}" -p "${PYPI_PASSWD}"
# Test dist files
for f in dist/*; do
pip install "$f"
done

echo "Attempting to upload all distribution files to PyPi..."
twine upload dist/* -u "${PYPI_USERNAME}" -p "${PYPI_PASSWD}"
fi
fi
fi

if [[ "$TRAVIS" == "true" ]]; then
if [ "$TRAVIS_PULL_REQUEST" != "false" ] || [ "$TRAVIS_BRANCH" != "master" ]; then
echo "This is an untrusted commit. No deployment will be done."
else
echo "Attempting to upload all distribution files to PyPi..."
set +x
set +e
twine upload dist/* -u "${PYPI_USERNAME}" -p "${PYPI_PASSWD}"
fi
fi
110 changes: 55 additions & 55 deletions ci/before_install.sh
@@ -1,75 +1,75 @@
#!/bin/bash
#!/bin/bash
set -x
set -e
echo "Running before_install.sh on $TRAVIS_OS_NAME"
echo "Checking OS : PWD = $PWD, HOME=$HOME"

# Keept for hystory, not used anymore
if [[ -n "$SSH_VREP_SERVER" ]]; then
set +x
set -e
rm -r ~/.ssh
mkdir ~/.ssh
# Decrypt ssh private key
openssl aes-256-cbc -k $id_rsa_encrypted_key -in ci/id_rsa.enc -out ci/id_rsa.out -d -v
cp ci/known_hosts ~/.ssh/known_hosts
cp ci/id_rsa.out ~/.ssh/id_rsa
chmod 700 ~/.ssh/id_rsa
chmod 700 ci/id_rsa.out
echo -e "Host *.ci \n ProxyCommand ssh tseg001@ci-ssh.inria.fr \"/usr/bin/nc \`basename %h .ci\` %p\" \n UserKnownHostsFile=/dev/null\n StrictHostKeyChecking=no" > ~/.ssh/config
echo "Starting SSH proxy daemon"
ssh -i ci/id_rsa.out -t -t -v -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -N -L 19997:localhost:19997 ci@"$SSH_VREP_SERVER" &
sleep 5
set -x
set +x
set -e
rm -r ~/.ssh
mkdir ~/.ssh
# Decrypt ssh private key
openssl aes-256-cbc -k $id_rsa_encrypted_key -in ci/id_rsa.enc -out ci/id_rsa.out -d -v
cp ci/known_hosts ~/.ssh/known_hosts
cp ci/id_rsa.out ~/.ssh/id_rsa
chmod 700 ~/.ssh/id_rsa
chmod 700 ci/id_rsa.out
echo -e "Host *.ci \n ProxyCommand ssh tseg001@ci-ssh.inria.fr \"/usr/bin/nc \`basename %h .ci\` %p\" \n UserKnownHostsFile=/dev/null\n StrictHostKeyChecking=no" > ~/.ssh/config
echo "Starting SSH proxy daemon"
ssh -i ci/id_rsa.out -t -t -v -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -N -L 19997:localhost:19997 ci@"$SSH_VREP_SERVER" &
sleep 5
set -x
fi

if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
# Display os with more verbose than $TRAVIS_OS_NAME
lsb_release -a
# Display os with more verbose than $TRAVIS_OS_NAME
lsb_release -a
# Travis use automatically virtualenv version of python

# Download V-REP
# wget http://coppeliarobotics.com/V-REP_PRO_EDU_V${VREP_VERSION}_64_Linux.tar.gz
# tar -xzf V-REP_PRO_EDU_V${VREP_VERSION}_64_Linux.tar.gz
# mv ./V-REP_PRO_EDU_V${VREP_VERSION}_64_Linux $VREP_ROOT_DIR

# Use miniconda python (provide binaries for scipy and numpy on Linux)
if [[ "$TRAVIS_PYTHON_VERSION" == "2.7" ]]; then
curl -L -o miniconda.sh http://repo.continuum.io/miniconda/Miniconda2-latest-Linux-x86_64.sh
else
curl -L -o miniconda.sh http://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh
fi
# # Use miniconda python (provide binaries for scipy and numpy on Linux)
# if [[ "$TRAVIS_PYTHON_VERSION" == "2.7" ]]; then
# curl -L -o miniconda.sh http://repo.continuum.io/miniconda/Miniconda2-latest-Linux-x86_64.sh
# else
# curl -L -o miniconda.sh http://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh
# fi
elif [[ "$TRAVIS_OS_NAME" == "osx" ]]; then

# Download V-REP
# wget http://coppeliarobotics.com/V-REP_PRO_EDU_V${VREP_VERSION}_Mac.zip
# unzip -qq V-REP_PRO_EDU_V${VREP_VERSION}_Mac.zip
# mv ./V-REP_PRO_EDU_V${VREP_VERSION}_Mac $VREP_ROOT_DIR
echo "Removing homebrew from Travis CI to avoid conflicts."
curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall > ~/uninstall_homebrew
chmod +x ~/uninstall_homebrew
~/uninstall_homebrew -fq
rm ~/uninstall_homebrew

# brew update
# Use miniconda python (provide binaries for scipy and numpy on Linux)
if [[ "$TRAVIS_PYTHON_VERSION" == "2.7" ]]; then
curl -L -o miniconda.sh http://repo.continuum.io/miniconda/Miniconda2-latest-MacOSX-x86_64.sh
else
curl -L -o miniconda.sh http://repo.continuum.io/miniconda/Miniconda3-latest-MacOSX-x86_64.sh
fi

# Use miniconda python (provide binaries for scipy and numpy on Linux)
if [[ "$TRAVIS_PYTHON_VERSION" == "2.7" ]]; then
curl -L -o miniconda.sh http://repo.continuum.io/miniconda/Miniconda2-latest-MacOSX-x86_64.sh
else
curl -L -o miniconda.sh http://repo.continuum.io/miniconda/Miniconda3-latest-MacOSX-x86_64.sh
fi
fi

chmod +x miniconda.sh
./miniconda.sh -b -p $HOME/miniconda
# Install python version corresponding to travis setting
$HOME/miniconda/bin/conda config --set always_yes yes --set changeps1 no
$HOME/miniconda/bin/conda create --name=travis python=$TRAVIS_PYTHON_VERSION

# Use travis conda env as default
export PATH=$HOME/miniconda/envs/travis/bin:$PATH
hash -r

chmod +x miniconda.sh
./miniconda.sh -b -p $HOME/miniconda
export PATH=$HOME/miniconda/bin:$PATH
hash -r
conda config --set always_yes yes --set changeps1 no
conda update -q conda
conda update -q conda

# conda create
# source activate condaenv
conda install --yes pip python=$TRAVIS_PYTHON_VERSION
# conda create
# source activate condaenv
conda install --yes pip python=$TRAVIS_PYTHON_VERSION

# Show config
which python
which pip
# Show config
which python
which pip

# Remove useless outputs in STDOUT
set +x
# Remove useless outputs in STDOUT
set +x
fi
12 changes: 1 addition & 11 deletions ci/run_tests.sh
Expand Up @@ -33,17 +33,7 @@ else

pip uninstall -y poppy-creature poppy-humanoid
fi

# Old test of running VREP localy (network trouble)
# pushd $VREP_ROOT_DIR/
# if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
# xvfb-run --auto-servernum --server-num=1 ./vrep.sh -h &
# else
# ./vrep.app/Contents/MacOS/vrep -h &
# fi
# sleep 10
# popd
# python ci/test_vrep.py

popd

pushd tests
Expand Down

0 comments on commit 3546c9e

Please sign in to comment.