From 37a1bc38486dc46b87522bbb4fcd1bcdc5314093 Mon Sep 17 00:00:00 2001 From: KangWon LEE Date: Mon, 9 Sep 2019 14:39:46 +0900 Subject: [PATCH 1/2] build & test using GitHub Workflows --- .github/workflows/before_install.sh | 11 +++++ .github/workflows/install.sh | 47 +++++++++++++++++++++ .github/workflows/run_tests.sh | 29 +++++++++++++ .github/workflows/set_os_env.sh | 23 ++++++++++ .github/workflows/test_linux.yml | 32 ++++++++++++++ .github/workflows/test_osx.yml | 31 ++++++++++++++ .github/workflows/wget_install_miniconda.sh | 17 ++++++++ 7 files changed, 190 insertions(+) create mode 100644 .github/workflows/before_install.sh create mode 100644 .github/workflows/install.sh create mode 100644 .github/workflows/run_tests.sh create mode 100644 .github/workflows/set_os_env.sh create mode 100644 .github/workflows/test_linux.yml create mode 100644 .github/workflows/test_osx.yml create mode 100644 .github/workflows/wget_install_miniconda.sh diff --git a/.github/workflows/before_install.sh b/.github/workflows/before_install.sh new file mode 100644 index 00000000..0095f0aa --- /dev/null +++ b/.github/workflows/before_install.sh @@ -0,0 +1,11 @@ +if [[ $TEST_CONDA == 0 && $RUNNER_OS != "Linux" ]]; then + echo "Only Linux supported for non-Conda builds"; + exit 1; +fi +# from here on assume $TEST_CONDA == 0 implies $TRAVIS_OS_NAME == linux + +if [[ $TEST_CONDA == 0 ]]; then + sudo apt-get install liblapack-dev libblas-dev; + sudo apt-get install gfortran; + sudo apt-get install cmake; +fi diff --git a/.github/workflows/install.sh b/.github/workflows/install.sh new file mode 100644 index 00000000..2311e226 --- /dev/null +++ b/.github/workflows/install.sh @@ -0,0 +1,47 @@ +. ./.github/workflows/set_os_env.sh + +# +# Install miniconda to allow quicker installation of dependencies +# See https://conda.io/docs/user-guide/tasks/use-conda-with-travis-ci.html +# + +if [[ $RUNNER_OS == "macOS" ]]; then + . ./.github/workflows/wget_install_miniconda.sh +fi + +hash -r +conda config --set always_yes yes --set changeps1 no +conda update -q --all +if [[ $TEST_CONDA == 1 ]]; then + conda install conda-build; + conda install conda-verify; +fi +conda info -a + +# +# Set up a test environment for testing everything out +conda create -q -n test-environment python="$SLYCOT_PYTHON_VERSION" pip coverage nose numpy openblas +source activate test-environment + + +# install scikit-build +if [[ $TEST_CONDA == 0 ]]; then + conda config --append channels conda-forge; + conda install -c conda-forge scikit-build >=0.8.0 ; +fi +# +# Install the slycot package (two ways, to improve robustness). For the +# conda version, need to install lapack from conda-forge (no way to specify +# this in the recipe). +# add the conda-forge channel to the config, otherwise openblas or +# lapack cannot be found in the check +# with --override-channels to make sure the locally built slycot is installed +# +if [[ $TEST_CONDA == 1 ]]; then + conda config --append channels conda-forge; + conda build --python "$SLYCOT_PYTHON_VERSION" conda-recipe-openblas; + conda install conda-forge::openblas>=0.3.0; + conda install local::slycot; +else + CMAKE_GENERATOR="Unix Makefiles" python setup.py install; +fi diff --git a/.github/workflows/run_tests.sh b/.github/workflows/run_tests.sh new file mode 100644 index 00000000..d630e86c --- /dev/null +++ b/.github/workflows/run_tests.sh @@ -0,0 +1,29 @@ +# Local unit tests +# TODO: replace with nose? + +echo "start xvfb =====================================" +Xvfb :99 & +export DISPLAY=:99 + +. ./.github/workflows/set_os_env.sh + +echo "source activate test-environment ===============" +source activate test-environment +echo "change directory to .. =========================" +cd .. +echo "python Slycot/runtests.py ======================" +python Slycot/runtests.py --coverage --no-build + +# +# As a deeper set of tests, get test against python-control as well +# +# Additional packages required for python-control + +echo "conda install scipy matplotlib =================" +conda install scipy matplotlib +# Get python-control from source and install +echo "git clone python-control =======================" +git clone --depth 1 https://github.com/python-control/python-control.git control +cd control +echo "python python-control/setup.py test ===========" +python setup.py test diff --git a/.github/workflows/set_os_env.sh b/.github/workflows/set_os_env.sh new file mode 100644 index 00000000..950946ec --- /dev/null +++ b/.github/workflows/set_os_env.sh @@ -0,0 +1,23 @@ +echo "exporting env vars =============================" + +if [[ $RUNNER_OS == "Linux" ]]; then + export MINICONDA_PATH=$CONDA + export CONDA_SCRIPT=bin # l o + export BASHRC=.bashrc # l +elif [[ $RUNNER_OS == "macOS" ]]; then + export MINICONDA_PATH=$RUNNER_WORKSPACE/miniconda + export CONDA_SCRIPT=bin # l o + export BASHRC=.bash_profile # o w +elif [[ $RUNNER_OS == "Windows" ]]; then + export MINICONDA_PATH=`cygpath --unix $CONDA` + export CONDA_SCRIPT=Scripts # w + export BASHRC=.bash_profile # o w +fi + +export MINICONDA_SUB_PATH=$MINICONDA_PATH/$CONDA_SCRIPT +export MINICONDA_PYTEST=$MINICONDA_PATH/envs/test-environment/$CONDA_SCRIPT/py.test +# +# Make sure that fortran compiler can find conda libraries +# +export LIBRARY_PATH="$MINICONDA_PATH/envs/test-environment/lib"; +export PATH="$MINICONDA_PATH:$MINICONDA_SUB_PATH:$PATH" diff --git a/.github/workflows/test_linux.yml b/.github/workflows/test_linux.yml new file mode 100644 index 00000000..6237d24d --- /dev/null +++ b/.github/workflows/test_linux.yml @@ -0,0 +1,32 @@ +name: CI linux + +on : [push] + +jobs: + build: + name: Python ${{ matrix.python }} with TEST_CONDA=${{ matrix.test_conda }} + runs-on: ubuntu-16.04 + strategy: + matrix: + python: [2.7, 3.5, 3.6, 3.7] + test_conda: [0, 1] + steps: + - uses: actions/checkout@v1 + - name: before install + env: + TEST_CONDA: ${{ matrix.test_conda }} + run: + source ./.github/workflows/before_install.sh + - name: install + env: + SLYCOT_PYTHON_VERSION: ${{ matrix.os }} + TEST_CONDA: ${{ matrix.test_conda }} + run: + source ./.github/workflows/install.sh + - name: run tests + run: + source ./.github/workflows/run_tests.sh + - name: coverall + run: + pip install coveralls + coveralls diff --git a/.github/workflows/test_osx.yml b/.github/workflows/test_osx.yml new file mode 100644 index 00000000..3c928530 --- /dev/null +++ b/.github/workflows/test_osx.yml @@ -0,0 +1,31 @@ +name: CI osx + +on : [push] + +jobs: + build: + name: Python ${{ matrix.python }} with TEST_CONDA=1 + runs-on: macOS-10.14 + strategy: + matrix: + python: [2.7, 3.5, 3.6, 3.7] + steps: + - uses: actions/checkout@v1 + - name: before install + env: + TEST_CONDA: 1 + run: + source ./.github/workflows/before_install.sh + - name: install + env: + SLYCOT_PYTHON_VERSION: ${{ matrix.os }} + TEST_CONDA: 1 + run: + source ./.github/workflows/install.sh + - name: run tests + run: + source ./.github/workflows/run_tests.sh + - name: coverall + run: + pip install coveralls + coveralls diff --git a/.github/workflows/wget_install_miniconda.sh b/.github/workflows/wget_install_miniconda.sh new file mode 100644 index 00000000..687f9176 --- /dev/null +++ b/.github/workflows/wget_install_miniconda.sh @@ -0,0 +1,17 @@ +echo "============================================" +echo "Downloading and Installing Miniconda for" +echo "============================================" + +export MINICONDA_DOWNLOAD=$MINICONDA_PATH/download +echo "MINICONDA_DOWNLOAD = $MINICONDA_DOWNLOAD" + +mkdir -p $MINICONDA_DOWNLOAD; +echo "downloading miniconda.sh for osx ===========" +wget https://repo.continuum.io/miniconda/Miniconda3-latest-MacOSX-x86_64.sh -O $MINICONDA_DOWNLOAD/miniconda.sh; + +echo "installing miniconda =======================" +bash $MINICONDA_DOWNLOAD/miniconda.sh -b -u -p $MINICONDA_PATH; + +echo "============================================" +echo "Finished Installing Miniconda" +echo "============================================" From 0545b2690b77838c0510799bb846cbb4bf640c8b Mon Sep 17 00:00:00 2001 From: KangWon LEE Date: Sat, 5 Oct 2019 00:05:17 +0900 Subject: [PATCH 2/2] echo vars --- .github/workflows/set_os_env.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/set_os_env.sh b/.github/workflows/set_os_env.sh index 950946ec..8c8eb833 100644 --- a/.github/workflows/set_os_env.sh +++ b/.github/workflows/set_os_env.sh @@ -21,3 +21,11 @@ export MINICONDA_PYTEST=$MINICONDA_PATH/envs/test-environment/$CONDA_SCRIPT/py.t # export LIBRARY_PATH="$MINICONDA_PATH/envs/test-environment/lib"; export PATH="$MINICONDA_PATH:$MINICONDA_SUB_PATH:$PATH" + +echo "MINICONDA_PATH=$MINICONDA_PATH" +echo "CONDA_SCRIPT=$CONDA_SCRIPT" +echo "BASHRC=$BASHRC" +echo "MINICONDA_SUB_PATH=$MINICONDA_SUB_PATH" +echo "MINICONDA_PYTEST=$MINICONDA_PYTEST" +echo "LIBRARY_PATH=$LIBRARY_PATH" +echo "PATH=$PATH"