Skip to content

Commit

Permalink
Travis CI migration (#109)
Browse files Browse the repository at this point in the history
* Get Windows environment working on Travis
* Ensure order of unit test execution doesn't cause failues
  • Loading branch information
wcarthur committed Nov 22, 2020
1 parent e036c31 commit 68b65a3
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 22 deletions.
37 changes: 18 additions & 19 deletions .travis.yml
@@ -1,30 +1,29 @@
language: python
python:
- '3.6'
- '3.7'
- '3.8'
language: shell

env:
- PYTHON_VERSION=3.6
- PYTHON_VERSION=3.7
- PYTHON_VERSION=3.8

os:
- linux
- windows

before_install:
- source ./preinstall.sh

install:
- sudo apt-get update
- wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh
# install in batch mode i.e. no input
- bash Miniconda3-latest-Linux-x86_64.sh -b -p $HOME/conda
- export PATH="$HOME/conda/bin:$PATH"
# clear bash cache table
- hash -r
- conda config --set always_yes yes
- conda config --set changeps1 no
- conda update -q conda
- conda config --add channels conda-forge
- conda config --set channel_priority strict
- conda env create -q -f tcrmenv.yml python=$TRAVIS_PYTHON_VERSION
- source activate tcrm
- source ./postinstall.sh

branches:
except:
- config
- notebooks

script:
- python installer/setup.py build_ext -i
- nosetests -v --with-coverage --cover-package=.

after_success: coveralls
notifications:
slack:
Expand Down
46 changes: 46 additions & 0 deletions postinstall.sh
@@ -0,0 +1,46 @@
# begin installing miniconda
if [[ "$TRAVIS_OS_NAME" != "windows" ]]; then
echo "installing miniconda for posix";
bash $HOME/download/miniconda.sh -b -u -p $MINICONDA_PATH;
elif [[ "$TRAVIS_OS_NAME" == "windows" ]]; then
echo "folder $MINICONDA_SUB_PATH does not exist"
echo "installing miniconda for windows";
choco install miniconda3 --params="'/JustMe /AddToPath:1 /D:$MINICONDA_PATH_WIN'";
fi;
# end installing miniconda

export PATH="$MINICONDA_PATH:$MINICONDA_SUB_PATH:$MINICONDA_LIB_BIN_PATH:$PATH";

# begin checking miniconda existance
echo "checking if folder $MINICONDA_SUB_PATH exists"
if [[ -d $MINICONDA_SUB_PATH ]]; then
echo "folder $MINICONDA_SUB_PATH exists"
else
echo "folder $MINICONDA_SUB_PATH does not exist"
fi;
# end checking miniconda existance

source $MINICONDA_PATH/etc/profile.d/conda.sh;
hash -r;
echo $TRAVIS_OS_NAME
echo $PYTHON_VERSION
python --version

if [[ "$TRAVIS_OS_NAME" == "windows" ]]; then
echo "Removing mpi4py from environment for windows build"
echo "Package not available in conda channels"
sed -i '/mpi4py/d' ./tcrmenv.yml
fi

conda config --set always_yes yes --set changeps1 no;
conda update -q conda;
conda config --add channels conda-forge;
conda config --set channel_priority strict;
# Useful for debugging any issues with conda
conda info -a

echo "Create TCRM environment"
conda env create -q -f tcrmenv.yml python=$PYTHON_VERSION;
conda activate tcrm
python --version
conda list
24 changes: 24 additions & 0 deletions preinstall.sh
@@ -0,0 +1,24 @@
if [[ "$TRAVIS_OS_NAME" != "windows" ]]; then
export MINICONDA_PATH=$HOME/miniconda;
export MINICONDA_SUB_PATH=$MINICONDA_PATH/bin;
elif [[ "$TRAVIS_OS_NAME" == "windows" ]]; then
export MINICONDA_PATH=$HOME/miniconda;
export MINICONDA_PATH_WIN=`cygpath --windows $MINICONDA_PATH`;
export MINICONDA_SUB_PATH=$MINICONDA_PATH/Scripts;
fi;
export MINICONDA_LIB_BIN_PATH=$MINICONDA_PATH/Library/bin;
# Obtain miniconda installer
if [[ "$TRAVIS_OS_NAME" != "windows" ]]; then
mkdir -p $HOME/download;
if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
echo "downloading miniconda.sh for linux";
wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O $HOME/download/miniconda.sh;
elif [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
echo "downloading miniconda.sh for osx";
wget https://repo.continuum.io/miniconda/Miniconda3-latest-MacOSX-x86_64.sh -O $HOME/download/miniconda.sh;
fi;
fi;
# Install openssl for Windows
if [[ "$TRAVIS_OS_NAME" == "windows" ]]; then
choco install openssl.light;
fi;
7 changes: 4 additions & 3 deletions tests/test_processMultipliers.py
Expand Up @@ -21,7 +21,7 @@
try:
from . import pathLocate
except:
from unittests import pathLocate
from tests import pathLocate

# Add parent folder to python path
unittest_dir = pathLocate.getUnitTestDirectory()
Expand Down Expand Up @@ -250,8 +250,8 @@ def test_generate_syn_mult_img(self):

shutil.rmtree(dir_path)

def test_computeOutputExtentIfInvalid(self):
"""Test createRaster returns a gdal dataset"""
def test_resetOutputExtentIfInvalid(self):
"""Test computation of output extent"""

# Write a .nc file to test with dummy data. This is the gust file
f_nc = tempfile.NamedTemporaryFile(suffix='.nc', prefix='test_processMultipliers', delete=False)
Expand Down Expand Up @@ -335,6 +335,7 @@ def test_xprocessMult_A(self):

if __name__ == "__main__":
# Suite = unittest.makeSuite(TestProcessMultipliers, 'test_x')
unittest.TestLoader.sortTestMethodsUsing = None
Suite = unittest.makeSuite(TestProcessMultipliers, 'test')
Runner = unittest.TextTestRunner()
Runner.run(Suite)

0 comments on commit 68b65a3

Please sign in to comment.