diff --git a/ci/bootstrap.sh b/ci/bootstrap.sh index f609717548623290f543910c1f601e8946aab32f..6e47a7c5ea3d668951ba4c105ed8f031a79216eb 100755 --- a/ci/bootstrap.sh +++ b/ci/bootstrap.sh @@ -25,24 +25,37 @@ else ARCH="linux" fi +# Functions for coloring echo commands +red_echo() { + echo -e "\033[1;31m${@}\033[0m" +} + +green_echo() { + echo -e "\033[1;32m${@}\033[0m" +} + +yellow_echo() { + echo -e "\033[1;33m${@}\033[0m" +} + # Function for running command and echoing results run_cmd() { - echo "[(`date +%c`)>>] Running \"${@}\"..." + green_echo "[(`date +%c`)>>] Running \"${@}\"..." ${@} if [ "$?" != "0" ]; then - echo "[(`date +%c`)!!] Command Failed \"${@}\"" + red_echo "[(`date +%c`)!!] Command Failed \"${@}\"" exit 1 else - echo "[(`date +%c`)<<] Finished comand \"${@}\"" + green_echo "[(`date +%c`)<<] Finished comand \"${@}\"" fi } # Clones the conda dev environment to use if [ ! -d ${PREFIX} ]; then - echo "[++] Downloading environment list into file \`env.txt'..." + yellow_echo "[++] Downloading environment list into file \`env.txt'..." pyver=$(echo ${PYTHON_VERSION} | tr -d '.') curl --silent https://gitlab.idiap.ch/bob/bob.admin/raw/master/install/${ARCH}/devel-py${pyver}.txt > env.txt - echo "[++] Bootstrapping conda installation at ${PREFIX}..." + yellow_echo "[++] Bootstrapping conda installation at ${PREFIX}..." run_cmd ${CONDA_FOLDER}/bin/conda create --prefix ${PREFIX} --file env.txt --yes # Dirty fix to libjpeg.8 compilation issues: @@ -52,49 +65,49 @@ if [ ! -d ${PREFIX} ]; then fi run_cmd ${CONDA_FOLDER}/bin/conda clean --lock else - echo "[!!] Prefix directory ${PREFIX} exists, not re-installing..." + yellow_echo "[!!] Prefix directory ${PREFIX} exists, not re-installing..." fi # Source the newly created conda environment -echo "[>>] Running \"source ${CONDA_FOLDER}/bin/activate ${PREFIX}\"..." +green_echo "[>>] Running \"source ${CONDA_FOLDER}/bin/activate ${PREFIX}\"..." source ${CONDA_FOLDER}/bin/activate ${PREFIX} -echo "[<<] Environment ${PREFIX} activated" +green_echo "[<<] Environment ${PREFIX} activated" # Verify where pip is installed use_pip=`which pip` if [ -z "${use_pip}" ]; then - echo "[!!] Cannot find pip, aborting..." + red_echo "[!!] Cannot find pip, aborting..." exit 1 else - echo "[++] Using pip: ${use_pip}" + yellow_echo "[++] Using pip: ${use_pip}" fi use_python=`which python` if [ -z "${use_python}" ]; then - echo "[!!] Cannot find python, aborting..." + red_echo "[!!] Cannot find python, aborting..." exit 1 else - echo "[++] Using python: ${use_python}" + yellow_echo "[++] Using python: ${use_python}" fi # Install this package's build dependencies if [ -e requirements.txt ]; then run_cmd ${use_pip} install --find-links ${WHEELS_REPOSITORY} --use-wheel --no-index --trusted-host ${WHEELS_SERVER} --pre --requirement requirements.txt else - echo "[!!] No requirements.txt file found, skipping 'pip install <build-deps>'..." + yellow_echo "[!!] No requirements.txt file found, skipping 'pip install <build-deps>'..." fi # Install this package's test dependencies if [ -e test-requirements.txt ]; then run_cmd ${use_pip} install --find-links ${WHEELS_REPOSITORY} --use-wheel --no-index --trusted-host ${WHEELS_SERVER} --pre --requirement test-requirements.txt else - echo "[!!] No test-requirements.txt file found, skipping 'pip install <test-deps>'..." + yellow_echo "[!!] No test-requirements.txt file found, skipping 'pip install <test-deps>'..." fi # Finally, bootstrap the installation from the new environment if [ -e bootstrap-buildout.py ]; then run_cmd ${use_python} bootstrap-buildout.py else - echo "[!!] No bootstrap-buildout.py file found, skipping 'buildout bootstrap'..." + red_echo "[!!] No bootstrap-buildout.py file found, stopping..." exit 1 fi