From 33ee71fd3113bcce5ebcb55baa4ce51d24d6e55a Mon Sep 17 00:00:00 2001
From: u214892 <u214892@sbb.ch>
Date: Thu, 11 Jul 2019 11:30:39 +0200
Subject: [PATCH] #97 tox-conda #94 use miniconda instead of anaconda

---
 .gitlab-ci.yml                      | 12 +++++++
 getting_started/getting_started.bat | 44 +++----------------------
 getting_started/getting_started.sh  | 51 +++--------------------------
 tox.ini                             | 44 +++++++++++++++++++------
 4 files changed, 54 insertions(+), 97 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 02a7155..aa5a5fc 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -11,6 +11,7 @@ image: themattrix/tox
 
 stages:
     - tests
+    - integration_testing
     - benchmarks_and_profiling
     - deploy_docs
 cache:
@@ -32,6 +33,7 @@ tests:
         - conda install -c conda-forge tox-conda
     script:
         - xvfb-run tox -v --recreate
+        - xvfb-run tox -e notebooks -v --recreate
 
 build_and_deploy_docs:
     image: "python:latest"
@@ -76,4 +78,14 @@ benchmarks_and_profiling:
     script:
         - xvfb-run tox -e benchmarks,profiling -v --recreate
 
+test_conda_setup:
+    stage: integration_testing
+    before_script:
+        - apt update
+        - apt install -y libgl1-mesa-glx xvfb graphviz xdg-utils libcairo2-dev libjpeg-dev libgif-dev
+        - wget -nv https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O /tmp/Miniconda3-latest-Linux-x86_64.sh
+        - bash /tmp/Miniconda3-latest-Linux-x86_64.sh -b -p /tmp/miniconda3
+    script:
+        - export PATH=/tmp/miniconda3/bin:$PATH; bash getting_started/getting_started.sh
+
 
diff --git a/getting_started/getting_started.bat b/getting_started/getting_started.bat
index 3289769..d0da9b6 100644
--- a/getting_started/getting_started.bat
+++ b/getting_started/getting_started.bat
@@ -2,47 +2,11 @@
 
 set FLATLAND_BASEDIR=%~dp0\..
 
-@echo off
-echo "************ TESTING PREREQUISITES PYTHON3 + GIT + GIT *************************"
-@echo on
-
-git --version || goto :error
-python --version || goto :error
-
-
-@echo off
-echo "************ SETUP VIRTUAL ENVIRONMENT FLATLAND *************************"
-@echo on
-(conda info --envs | findstr flatland-rl) || conda create python=3.6 -y --name flatland-rl || goto :error
-(call conda activate flatland-rl || call activate flatland-rl) || goto :error
-
-
-@echo off
-echo "************ INSTALL FLATLAND AND DEPENDENCIES IN THE VIRTUALENV  *************************"
-@echo on
-rem TODO we should get rid of having to install these packages outside of setup.py with conda!
-call conda install -y -c conda-forge cairosvg pycairo || goto :error
-call conda install -y -c anaconda tk || goto :error
-call python -m pip install --upgrade pip || goto :error
-python setup.py install || goto :error
-
-# ensure jupyter is installed in the virtualenv
-python -m pip install --upgrade -r %FLATLAND_BASEDIR%/requirements_dev.txt -r %FLATLAND_BASEDIR%/requirements_continuous_integration.txt || goto :error
+cd %FLATLAND_BASEDIR%
 
-
-@echo off
-echo "************ INSTALL JUPYTER EXTENSION *************************"
-@echo on
-jupyter nbextension install --py --sys-prefix widgetsnbextension || goto :error
-jupyter nbextension enable --py --sys-prefix widgetsnbextension || goto :error
-jupyter nbextension install --py --sys-prefix jpy_canvas || goto :error
-jupyter nbextension enable --py --sys-prefix jpy_canvas || goto :error
-
-
-@echo off
-echo "************ RUN JUPYTER NOTEBOOKS *************************"
-@echo on
-jupyter notebook || goto :error
+conda install -c conda-forge tox-conda || goto :error
+conda install tox || goto :error
+tox -v -e start_jupyter --recreate || goto :error
 
 
 goto :EOF
diff --git a/getting_started/getting_started.sh b/getting_started/getting_started.sh
index 0a24578..3d5539c 100644
--- a/getting_started/getting_started.sh
+++ b/getting_started/getting_started.sh
@@ -6,51 +6,8 @@ set -x # echo commands
 # https://stackoverflow.com/questions/4774054/reliable-way-for-a-bash-script-to-get-the-full-path-to-itself
 FLATLAND_BASEDIR=$(dirname "$0")/..
 FLATLAND_BASEDIR=$(realpath "$FLATLAND_BASEDIR")
-echo "BASEDIR=${FLATLAND_BASEDIR}"
+cd ${FLATLAND_BASEDIR}
 
