From b8f0c3dc7bdf37553fa564578635f5bfcc6c646c Mon Sep 17 00:00:00 2001 From: Igor Minar Date: Sun, 5 Mar 2017 01:49:10 -0800 Subject: [PATCH] ci: redo how env variables are set and shared in ci to prevent collisions --- .travis.yml | 17 +++---- build.sh | 6 ++- modules/@angular/compiler-cli/README.md | 2 +- scripts/ci/_travis-fold.sh | 27 ++++++----- scripts/ci/angular.sh | 12 ++--- scripts/ci/build.sh | 12 ++++- scripts/ci/cleanup.sh | 7 +-- scripts/ci/deploy.sh | 16 +++++-- scripts/ci/env.sh | 38 ++++++---------- scripts/ci/install.sh | 36 ++++++++++----- scripts/ci/offline_compiler_test.sh | 4 +- scripts/ci/print-logs.sh | 9 ++-- scripts/ci/publish-build-artifacts.sh | 9 +++- scripts/ci/test-aio.sh | 59 ++++++++++++++----------- scripts/ci/test-browserstack.sh | 4 +- scripts/ci/test-docs.sh | 10 +++-- scripts/ci/test-e2e.sh | 6 +-- scripts/ci/test-js.sh | 4 +- scripts/ci/test-saucelabs.sh | 4 +- scripts/ci/test.sh | 28 +++++++----- scripts/sauce/sauce_connect_setup.sh | 5 +-- 21 files changed, 180 insertions(+), 135 deletions(-) diff --git a/.travis.yml b/.travis.yml index 05fada7a4c..31fc33cbf7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,6 +10,7 @@ addons: # needed to install g++ that is used by npms's native modules - ubuntu-toolchain-r-test packages: + # needed to install g++ that is used by npms's native modules - g++-4.8 # https://docs.travis-ci.com/user/jwt jwt: @@ -54,17 +55,17 @@ matrix: - env: "CI_MODE=browserstack_optional" before_install: - - ./scripts/ci-lite/env.sh print + - source ./scripts/ci/env.sh print install: - - ./scripts/ci-lite/install.sh + - ./scripts/ci/install.sh script: - - ./scripts/ci-lite/build.sh - - ./scripts/ci-lite/test.sh + - ./scripts/ci/build.sh + - ./scripts/ci/test.sh # deploy is part of 'script' and not 'after_success' so that we fail the build if the deployment fails - - ./scripts/ci-lite/deploy.sh - - ./scripts/ci-lite/angular.sh + - ./scripts/ci/deploy.sh + - ./scripts/ci/angular.sh # all the scripts under this line will not quickly abort in case ${TRAVIS_TEST_RESULT} is 1 (job failure) - - ./scripts/ci-lite/cleanup.sh - - ./scripts/ci-lite/print-logs.sh + - ./scripts/ci/cleanup.sh + - ./scripts/ci/print-logs.sh diff --git a/build.sh b/build.sh index 18a6ff7dbe..efbcb10dc5 100755 --- a/build.sh +++ b/build.sh @@ -2,9 +2,11 @@ set -u -e -o pipefail -source ${TRAVIS_BUILD_DIR}/scripts/ci-lite/_travis_fold.sh +readonly currentDir=$(cd $(dirname $0); pwd) +source ${currentDir}/scripts/ci/_travis-fold.sh -cd `dirname $0` +# TODO(i): wrap into subshell, so that we don't pollute CWD, but not yet to minimize diff collision with Jason +cd ${currentDir} PACKAGES=(core compiler diff --git a/modules/@angular/compiler-cli/README.md b/modules/@angular/compiler-cli/README.md index 0c345f3fde..de0967ca61 100644 --- a/modules/@angular/compiler-cli/README.md +++ b/modules/@angular/compiler-cli/README.md @@ -125,7 +125,7 @@ $ cp tools/@angular/tsc-wrapped/package.json dist/tools/@angular/tsc-wrapped # Run the test once # (First edit the LINKABLE_PKGS to use npm link instead of npm install) -$ ./scripts/ci-lite/offline_compiler_test.sh +$ ./scripts/ci/offline_compiler_test.sh # Keep a package fresh in watch mode ./node_modules/.bin/tsc -p modules/@angular/compiler/tsconfig-es5.json -w diff --git a/scripts/ci/_travis-fold.sh b/scripts/ci/_travis-fold.sh index 1b54712da4..6ba6265bf7 100644 --- a/scripts/ci/_travis-fold.sh +++ b/scripts/ci/_travis-fold.sh @@ -13,8 +13,10 @@ function travisFoldStart() { travisFoldStack+=("${sanitizedFoldName}|${foldStartTime}") echo "" - echo "travis_fold:start:${sanitizedFoldName}" - echo "travis_time:start:${sanitizedFoldName}" + if [[ ${TRAVIS:-} ]]; then + echo "travis_fold:start:${sanitizedFoldName}" + echo "travis_time:start:${sanitizedFoldName}" + fi local enterArrow="===> ${foldName} ==>==>==>==>==>==>==>==>==>==>==>==>==>==>==>==>==>==>==>==>==>==>==>==>==>==>==>==>==>" # keep all messages consistently wide 80chars regardless of the foldName echo ${enterArrow:0:100} @@ -37,13 +39,16 @@ function travisFoldEnd() { # split the string by | and then turn that into an array local lastFoldArray=(${lastFoldString//\|/ }) local lastSanitizedFoldName=${lastFoldArray[0]} - local lastFoldStartTime=${lastFoldArray[1]} - local foldFinishTime=$(date +%s%N) - local foldDuration=$(expr ${foldFinishTime} - ${lastFoldStartTime}) - # write into build-perf.log file - local logIndent=$(expr ${lastFoldIndex} \* 2) - printf "%6ss%${logIndent}s: %s\n" $(expr ${foldDuration} / 1000000000) " " "${foldName}" >> ${LOGS_DIR}/build-perf.log + if [[ ${TRAVIS:-} ]]; then + local lastFoldStartTime=${lastFoldArray[1]} + local foldFinishTime=$(date +%s%N) + local foldDuration=$(expr ${foldFinishTime} - ${lastFoldStartTime}) + + # write into build-perf.log file + local logIndent=$(expr ${lastFoldIndex} \* 2) + printf "%6ss%${logIndent}s: %s\n" $(expr ${foldDuration} / 1000000000) " " "${foldName}" >> ${LOGS_DIR}/build-perf.log + fi # pop travisFoldStack=(${travisFoldStack[@]:0:lastFoldIndex}) @@ -58,8 +63,10 @@ function travisFoldEnd() { # keep all messages consistently wide 80chars regardless of the foldName echo ${returnArrow:0:100} echo "" - echo "travis_time:end:${sanitizedFoldName}:start=${lastFoldStartTime},finish=${foldFinishTime},duration=${foldDuration}" - echo "travis_fold:end:${sanitizedFoldName}" + if [[ ${TRAVIS:-} ]]; then + echo "travis_time:end:${sanitizedFoldName}:start=${lastFoldStartTime},finish=${foldFinishTime},duration=${foldDuration}" + echo "travis_fold:end:${sanitizedFoldName}" + fi } diff --git a/scripts/ci/angular.sh b/scripts/ci/angular.sh index f98af2dc41..ec28c34232 100755 --- a/scripts/ci/angular.sh +++ b/scripts/ci/angular.sh @@ -2,17 +2,17 @@ set -u -e -o pipefail -# created based on the official Angular logo from https://angular.io/presskit.html -# converted using http://www.text-image.com/convert/ -# colors added based on http://stackoverflow.com/questions/5947742/how-to-change-the-output-color-of-echo-in-linux - - # If the previous commands in the `script` section of .travis.yaml failed, then abort. -if [[ ${TRAVIS_TEST_RESULT} == 1 ]]; then +# The variable is not set in early stages of the build, so we default to 0 there. +# https://docs.travis-ci.com/user/environment-variables/ +if [[ ${TRAVIS_TEST_RESULT=0} == 1 ]]; then exit 1; fi +# this ascii art was created based on the official Angular logo from https://angular.io/presskit.html +# converted using http://www.text-image.com/convert/ +# colors added based on http://stackoverflow.com/questions/5947742/how-to-change-the-output-color-of-echo-in-linux RED='\033[0;31m' LRED='\033[1;31m' WHITE='\033[1;37m' diff --git a/scripts/ci/build.sh b/scripts/ci/build.sh index 1cb9f1cb13..c46011fadf 100755 --- a/scripts/ci/build.sh +++ b/scripts/ci/build.sh @@ -3,8 +3,16 @@ set -u -e -o pipefail # Setup environment -source ${TRAVIS_BUILD_DIR}/scripts/ci-lite/_travis_fold.sh -source ${TRAVIS_BUILD_DIR}/scripts/ci-lite/env.sh +readonly thisDir=$(cd $(dirname $0); pwd) +source ${thisDir}/_travis-fold.sh + + +# If the previous commands in the `script` section of .travis.yaml failed, then abort. +# The variable is not set in early stages of the build, so we default to 0 there. +# https://docs.travis-ci.com/user/environment-variables/ +if [[ ${TRAVIS_TEST_RESULT=0} == 1 ]]; then + exit 1; +fi travisFoldStart "tsc tools" diff --git a/scripts/ci/cleanup.sh b/scripts/ci/cleanup.sh index 6f74309b67..7b1046d7c9 100755 --- a/scripts/ci/cleanup.sh +++ b/scripts/ci/cleanup.sh @@ -2,12 +2,9 @@ set -u -e -o pipefail -# override test failure so that we perform this file regardless and not abort in env.sh -TRAVIS_TEST_RESULT=0 - # Setup environment -source ${TRAVIS_BUILD_DIR}/scripts/ci-lite/_travis_fold.sh -source ${TRAVIS_BUILD_DIR}/scripts/ci-lite/env.sh +readonly thisDir=$(cd $(dirname $0); pwd) +source ${thisDir}/_travis-fold.sh case ${CI_MODE} in diff --git a/scripts/ci/deploy.sh b/scripts/ci/deploy.sh index f4cb6d6042..db43734066 100755 --- a/scripts/ci/deploy.sh +++ b/scripts/ci/deploy.sh @@ -3,15 +3,23 @@ set -u -e -o pipefail # Setup environment -source ${TRAVIS_BUILD_DIR}/scripts/ci-lite/_travis_fold.sh -source ${TRAVIS_BUILD_DIR}/scripts/ci-lite/env.sh +readonly thisDir=$(cd $(dirname $0); pwd) +source ${thisDir}/_travis-fold.sh + + +# If the previous commands in the `script` section of .travis.yaml failed, then abort. +# The variable is not set in early stages of the build, so we default to 0 there. +# https://docs.travis-ci.com/user/environment-variables/ +if [[ ${TRAVIS_TEST_RESULT=0} == 1 ]]; then + exit 1; +fi # Don't deploy if not running against angular/angular and not a PR # TODO(i): because we don't let deploy to run outside of angular/angular folks can't use their # private travis build to deploy anywhere. This is likely ok, but this means that @alexeagle's # fancy setup to publish ES2015 packages to github -build repos no longer works. This is ok -# since with megamodules we'll have this feature built-in. We should still go and remove +# since with flat modules we'll have this feature built-in. We should still go and remove # stuff that Alex put in for this from publish-build-artifacts.sh if [[ ${TRAVIS_REPO_SLUG} != "angular/angular" || ${TRAVIS_PULL_REQUEST} != "false" ]]; then echo "Skipping deploy to staging because this is a PR build." @@ -22,7 +30,7 @@ fi case ${CI_MODE} in e2e) travisFoldStart "deploy.packages" - ./scripts/publish/publish-build-artifacts.sh + ${thisDir}/publish-build-artifacts.sh travisFoldEnd "deploy.packages" ;; aio) diff --git a/scripts/ci/env.sh b/scripts/ci/env.sh index ddd427ff02..a29dfe443f 100755 --- a/scripts/ci/env.sh +++ b/scripts/ci/env.sh @@ -1,18 +1,12 @@ #!/usr/bin/env bash -# If the previous commands in the `script` section of .travis.yaml failed, then abort. -# The variable is not set in early stages of the build, so we default to 0 there. -# https://docs.travis-ci.com/user/environment-variables/ -if [[ ${TRAVIS_TEST_RESULT=0} == 1 ]]; then - exit 1; -fi - - -# set wasBashSetXOn using the current "set -x" mode state, so that we can restore it at the end -[[ "${-//[^x]/}" = "x" ]] && wasBashSetXOn=1 || wasBashSetXOn=0 +# because this script is being source-ed via .travis.yaml, +# we need to restore the original options so that that we don't interfere with +# travis' internals +readonly ORIGINAL_SHELL_OPTIONS=$(set +o) # this script is extra noisy and used in many places during the build so we suppress the trace with +x to reduce the noise -set +x -u -e -o pipefail +set -u -e -o pipefail # sets and optionally prints environmental variable # usage: setEnvVar variableName variableValue @@ -26,14 +20,14 @@ function setEnvVar() { export ${name}=${value} } - -# strip leading "./" -currentFileName=${0#./} -currentWorkingDirectory=`pwd` -#cd ${currentWorkingDirectory%currentFileName} +# use BASH_SOURCE so that we get the right path when this script is called AND source-d +readonly thisDir=$(cd $(dirname ${BASH_SOURCE[0]}); pwd) readonly print=${1:-} -# TODO(i): this won't work locally -source ${TRAVIS_BUILD_DIR}/scripts/ci-lite/_travis_fold.sh + +# print bash version just so that we know what is running all the scripts +if [[ ${print} == "print" ]]; then + bash --version +fi ####################### @@ -45,8 +39,7 @@ setEnvVar NPM_VERSION 3.10.7 # do not upgrade to >3.10.8 unless https://github.c setEnvVar YARN_VERSION 0.21.3 setEnvVar CHROMIUM_VERSION 433059 # Chrome 53 linux stable, see https://www.chromium.org/developers/calendar setEnvVar SAUCE_CONNECT_VERSION 4.3.11 -# TODO(i): this won't work locally -setEnvVar PROJECT_ROOT ${TRAVIS_BUILD_DIR} # all source includes above for helper files in this env.sh script (e.g. _travis_fold.sh) duplicate this setting, update those if you change it here +setEnvVar PROJECT_ROOT $(cd ${thisDir}/../..; pwd) if [[ ${TRAVIS:-} ]]; then case ${CI_MODE} in @@ -124,7 +117,4 @@ if [[ ${print} == "print" ]]; then echo PS4=${PS4} fi -# restore set -x mode -if [[ wasBashSetXOn == 1 ]]; then - set -x -fi +eval "${ORIGINAL_SHELL_OPTIONS}" diff --git a/scripts/ci/install.sh b/scripts/ci/install.sh index 96df9e9834..012894b579 100755 --- a/scripts/ci/install.sh +++ b/scripts/ci/install.sh @@ -2,12 +2,18 @@ set -u -e -o pipefail -source ${TRAVIS_BUILD_DIR}/scripts/ci-lite/_travis_fold.sh - # Setup environment -cd `dirname $0` -source ./env.sh -cd ../.. +readonly thisDir=$(cd $(dirname $0); pwd) +source ${thisDir}/_travis-fold.sh + + +# If the previous commands in the `script` section of .travis.yaml failed, then abort. +# The variable is not set in early stages of the build, so we default to 0 there. +# https://docs.travis-ci.com/user/environment-variables/ +if [[ ${TRAVIS_TEST_RESULT=0} == 1 ]]; then + exit 1; +fi + mkdir -p ${LOGS_DIR} @@ -43,9 +49,11 @@ fi if [[ ${TRAVIS} && (${CI_MODE} == "aio" || ${CI_MODE} == "docs_test") ]]; then # angular.io: Install all yarn dependencies according to angular.io/yarn.lock travisFoldStart "yarn-install.aio" - cd "`dirname $0`/../../aio" - yarn install - cd - + ( + printenv + cd ${PROJECT_ROOT}/aio + yarn install + ) travisFoldEnd "yarn-install.aio" fi @@ -53,7 +61,9 @@ fi # Install Chromium if [[ ${CI_MODE} == "js" || ${CI_MODE} == "e2e" || ${CI_MODE} == "aio" ]]; then travisFoldStart "install-chromium" - ./scripts/ci/install_chromium.sh + ( + ${thisDir}/install-chromium.sh + ) travisFoldEnd "install-chromium" fi @@ -61,7 +71,9 @@ fi # Install Sauce Connect if [[ ${TRAVIS}] && (${CI_MODE} == "saucelabs_required" || ${CI_MODE} == "saucelabs_optional") ]]; then travisFoldStart "install-sauceConnect" - ./scripts/sauce/sauce_connect_setup.sh + ( + ${thisDir}/../sauce/sauce_connect_setup.sh + ) travisFoldEnd "install-sauceConnect" fi @@ -69,7 +81,9 @@ fi # Install BrowserStack Tunnel if [[ ${TRAVIS} && (${CI_MODE} == "browserstack_required" || ${CI_MODE} == "browserstack_optional") ]]; then travisFoldStart "install-browserstack" - ./scripts/browserstack/start_tunnel.sh + ( + ${thisDir}/../browserstack/start_tunnel.sh + ) travisFoldEnd "install-browserstack" fi diff --git a/scripts/ci/offline_compiler_test.sh b/scripts/ci/offline_compiler_test.sh index 50d8fe8e97..eed041d165 100755 --- a/scripts/ci/offline_compiler_test.sh +++ b/scripts/ci/offline_compiler_test.sh @@ -1,5 +1,7 @@ #!/usr/bin/env bash -set -ex -o pipefail + +set -u -e -o pipefail + # These ones can be `npm link`ed for fast development LINKABLE_PKGS=( diff --git a/scripts/ci/print-logs.sh b/scripts/ci/print-logs.sh index 4ac0112994..37cbf74e34 100755 --- a/scripts/ci/print-logs.sh +++ b/scripts/ci/print-logs.sh @@ -1,13 +1,10 @@ -#!/bin/bash +#!/usr/bin/env bash set -u -e -o pipefail -# override test failure so that we perform this file regardless and not abort in env.sh -TRAVIS_TEST_RESULT=0 - # Setup environment -source ${TRAVIS_BUILD_DIR}/scripts/ci-lite/_travis_fold.sh -source ${TRAVIS_BUILD_DIR}/scripts/ci-lite/env.sh +readonly thisDir=$(cd $(dirname $0); pwd) +source ${thisDir}/_travis-fold.sh for FILE in ${LOGS_DIR}/*; do diff --git a/scripts/ci/publish-build-artifacts.sh b/scripts/ci/publish-build-artifacts.sh index cbabeea38b..1517512083 100755 --- a/scripts/ci/publish-build-artifacts.sh +++ b/scripts/ci/publish-build-artifacts.sh @@ -1,5 +1,10 @@ -#!/bin/bash -set -e -x +#!/usr/bin/env bash + +set -u -e -o pipefail + +# Setup environment +readonly thisDir=$(cd $(dirname $0); pwd) +source ${thisDir}/_travis-fold.sh # Find the most recent tag that is reachable from the current commit. diff --git a/scripts/ci/test-aio.sh b/scripts/ci/test-aio.sh index d36b8caefe..a15504465e 100755 --- a/scripts/ci/test-aio.sh +++ b/scripts/ci/test-aio.sh @@ -3,36 +3,41 @@ set -u -e -o pipefail # Setup environment -source ${TRAVIS_BUILD_DIR}/scripts/ci-lite/_travis_fold.sh -source ${TRAVIS_BUILD_DIR}/scripts/ci-lite/env.sh -cd ${PROJECT_ROOT}/aio +readonly thisDir=$(cd $(dirname $0); pwd) +source ${thisDir}/_travis-fold.sh -# Lint the code -travisFoldStart "test.aio.lint" - yarn run lint -travisFoldEnd "test.aio.lint" - -# Generate docs files -# TODO(i): why is this in 'test' phase and not in the 'build' phase? -travisFoldStart "test.aio.doc-gen" - $(npm bin)/gulp docs -travisFoldEnd "test.aio.doc-gen" +# run in subshell to avoid polluting cwd +( + cd ${PROJECT_ROOT}/aio -# Start xvfb for local Chrome used for testing -if [[ ${TRAVIS} ]]; then - travisFoldStart "test.aio.xvfb-start" - sh -e /etc/init.d/xvfb start - travisFoldEnd "test.aio.xvfb-start" -fi + # Lint the code + travisFoldStart "test.aio.lint" + yarn run lint + travisFoldEnd "test.aio.lint" -# Run unit tests -travisFoldStart "test.aio.unit" - yarn test -- --single-run -travisFoldEnd "test.aio.unit" + # Generate docs files + # TODO(i): why is this in 'test' phase and not in the 'build' phase? + travisFoldStart "test.aio.doc-gen" + $(npm bin)/gulp docs + travisFoldEnd "test.aio.doc-gen" -# Run e2e tests -travisFoldStart "test.aio.e2e" - yarn run e2e -travisFoldEnd "test.aio.e2e" + + # Start xvfb for local Chrome used for testing + if [[ ${TRAVIS} ]]; then + travisFoldStart "test.aio.xvfb-start" + sh -e /etc/init.d/xvfb start + travisFoldEnd "test.aio.xvfb-start" + fi + + # Run unit tests + travisFoldStart "test.aio.unit" + yarn test -- --single-run + travisFoldEnd "test.aio.unit" + + # Run e2e tests + travisFoldStart "test.aio.e2e" + yarn run e2e + travisFoldEnd "test.aio.e2e" +) diff --git a/scripts/ci/test-browserstack.sh b/scripts/ci/test-browserstack.sh index 5e6b5e2c3d..008813917e 100755 --- a/scripts/ci/test-browserstack.sh +++ b/scripts/ci/test-browserstack.sh @@ -3,8 +3,8 @@ set -u -e -o pipefail # Setup environment -source ${TRAVIS_BUILD_DIR}/scripts/ci-lite/_travis_fold.sh -source ${TRAVIS_BUILD_DIR}/scripts/ci-lite/env.sh +readonly thisDir=$(cd $(dirname $0); pwd) +source ${thisDir}/_travis-fold.sh travisFoldStart "test.unit.browserstack" diff --git a/scripts/ci/test-docs.sh b/scripts/ci/test-docs.sh index 46a0af140a..9368d12898 100755 --- a/scripts/ci/test-docs.sh +++ b/scripts/ci/test-docs.sh @@ -3,11 +3,13 @@ set -u -e -o pipefail # Setup environment -source ${TRAVIS_BUILD_DIR}/scripts/ci-lite/_travis_fold.sh -source ${TRAVIS_BUILD_DIR}/scripts/ci-lite/env.sh +readonly thisDir=$(cd $(dirname $0); pwd) +source ${thisDir}/_travis-fold.sh travisFoldStart "test.docs" - cd ${PROJECT_ROOT}/aio - $(npm bin)/gulp docs-test + ( + cd ${PROJECT_ROOT}/aio + $(npm bin)/gulp docs-test + ) travisFoldEnd "test.docs" diff --git a/scripts/ci/test-e2e.sh b/scripts/ci/test-e2e.sh index bc10504304..131a295f9e 100755 --- a/scripts/ci/test-e2e.sh +++ b/scripts/ci/test-e2e.sh @@ -3,8 +3,8 @@ set -u -e -o pipefail # Setup environment -source ${TRAVIS_BUILD_DIR}/scripts/ci-lite/_travis_fold.sh -source ${TRAVIS_BUILD_DIR}/scripts/ci-lite/env.sh +readonly thisDir=$(cd $(dirname $0); pwd) +source ${thisDir}/_travis-fold.sh travisFoldStart "test.e2e.buildPackages" @@ -26,7 +26,7 @@ travisFoldEnd "test.e2e.integration" travisFoldStart "test.e2e.offlineCompiler" #TODO(alexeagle): move offline_compiler_test to integration/ - ./scripts/ci-lite/offline_compiler_test.sh + ${thisDir}/offline_compiler_test.sh travisFoldEnd "test.e2e.offlineCompiler" diff --git a/scripts/ci/test-js.sh b/scripts/ci/test-js.sh index 806b0c13db..40b6d18d2e 100755 --- a/scripts/ci/test-js.sh +++ b/scripts/ci/test-js.sh @@ -3,8 +3,8 @@ set -u -e -o pipefail # Setup environment -source ${TRAVIS_BUILD_DIR}/scripts/ci-lite/_travis_fold.sh -source ${TRAVIS_BUILD_DIR}/scripts/ci-lite/env.sh +readonly thisDir=$(cd $(dirname $0); pwd) +source ${thisDir}/_travis-fold.sh # Run unit tests for our tools/ directory diff --git a/scripts/ci/test-saucelabs.sh b/scripts/ci/test-saucelabs.sh index d5a068021f..f3e1b8bd41 100755 --- a/scripts/ci/test-saucelabs.sh +++ b/scripts/ci/test-saucelabs.sh @@ -3,8 +3,8 @@ set -u -e -o pipefail # Setup environment -source ${TRAVIS_BUILD_DIR}/scripts/ci-lite/_travis_fold.sh -source ${TRAVIS_BUILD_DIR}/scripts/ci-lite/env.sh +readonly thisDir=$(cd $(dirname $0); pwd) +source ${thisDir}/_travis-fold.sh travisFoldStart "test.unit.saucelabs" diff --git a/scripts/ci/test.sh b/scripts/ci/test.sh index 256d22df5d..67e4f63c4d 100755 --- a/scripts/ci/test.sh +++ b/scripts/ci/test.sh @@ -3,33 +3,41 @@ set -u -e -o pipefail # Setup environment -source ${TRAVIS_BUILD_DIR}/scripts/ci-lite/_travis_fold.sh -source ${TRAVIS_BUILD_DIR}/scripts/ci-lite/env.sh +readonly thisDir=$(cd $(dirname $0); pwd) +source ${thisDir}/_travis-fold.sh + + +# If the previous commands in the `script` section of .travis.yaml failed, then abort. +# The variable is not set in early stages of the build, so we default to 0 there. +# https://docs.travis-ci.com/user/environment-variables/ +if [[ ${TRAVIS_TEST_RESULT=0} == 1 ]]; then + exit 1; +fi case ${CI_MODE} in js) - ./scripts/ci-lite/test_js.sh + ${thisDir}/test-js.sh ;; e2e) - ./scripts/ci-lite/test_e2e.sh + ${thisDir}/test-e2e.sh ;; saucelabs_required) - ./scripts/ci-lite/test_saucelabs.sh + ${thisDir}/test-saucelabs.sh ;; browserstack_required) - ./scripts/ci-lite/test_browserstack.sh + ${thisDir}/test-browserstack.sh ;; saucelabs_optional) - ./scripts/ci-lite/test_saucelabs.sh + ${thisDir}/test-saucelabs.sh ;; browserstack_optional) - ./scripts/ci-lite/test_browserstack.sh + ${thisDir}/test-browserstack.sh ;; docs_test) - ./scripts/ci-lite/test_docs.sh + ${thisDir}/test-docs.sh ;; aio) - ./scripts/ci-lite/test_aio.sh + ${thisDir}/test-aio.sh ;; esac diff --git a/scripts/sauce/sauce_connect_setup.sh b/scripts/sauce/sauce_connect_setup.sh index 48e4612cd1..1538c69947 100755 --- a/scripts/sauce/sauce_connect_setup.sh +++ b/scripts/sauce/sauce_connect_setup.sh @@ -2,10 +2,9 @@ set +x -u -e -o pipefail - # Setup environment -source ${TRAVIS_BUILD_DIR}/scripts/ci-lite/_travis_fold.sh -source ${TRAVIS_BUILD_DIR}/scripts/ci-lite/env.sh +readonly thisDir=$(cd $(dirname $0); pwd) +source ${thisDir}/../ci/_travis-fold.sh