2016-04-28 20:50:03 -04:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2017-03-05 04:49:10 -05:00
|
|
|
# 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)
|
2016-04-28 20:50:03 -04:00
|
|
|
|
2017-03-02 03:22:24 -05:00
|
|
|
# this script is extra noisy and used in many places during the build so we suppress the trace with +x to reduce the noise
|
2017-03-05 04:49:10 -05:00
|
|
|
set -u -e -o pipefail
|
2017-03-02 03:22:24 -05:00
|
|
|
|
|
|
|
# sets and optionally prints environmental variable
|
|
|
|
# usage: setEnvVar variableName variableValue
|
|
|
|
function setEnvVar() {
|
|
|
|
local name=$1
|
|
|
|
local value=$2
|
|
|
|
|
|
|
|
if [[ ${print} == "print" ]]; then
|
|
|
|
echo ${name}=${value}
|
|
|
|
fi
|
|
|
|
export ${name}=${value}
|
|
|
|
}
|
2016-04-28 20:50:03 -04:00
|
|
|
|
2017-03-05 04:49:10 -05:00
|
|
|
# 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)
|
2017-03-02 03:22:24 -05:00
|
|
|
readonly print=${1:-}
|
2017-03-05 04:49:10 -05:00
|
|
|
|
|
|
|
# print bash version just so that we know what is running all the scripts
|
|
|
|
if [[ ${print} == "print" ]]; then
|
|
|
|
bash --version
|
|
|
|
fi
|
2016-04-28 20:50:03 -04:00
|
|
|
|
|
|
|
|
2017-03-02 03:22:24 -05:00
|
|
|
#######################
|
|
|
|
# CUSTOM GLOBALS #
|
|
|
|
#######################
|
2016-04-28 20:50:03 -04:00
|
|
|
|
2017-03-02 03:22:24 -05:00
|
|
|
setEnvVar NODE_VERSION 6.9.5
|
|
|
|
setEnvVar NPM_VERSION 3.10.7 # do not upgrade to >3.10.8 unless https://github.com/npm/npm/issues/14042 is resolved
|
|
|
|
setEnvVar YARN_VERSION 0.21.3
|
2017-06-08 05:43:37 -04:00
|
|
|
setEnvVar CHROMIUM_VERSION 464641 # Chrome 59 linux stable, see https://www.chromium.org/developers/calendar
|
2017-03-02 03:22:24 -05:00
|
|
|
setEnvVar SAUCE_CONNECT_VERSION 4.3.11
|
2017-03-05 04:49:10 -05:00
|
|
|
setEnvVar PROJECT_ROOT $(cd ${thisDir}/../..; pwd)
|
2016-04-28 20:50:03 -04:00
|
|
|
|
2017-03-02 03:22:24 -05:00
|
|
|
if [[ ${TRAVIS:-} ]]; then
|
2016-04-28 20:50:03 -04:00
|
|
|
case ${CI_MODE} in
|
|
|
|
js)
|
2017-03-02 03:22:24 -05:00
|
|
|
setEnvVar KARMA_JS_BROWSERS ChromeNoSandbox
|
2016-04-28 20:50:03 -04:00
|
|
|
;;
|
|
|
|
saucelabs_required)
|
2017-03-02 03:22:24 -05:00
|
|
|
setEnvVar KARMA_JS_BROWSERS `node -e "console.log(require('/home/travis/build/angular/angular/browser-providers.conf').sauceAliases.CI_REQUIRED.join(','))"`
|
2016-04-28 20:50:03 -04:00
|
|
|
;;
|
|
|
|
browserstack_required)
|
2017-03-02 03:22:24 -05:00
|
|
|
setEnvVar KARMA_JS_BROWSERS `node -e "console.log(require('/home/travis/build/angular/angular/browser-providers.conf').browserstackAliases.CI_REQUIRED.join(','))"`
|
2016-04-28 20:50:03 -04:00
|
|
|
;;
|
2016-05-09 19:47:26 -04:00
|
|
|
saucelabs_optional)
|
2017-03-02 03:22:24 -05:00
|
|
|
setEnvVar KARMA_JS_BROWSERS `node -e "console.log(require('/home/travis/build/angular/angular/browser-providers.conf').sauceAliases.CI_OPTIONAL.join(','))"`
|
2016-05-09 19:47:26 -04:00
|
|
|
;;
|
|
|
|
browserstack_optional)
|
2017-03-02 03:22:24 -05:00
|
|
|
setEnvVar KARMA_JS_BROWSERS `node -e "console.log(require('/home/travis/build/angular/angular/browser-providers.conf').browserstackAliases.CI_OPTIONAL.join(','))"`
|
2016-05-09 19:47:26 -04:00
|
|
|
;;
|
2017-03-31 19:24:25 -04:00
|
|
|
aio)
|
2017-05-23 04:36:02 -04:00
|
|
|
# Determine the current stable branch.
|
|
|
|
readonly versionRe="^\s*([0-9]+\.[0-9]+)\.[0-9]+.*$"
|
|
|
|
setEnvVar STABLE_BRANCH `npm info @angular/core dist-tags.latest | sed -r "s/$versionRe/\1.x/"`
|
|
|
|
|
2017-05-10 17:22:16 -04:00
|
|
|
setEnvVar MIN_PWA_SCORE 95
|
2017-03-31 19:24:25 -04:00
|
|
|
;;
|
2016-04-28 20:50:03 -04:00
|
|
|
esac
|
|
|
|
else
|
2017-03-02 03:22:24 -05:00
|
|
|
setEnvVar KARMA_JS_BROWSERS Chrome
|
2016-04-28 20:50:03 -04:00
|
|
|
fi
|
|
|
|
|
|
|
|
|
2017-03-02 03:22:24 -05:00
|
|
|
if [[ ${TRAVIS:-} ]]; then
|
2016-04-28 20:50:03 -04:00
|
|
|
# used by xvfb that is used by Chromium
|
2017-03-02 03:22:24 -05:00
|
|
|
setEnvVar DISPLAY :99.0
|
2016-04-28 20:50:03 -04:00
|
|
|
|
2017-03-02 03:22:24 -05:00
|
|
|
# Use newer version of GCC to that is required to compile native npm modules for Node v4+ on Ubuntu Precise
|
2016-04-28 20:50:03 -04:00
|
|
|
# more info: https://docs.travis-ci.com/user/languages/javascript-with-nodejs#Node.js-v4-(or-io.js-v3)-compiler-requirements
|
2017-03-02 03:22:24 -05:00
|
|
|
setEnvVar CXX g++-4.8
|
2016-04-28 20:50:03 -04:00
|
|
|
|
2017-03-02 15:54:19 -05:00
|
|
|
# If NGBUILDS_IO_KEY not set yet, export the NGBUILDS_IO_KEY using the JWT token that Travis generated and exported for SAUCE_ACCESS_KEY.
|
|
|
|
# This is a workaround for travis-ci/travis-ci#7223
|
2017-03-05 09:32:44 -05:00
|
|
|
# WARNING: NGBUILDS_IO_KEY should NOT be printed
|
2017-03-02 15:54:19 -05:00
|
|
|
export NGBUILDS_IO_KEY=${NGBUILDS_IO_KEY:-$SAUCE_ACCESS_KEY}
|
|
|
|
|
2017-03-07 04:39:37 -05:00
|
|
|
# Personal token generated by mary-poppins, with only `read_org` permission
|
|
|
|
export GITHUB_TEAM_MEMBERSHIP_CHECK_KEY=35fc4093c1f29a2ddaf60cce5d57065454180bf6
|
|
|
|
|
2016-04-28 20:50:03 -04:00
|
|
|
# Used by karma and karma-chrome-launcher
|
2016-09-06 15:07:48 -04:00
|
|
|
# In order to have a meaningful SauceLabs badge on the repo page,
|
|
|
|
# the angular2-ci account is used only when pushing commits to master;
|
|
|
|
# in all other cases, the regular angular-ci account is used.
|
|
|
|
if [ "${TRAVIS_PULL_REQUEST}" = "false" ] && [ "${TRAVIS_BRANCH}" = "master" ]; then
|
2017-03-02 03:22:24 -05:00
|
|
|
setEnvVar SAUCE_USERNAME angular2-ci
|
2017-03-02 15:54:19 -05:00
|
|
|
# - not using use setEnvVar so that we don't print the key
|
|
|
|
# - we overwrite the value set by Travis JWT addon here to work around travis-ci/travis-ci#7223 for NGBUILDS_IO_KEY
|
2016-09-06 15:07:48 -04:00
|
|
|
export SAUCE_ACCESS_KEY=693ebc16208a-0b5b-1614-8d66-a2662f4e
|
|
|
|
else
|
2017-03-02 03:22:24 -05:00
|
|
|
setEnvVar SAUCE_USERNAME angular-ci
|
2017-03-02 15:54:19 -05:00
|
|
|
# - not using use setEnvVar so that we don't print the key
|
|
|
|
# - we overwrite the value set by Travis JWT addon here to work around travis-ci/travis-ci#7223 for NGBUILDS_IO_KEY
|
2016-09-06 15:07:48 -04:00
|
|
|
export SAUCE_ACCESS_KEY=9b988f434ff8-fbca-8aa4-4ae3-35442987
|
|
|
|
fi
|
2017-03-02 03:22:24 -05:00
|
|
|
|
|
|
|
setEnvVar BROWSER_STACK_USERNAME angularteam1
|
2017-03-02 15:54:19 -05:00
|
|
|
# not using use setEnvVar so that we don't print the key
|
2016-04-28 20:50:03 -04:00
|
|
|
export BROWSER_STACK_ACCESS_KEY=BWCd4SynLzdDcv8xtzsB
|
2017-03-02 03:22:24 -05:00
|
|
|
setEnvVar CHROME_BIN ${HOME}/.chrome/chromium/chrome-linux/chrome
|
|
|
|
setEnvVar BROWSER_PROVIDER_READY_FILE /tmp/angular-build/browser-provider-tunnel-init.lock
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#######################
|
|
|
|
# PREEXISTING GLOBALS #
|
|
|
|
#######################
|
|
|
|
|
|
|
|
# Prepend `~/.yarn/bin` to the PATH
|
|
|
|
setEnvVar PATH $HOME/.yarn/bin:$PATH
|
|
|
|
|
|
|
|
# Append dist/all to the NODE_PATH so that cjs module resolver finds find the packages that use
|
|
|
|
# absolute module ids (e.g. @angular/core)
|
|
|
|
setEnvVar NODE_PATH ${NODE_PATH:-}:${PROJECT_ROOT}/dist/all:${PROJECT_ROOT}/dist/tools
|
|
|
|
setEnvVar LOGS_DIR /tmp/angular-build/logs
|
|
|
|
|
2017-05-15 08:43:08 -04:00
|
|
|
# Log file for full PWA testing results
|
|
|
|
setEnvVar PWA_RESULTS_LOG $LOGS_DIR/pwa-results.json
|
|
|
|
|
2017-03-02 03:22:24 -05:00
|
|
|
# strip leading "/home/travis/build/angular/angular/" or "./" path. Could this be done in one shot?
|
|
|
|
CURRENT_SHELL_SOURCE_FILE=${BASH_SOURCE#${PROJECT_ROOT}/}
|
|
|
|
export CURRENT_SHELL_SOURCE_FILE=${CURRENT_SHELL_SOURCE_FILE#./}
|
|
|
|
# Prefix xtrace output with file name/line and optionally function name
|
|
|
|
# http://wiki.bash-hackers.org/scripting/debuggingtips#making_xtrace_more_useful
|
|
|
|
# TODO(i): I couldn't figure out how to set this via `setEnvVar` so I just set it manually
|
|
|
|
export PS4='+(${CURRENT_SHELL_SOURCE_FILE}:${LINENO}): ${FUNCNAME[0]:+${FUNCNAME[0]}(): }'
|
|
|
|
if [[ ${print} == "print" ]]; then
|
|
|
|
echo PS4=${PS4}
|
2016-04-28 20:50:03 -04:00
|
|
|
fi
|
|
|
|
|
2017-03-05 04:49:10 -05:00
|
|
|
eval "${ORIGINAL_SHELL_OPTIONS}"
|