Skip to content

Commit

Permalink
Simplify travis.yml script steps by bailing early if nothing to do
Browse files Browse the repository at this point in the history
As the first step in before_install we can do a single big conditional statement to see if we have anything useful to do for this build matrix job. If not then we can do an `exit 0` in the `else` which happily terminates the job. This saves it doing any further unneeded install steps or sauce_connect, saving a bit of time for build matrix jobs that have nothing to do.
Tests on later steps do not need the full complex logic any more. Once we get through the first step, we know that we have either a "syntax", "selenium" or "TEST_DAV" build, and the selenium build satisfies all the other complicated conditions already. So we can just test for those 3 things to decide which steps to execute.
  • Loading branch information
phil-davis authored and DeepDiver1975 committed May 17, 2017
1 parent e2cef9f commit ec7c026
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,23 +33,24 @@ addons:
- owncloud

before_install:
- sh -c "if [ '$TC' = 'syntax' ] || [ '$TEST_DAV' = '1' ] || { [ '$TC' = 'selenium' ] && [ ! -z "$SAUCE_USERNAME" ] && [ ! -z "$SAUCE_ACCESS_KEY" ] && { [ '$CRON_ONLY' = '0' ] || [ '$TRAVIS_EVENT_TYPE' = 'cron' ]; }; }; then make; fi"
- sh -c "if [ '$TEST_DAV' = '1' ] || { [ '$TC' = 'selenium' ] && [ ! -z "$SAUCE_USERNAME" ] && [ ! -z "$SAUCE_ACCESS_KEY" ] && { [ '$CRON_ONLY' = '0' ] || [ '$TRAVIS_EVENT_TYPE' = 'cron' ]; }; }; then bash tests/travis/before_install.sh $DB; fi"
- if [ "$TC" = "syntax" ] || [ "$TEST_DAV" = "1" ] || { [ "$TC" = "selenium" ] && [ ! -z "$SAUCE_USERNAME" ] && [ ! -z "$SAUCE_ACCESS_KEY" ] && { [ "$CRON_ONLY" = "0" ] || [ "$TRAVIS_EVENT_TYPE" = "cron" ]; }; }; then echo "There is real work to do"; else exit 0; fi
- make
- sh -c "if [ '$TEST_DAV' = '1' ] || [ '$TC' = 'selenium' ]; then bash tests/travis/before_install.sh $DB; fi"

install:
- sh -c "if [ '$TEST_DAV' = '1' ] || { [ '$TC' = 'selenium' ] && [ ! -z "$SAUCE_USERNAME" ] && [ ! -z "$SAUCE_ACCESS_KEY" ] && { [ '$CRON_ONLY' = '0' ] || [ '$TRAVIS_EVENT_TYPE' = 'cron' ]; }; }; then bash tests/travis/install.sh $DB; fi"
- sh -c "if [ '$TEST_DAV' = '1' ] || [ '$TC' = 'selenium' ]; then bash tests/travis/install.sh $DB; fi"
- sh -c "if [ '$TEST_DAV' = '1' ]; then bash apps/dav/tests/travis/$TC/install.sh; fi"

before_script:
- sh -c "if [ '$TC' = 'selenium' ] && [ ! -z "$SAUCE_USERNAME" ] && [ ! -z "$SAUCE_ACCESS_KEY" ] && { [ '$CRON_ONLY' = '0' ] || [ '$TRAVIS_EVENT_TYPE' = 'cron' ]; }; then bash tests/travis/start_php_dev_server.sh; fi"
- sh -c "if [ '$TC' = 'selenium' ]; then bash tests/travis/start_php_dev_server.sh; fi"

script:
- sh -c "if [ '$TC' = 'syntax' ]; then make test-php-lint ; fi"
- sh -c "if [ '$TEST_DAV' != '1' ]; then echo \"Not testing DAV\"; fi"
- sh -c "if [ '$TEST_DAV' = '1' ]; then echo \"Testing DAV\"; fi"

- sh -c "if [ '$TEST_DAV' = '1' ]; then bash apps/dav/tests/travis/$TC/script.sh; fi"
- sh -c "if [ '$TC' = 'selenium' ] && [ ! -z "$SAUCE_USERNAME" ] && [ ! -z "$SAUCE_ACCESS_KEY" ] && { [ '$CRON_ONLY' = '0' ] || [ '$TRAVIS_EVENT_TYPE' = 'cron' ]; }; then bash tests/travis/start_behat_tests.sh; fi"
- sh -c "if [ '$TC' = 'selenium' ]; then bash tests/travis/start_behat_tests.sh; fi"

matrix:
include:
Expand Down

0 comments on commit ec7c026

Please sign in to comment.