Skip to content

Commit

Permalink
Include setup helper scripts in tardis
Browse files Browse the repository at this point in the history
We can't use an external repository because we are hacking the scripts
heavily to work with a conda environment file instead of defining the
dependencies with environment variables in .travis.yml.
  • Loading branch information
yeganer committed Sep 8, 2017
1 parent eac566a commit 64c30bc
Show file tree
Hide file tree
Showing 5 changed files with 116 additions and 5 deletions.
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,7 @@ install:
# in how to install a package, in which case you can have additional
# commands in the install: section below.

- git clone git://github.com/yeganer/ci-helpers.git
- source ci-helpers/travis/setup_conda.sh
- source travis/setup_conda.sh
- source travis/before_install.sh

# As described above, using ci-helpers, you should be able to set up an
Expand Down
3 changes: 0 additions & 3 deletions travis/before_install.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
conda env create -f tardis_env27.yml
source activate tardis

if [[ $SETUP_CMD == *coverage* ]]; then
conda install -c conda-forge git-lfs=2.2.1 -y
git lfs install --skip-smudge
Expand Down
62 changes: 62 additions & 0 deletions travis/setup_conda.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#!/bin/bash

# Note to the future: keep the conda scripts separate for each OS because many
# packages call ci-helpers with:
#
# source ci-helpers/travis/setup_conda_$TRAVIS_OS_NAME.sh
#
# The present script was added later.

if [[ $DEBUG == True ]]; then
set -x
fi

# First check: if the build should be run at all based on the event type

if [[ ! -z $EVENT_TYPE ]]; then
for event in $EVENT_TYPE; do
if [[ $TRAVIS_EVENT_TYPE = $event ]]; then
allow_to_build=True
fi
done
if [[ $allow_to_build != True ]]; then
travis_terminate 0
fi
fi

# Second check: if any of the custom tags are used to skip the build

TR_SKIP="\[(skip travis|travis skip)\]"
DOCS_ONLY="\[docs only|build docs\]"

# Travis doesn't provide the commit message of the top of the branch for
# PRs, only the commit message of the merge. Thus this ugly workaround is
# needed for now.

if [[ $TRAVIS_PULL_REQUEST == false ]]; then
COMMIT_MESSAGE=${TRAVIS_COMMIT_MESSAGE}
else
COMMIT_MESSAGE=$(git show -s $TRAVIS_COMMIT_RANGE | awk 'BEGIN{count=0}{if ($1=="Author:") count++; if (count==1) print $0}')
fi

# Skip build if the commit message contains [skip travis] or [travis skip]
# Remove workaround once travis has this feature natively
# https://github.com/travis-ci/travis-ci/issues/5032

if [[ ! -z $(echo ${COMMIT_MESSAGE} | grep -E "${TR_SKIP}") ]]; then
echo "Travis was requested to be skipped by the commit message, exiting."
travis_terminate 0
elif [[ ! -z $(echo ${COMMIT_MESSAGE} | grep -E "${DOCS_ONLY}") ]]; then
if [[ $SETUP_CMD != *build_docs* ]] && [[ $SETUP_CMD != *build_sphinx* ]]; then
echo "Only docs build was requested by the commit message, exiting."
travis_terminate 0
fi
fi

echo "==================== Starting executing ci-helpers scripts ====================="

source travis/setup_conda_$TRAVIS_OS_NAME.sh;

echo "================= Returning executing local .travis.yml script ================="

set +x
23 changes: 23 additions & 0 deletions travis/setup_conda_linux.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash

# Install conda
# http://conda.pydata.org/docs/travis.html#the-travis-yml-file
echo ls -la $HOME/miniconda
ls -la $HOME/miniconda
if [ ! "$(ls -A $HOME/miniconda)" ]; then
echo "Cache is empty, installing miniconda and test environment."
# Control will enter here if $HOME/miniconda is empty.
rm -r $HOME/miniconda
wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh
bash miniconda.sh -b -p $HOME/miniconda

export PATH="$HOME/miniconda/bin:$PATH"

hash -r

conda env create -f tardis_env27.yml
else
export PATH="$HOME/miniconda/bin:$PATH"
fi

source activate tardis
30 changes: 30 additions & 0 deletions travis/setup_conda_osx.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash

# Workaround for https://github.com/travis-ci/travis-ci/issues/6307, which
# caused the following error on MacOS X workers:
#
# /Users/travis/build.sh: line 109: shell_session_update: command not found
#
rvm get head

# Install conda
# http://conda.pydata.org/docs/travis.html#the-travis-yml-file
echo ls -la $HOME/miniconda
ls -la $HOME/miniconda
if [ ! "$(ls -A $HOME/miniconda)" ]; then
echo "Cache is empty, installing miniconda and test environment."
# Control will enter here if $HOME/miniconda is empty.
rm -r $HOME/miniconda
# Control will enter here if $HOME/miniconda doesn't exist.
wget https://repo.continuum.io/miniconda/Miniconda3-latest-MacOSX-x86_64.sh -O miniconda.sh

export PATH="$HOME/miniconda/bin:$PATH"

hash -r

conda env create -f tardis_env27.yml
else
export PATH="$HOME/miniconda/bin:$PATH"
fi

source activate tardis

0 comments on commit 64c30bc

Please sign in to comment.