diff --git a/.travis.yml b/.travis.yml index 3dfb92c..3112c26 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,8 +22,7 @@ env: - PYTHON_VERSION=3.6 matrix: - - SETUP_CMD='egg_info' - TEST_CMD='python --version' + - SETUP_CMD='egg_info' TEST_CMD='python --version' matrix: include: diff --git a/README.md b/README.md index c0ca0b8..6df10ee 100644 --- a/README.md +++ b/README.md @@ -35,9 +35,15 @@ This does the following: - Set up Miniconda. - Set up the PATH appropriately. - Set up a conda environment named 'test' and switch to it. -- Set the ``always_yes`` config option for conda to ``true`` so that you don't need to include ``--yes``. -- Register the specified channels, or if not stated the ``astropy``, ``astropy-ci-extras``, and ``openastronomy`` channels. +- Set the ``always_yes`` config option for conda to ``true`` so that you + don't need to include ``--yes``. +- Register the specified channels. - ``export PYTHONIOENCODING=UTF8`` +- Supports custom skip tags included in the commit message that are not yet + natively provided by Travis. To skip the travis build: [skip travis] or + [travis skip]. To run only the docs build: [build docs] or [docs + only]. The latter requires ``SETUP_CMD`` (see below) to be set to + "build_docs" or "build_sphinx". Following this, various dependencies are installed depending on the following environment variables @@ -53,7 +59,7 @@ environment variables * ``egg_info``: no dependencies are installed once the conda environment has been created and any other environment variables are ignored. - * ``build_sphinx`` or ``build_docs``: the Sphinx and matplotlib packages + * ``build_docs`` or ``build_sphinx``: the Sphinx and matplotlib packages are installed in addition to other packages that might be requested via other environment variables. @@ -206,9 +212,10 @@ The scripts include: * ``appveyor/install-miniconda.ps1`` - set up conda on Windows * ``appveyor/windows_sdk.cmd`` - set up the compiler environment on Windows * ``travis/setup_dependencies_common.sh`` - set up conda packages on Linux and MacOS X +* ``travis/setup_conda.sh`` - set up conda on MacOS X or Linux, users should use this directly rather than the OS specific ones below * ``travis/setup_conda_linux.sh`` - set up conda on Linux * ``travis/setup_conda_osx.sh`` - set up conda on MacOS X -* ``travis/setup_conda.sh`` - set up conda on MacOS X or Linux + This repository can be cloned directly from the ``.travis.yml`` and ``appveyor.yml`` files when about to run tests and does not need to be diff --git a/travis/setup_conda.sh b/travis/setup_conda.sh index 4027f03..4b6dac6 100755 --- a/travis/setup_conda.sh +++ b/travis/setup_conda.sh @@ -7,10 +7,39 @@ # # The present script was added later. +if [[ $DEBUG == True ]]; then + set -x +fi + +# First check: if the build should be run at all based on the event type + +if [[ ! -z $EVENT_TYPE ]]; then + for event in $EVENT_TYPE; do + if [[ $TRAVIS_EVENT_TYPE = $event ]]; then + allow_to_build=True + fi + done + if [[ $allow_to_build != True ]]; then + travis_terminate 0 + fi +fi + +# Second check: if any of the custom tags are used to skip the build + +TR_SKIP="\[(skip travis|travis skip)\]" +DOCS_ONLY="\[docs only|build docs\]" + # Skip build if the commit message contains [skip travis] or [travis skip] # Remove workaround once travis has this feature natively # https://github.com/travis-ci/travis-ci/issues/5032 -echo "$TRAVIS_COMMIT_MESSAGE" | grep -E '\[(skip travis|travis skip)\]' \ - && echo "[skip travis] has been found, exiting." && exit 0 +if [[ ! -z $(echo $TRAVIS_COMMIT_MESSAGE | grep -E "$TR_SKIP") ]]; then + echo "Travis was requested to be skipped by the commit message, exiting." + travis_terminate 0 +elif [[ ! -z $(echo $TRAVIS_COMMIT_MESSAGE | grep -E "$DOCS_ONLY") ]]; then + if [[ $SETUP_CMD != *build_docs* ]] && [[ $SETUP_CMD != *build_sphinx* ]]; then + echo "Only docs build was requested by the commit message, exiting." + travis_terminate 0 + fi +fi source ci-helpers/travis/setup_conda_$TRAVIS_OS_NAME.sh; diff --git a/travis/setup_dependencies_common.sh b/travis/setup_dependencies_common.sh index 84022a2..24fa9a4 100755 --- a/travis/setup_dependencies_common.sh +++ b/travis/setup_dependencies_common.sh @@ -4,17 +4,6 @@ hash -r set -e -if [[ ! -z $EVENT_TYPE ]]; then - for event in $EVENT_TYPE; do - if [[ $TRAVIS_EVENT_TYPE = $event ]]; then - allow_to_build=True - fi - done - if [[ $allow_to_build != True ]]; then - travis_terminate 0 - fi -fi - # We need to do this before updating conda, as $CONDA_CHANNELS may be a # conda environment variable for some Miniconda versions, too that needs to # be space separated. @@ -255,7 +244,7 @@ fi # DOCUMENTATION DEPENDENCIES # build_sphinx needs sphinx and matplotlib (for plot_directive). -if [[ $SETUP_CMD == build_sphinx* ]] || [[ $SETUP_CMD == build_docs* ]]; then +if [[ $SETUP_CMD == *build_sphinx* ]] || [[ $SETUP_CMD == *build_docs* ]]; then # Check whether there are any version setting env variables, pin them if # there are (only need to deal with the case when they aren't listed in # CONDA_DEPENDENCIES, otherwise this was already dealt with) @@ -428,7 +417,7 @@ fi # cache before starting the tests/docs build. See details in # https://github.com/matplotlib/matplotlib/issues/5836 -if [[ $SETUP_CMD == build_sphinx* ]] || [[ $SETUP_CMD == build_docs* ]]; then +if [[ $SETUP_CMD == *build_sphinx* ]] || [[ $SETUP_CMD == *build_docs* ]]; then python -c "import matplotlib.pyplot" fi