From 68b65a3eace9ad33597da8397209b8ca904c08bd Mon Sep 17 00:00:00 2001 From: Craig Arthur Date: Sun, 22 Nov 2020 12:32:41 +1100 Subject: [PATCH] Travis CI migration (#109) * Get Windows environment working on Travis * Ensure order of unit test execution doesn't cause failues --- .travis.yml | 37 +++++++++++++------------ postinstall.sh | 46 ++++++++++++++++++++++++++++++++ preinstall.sh | 24 +++++++++++++++++ tests/test_processMultipliers.py | 7 ++--- 4 files changed, 92 insertions(+), 22 deletions(-) create mode 100644 postinstall.sh create mode 100644 preinstall.sh diff --git a/.travis.yml b/.travis.yml index b2da90c2..aef70720 100644 --- a/.travis.yml +++ b/.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: diff --git a/postinstall.sh b/postinstall.sh new file mode 100644 index 00000000..3bd82652 --- /dev/null +++ b/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 diff --git a/preinstall.sh b/preinstall.sh new file mode 100644 index 00000000..339b2536 --- /dev/null +++ b/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; \ No newline at end of file diff --git a/tests/test_processMultipliers.py b/tests/test_processMultipliers.py index f090e906..5f967177 100755 --- a/tests/test_processMultipliers.py +++ b/tests/test_processMultipliers.py @@ -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() @@ -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) @@ -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)