ci: redo how env variables are set and shared in ci to prevent collisions

This commit is contained in:
Igor Minar 2017-03-05 01:49:10 -08:00 committed by Igor Minar
parent 91fe3aadbc
commit b8f0c3dc7b
21 changed files with 180 additions and 135 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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
}

View File

@ -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'

View File

@ -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"

View File

@ -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

View File

@ -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)

View File

@ -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}"

View File

@ -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

View File

@ -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=(

View File

@ -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

View File

@ -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.

View File

@ -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"
)

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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

View File

@ -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"

View File

@ -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

View File

@ -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