-set +x
-echo "************ TESTING PREREQUISITES PYTHON3 + GIT *************************"
-set -x
-
-git --version
-python --version
-conda --version
-echo $PATH
-
-
-set +x
-echo "************ SETUP VIRTUAL ENVIRONMENT FLATLAND *************************"
-set -x
-source deactivate
-(conda info --envs | fgrep flatland-rl) || conda create python=3.6 -y --name flatland-rl
-source activate flatland-rl
-
-
-set +x
-echo "************ INSTALL FLATLAND IN THE VIRTUALENV  *************************"
-set -x
-
-# TODO we should get rid of having to install these packages outside of setup.py with conda!
-conda install -y -c conda-forge cairosvg pycairo
-conda install -y  -c anaconda tk
-python -m pip install --upgrade pip
-
-python ${FLATLAND_BASEDIR}/setup.py install
-
-# ensure jupyter is installed in the virtualenv
-python -m pip install --upgrade -r ${FLATLAND_BASEDIR}/requirements_dev.txt -r requirements_continuous_integration.txt
-
-
-set +x
-echo "************ INSTALL JUPYTER EXTENSION *************************"
-set -x
-jupyter nbextension install --py --sys-prefix widgetsnbextension
-jupyter nbextension enable --py --sys-prefix widgetsnbextension
-jupyter nbextension install --py --sys-prefix jpy_canvas
-jupyter nbextension enable --py --sys-prefix jpy_canvas
-
-
-set +x
-echo "************ RUN JUPYTER NOTEBOOKS *************************"
-set -x
-jupyter notebook &
+conda install -c conda-forge tox-conda
+conda install tox
+tox -v -e start_jupyter &
diff --git a/tox.ini b/tox.ini
index 7bd40ed..bcd10fa 100644
--- a/tox.ini
+++ b/tox.ini
@@ -1,5 +1,5 @@
 [tox]
-envlist = py36, py37, examples, notebooks, flake8, docs, coverage
+envlist = py36, py37, examples, flake8, docs, coverage
 
 [travis]
 python =
@@ -73,11 +73,11 @@ passenv =
 ; HTTP_PROXY+HTTPS_PROXY required behind corporate proxies
     HTTP_PROXY
     HTTPS_PROXY
-conda_deps=
+conda_deps =
     cairosvg
     pycairo
     tk
-conda_channels:
+conda_channels :
     conda-forge
     anaconda
 deps =
@@ -96,11 +96,11 @@ passenv =
 ; HTTP_PROXY+HTTPS_PROXY required behind corporate proxies
     HTTP_PROXY
     HTTPS_PROXY
-conda_deps=
+conda_deps =
     cairosvg
     pycairo
     tk
-conda_channels:
+conda_channels :
     conda-forge
     anaconda
 deps =
@@ -124,11 +124,11 @@ whitelist_externals = sh
 deps =
     -r{toxinidir}/requirements_dev.txt
     -r{toxinidir}/requirements_continuous_integration.txt
-conda_deps=
+conda_deps =
     cairosvg
     pycairo
     tk
-conda_channels:
+conda_channels :
     conda-forge
     anaconda
 ; run tests from subfolder to ensure that resources are accessed via resources and not via relative paths
@@ -140,9 +140,33 @@ commands =
     sh -c 'jupyter nbextension install --py --sys-prefix jpy_canvas'
     sh -c 'jupyter nbextension enable --py --sys-prefix jpy_canvas'
 ; https://stackoverflow.com/questions/35545402/how-to-run-an-ipynb-jupyter-notebook-from-terminal/35545463
-    sh -c 'ls notebooks/*.ipynb  | xargs -n 1 jupyter nbconvert --to python'
+    sh -c 'ls {toxinidir}/notebooks/*.ipynb  | xargs -n 1 jupyter nbconvert --to python'
     sh -c 'ls {toxinidir}/notebooks/*.py  | xargs -I{} -n 1 sh -c "echo -e \"\n====== Running {} ========\n\"; ipython {}"'
 
+[testenv:start_jupyter]
+basepython = python
+setenv =
+    PYTHONPATH = {toxinidir}
+passenv =
+    DISPLAY
+    XAUTHORITY
+; HTTP_PROXY+HTTPS_PROXY required behind corporate proxies
+    HTTP_PROXY
+    HTTPS_PROXY
+whitelist_externals = sh
+deps =
+    -r{toxinidir}/requirements_dev.txt
+    -r{toxinidir}/requirements_continuous_integration.txt
+conda_deps =
+    cairosvg
+    pycairo
+    tk
+conda_channels :
+    conda-forge
+    anaconda
+commands =
+    jupyter notebook
+
 [testenv]
 whitelist_externals = pip
 setenv =
@@ -153,11 +177,11 @@ passenv =
 ; HTTP_PROXY+HTTPS_PROXY required behind corporate proxies
     HTTP_PROXY
     HTTPS_PROXY
-conda_deps=
+conda_deps =
     cairosvg
     pycairo
     tk
-conda_channels:
+conda_channels :
     conda-forge
     anaconda
 deps =
-- 
GitLab