Skip to content

Commit a24e652

Browse files
authored
ci: clean up CI logging, folding, add build time logging, and improve error handling (angular#14425)
1 parent 207298c commit a24e652

24 files changed

Lines changed: 621 additions & 416 deletions

.travis.yml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,18 @@ matrix:
5353
- env: "CI_MODE=saucelabs_optional"
5454
- env: "CI_MODE=browserstack_optional"
5555

56+
before_install:
57+
- ./scripts/ci-lite/env.sh print
58+
5659
install:
5760
- ./scripts/ci-lite/install.sh
5861

5962
script:
60-
- ./scripts/ci-lite/build.sh && ./scripts/ci-lite/test.sh
61-
62-
after_success:
63-
- ./scripts/ci-lite/deploy_aio_staging.sh
64-
65-
after_script:
63+
- ./scripts/ci-lite/build.sh
64+
- ./scripts/ci-lite/test.sh
65+
# deploy is part of 'script' and not 'after_success' so that we fail the build if the deployment fails
66+
- ./scripts/ci-lite/deploy.sh
67+
- ./scripts/ci-lite/angular.sh
68+
# all the scripts under this line will not quickly abort in case ${TRAVIS_TEST_RESULT} is 1 (job failure)
6669
- ./scripts/ci-lite/cleanup.sh
70+
- ./scripts/ci-lite/print-logs.sh

build.sh

Lines changed: 76 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#!/usr/bin/env bash
22

3-
set -e -o pipefail
3+
set -u -e -o pipefail
4+
5+
source ${TRAVIS_BUILD_DIR}/scripts/ci-lite/_travis_fold.sh
46

57
cd `dirname $0`
68

@@ -76,66 +78,75 @@ VERSION="${VERSION_PREFIX}${VERSION_SUFFIX}"
7678
ROUTER_VERSION="${ROUTER_VERSION_PREFIX}${VERSION_SUFFIX}"
7779
echo "====== BUILDING: Version ${VERSION} (Router ${ROUTER_VERSION})"
7880

79-
export NODE_PATH=${NODE_PATH}:$(pwd)/dist/all:$(pwd)/dist/tools
8081
TSC="node --max-old-space-size=3000 dist/tools/@angular/tsc-wrapped/src/main"
8182
UGLIFYJS=`pwd`/node_modules/.bin/uglifyjs
8283
BABELJS=`pwd`/node_modules/.bin/babel
8384
BABILI=`pwd`/node_modules/.bin/babili
8485
TSCONFIG=./tools/tsconfig.json
85-
echo "====== (tools)COMPILING: \$(npm bin)/tsc -p ${TSCONFIG} ====="
86-
rm -rf ./dist/tools/
87-
mkdir -p ./dist/tools/
88-
$(npm bin)/tsc -p ${TSCONFIG}
8986

90-
cp ./tools/@angular/tsc-wrapped/package.json ./dist/tools/@angular/tsc-wrapped
87+
88+
travisFoldStart "build tools"
89+
echo "====== (tools)COMPILING: \$(npm bin)/tsc -p ${TSCONFIG} ====="
90+
rm -rf ./dist/tools/
91+
mkdir -p ./dist/tools/
92+
$(npm bin)/tsc -p ${TSCONFIG}
93+
94+
cp ./tools/@angular/tsc-wrapped/package.json ./dist/tools/@angular/tsc-wrapped
95+
travisFoldEnd "build tools"
96+
9197

9298
if [[ ${BUILD_ALL} == true ]]; then
93-
rm -rf ./dist/all/
94-
mkdir -p ./dist/all/
95-
96-
echo "====== Copying files needed for e2e tests ====="
97-
cp -r ./modules/playground ./dist/all/
98-
cp -r ./modules/playground/favicon.ico ./dist/
99-
#rsync -aP ./modules/playground/* ./dist/all/playground/
100-
mkdir ./dist/all/playground/vendor
101-
cd ./dist/all/playground/vendor
102-
ln -s ../../../../node_modules/core-js/client/core.js .
103-
ln -s ../../../../node_modules/zone.js/dist/zone.js .
104-
ln -s ../../../../node_modules/zone.js/dist/long-stack-trace-zone.js .
105-
ln -s ../../../../node_modules/systemjs/dist/system.src.js .
106-
ln -s ../../../../node_modules/base64-js .
107-
ln -s ../../../../node_modules/reflect-metadata/Reflect.js .
108-
ln -s ../../../../node_modules/rxjs .
109-
ln -s ../../../../node_modules/angular/angular.js .
110-
ln -s ../../../../node_modules/hammerjs/hammer.js .
111-
cd -
112-
113-
echo "====== Copying files needed for benchmarks ====="
114-
cp -r ./modules/benchmarks ./dist/all/
115-
cp -r ./modules/benchmarks/favicon.ico ./dist/
116-
mkdir ./dist/all/benchmarks/vendor
117-
cd ./dist/all/benchmarks/vendor
118-
ln -s ../../../../node_modules/core-js/client/core.js .
119-
ln -s ../../../../node_modules/zone.js/dist/zone.js .
120-
ln -s ../../../../node_modules/zone.js/dist/long-stack-trace-zone.js .
121-
ln -s ../../../../node_modules/systemjs/dist/system.src.js .
122-
ln -s ../../../../node_modules/reflect-metadata/Reflect.js .
123-
ln -s ../../../../node_modules/rxjs .
124-
ln -s ../../../../node_modules/angular/angular.js .
125-
ln -s ../../../../bower_components/polymer .
126-
ln -s ../../../../node_modules/incremental-dom/dist/incremental-dom-cjs.js
127-
cd -
128-
129-
TSCONFIG=./modules/tsconfig.json
130-
echo "====== (all)COMPILING: \$(npm bin)/tsc -p ${TSCONFIG} ====="
131-
# compile ts code
132-
$TSC -p modules/tsconfig.json
133-
134-
rm -rf ./dist/packages-dist
99+
travisFoldStart "clean dist"
100+
rm -rf ./dist/all/
101+
rm -rf ./dist/packages-dist
102+
travisFoldEnd "clean dist"
103+
104+
travisFoldStart "copy e2e files"
105+
mkdir -p ./dist/all/
106+
107+
echo "====== Copying files needed for e2e tests ====="
108+
cp -r ./modules/playground ./dist/all/
109+
cp -r ./modules/playground/favicon.ico ./dist/
110+
#rsync -aP ./modules/playground/* ./dist/all/playground/
111+
mkdir ./dist/all/playground/vendor
112+
cd ./dist/all/playground/vendor
113+
ln -s ../../../../node_modules/core-js/client/core.js .
114+
ln -s ../../../../node_modules/zone.js/dist/zone.js .
115+
ln -s ../../../../node_modules/zone.js/dist/long-stack-trace-zone.js .
116+
ln -s ../../../../node_modules/systemjs/dist/system.src.js .
117+
ln -s ../../../../node_modules/base64-js .
118+
ln -s ../../../../node_modules/reflect-metadata/Reflect.js .
119+
ln -s ../../../../node_modules/rxjs .
120+
ln -s ../../../../node_modules/angular/angular.js .
121+
ln -s ../../../../node_modules/hammerjs/hammer.js .
122+
cd -
123+
124+
echo "====== Copying files needed for benchmarks ====="
125+
cp -r ./modules/benchmarks ./dist/all/
126+
cp -r ./modules/benchmarks/favicon.ico ./dist/
127+
mkdir ./dist/all/benchmarks/vendor
128+
cd ./dist/all/benchmarks/vendor
129+
ln -s ../../../../node_modules/core-js/client/core.js .
130+
ln -s ../../../../node_modules/zone.js/dist/zone.js .
131+
ln -s ../../../../node_modules/zone.js/dist/long-stack-trace-zone.js .
132+
ln -s ../../../../node_modules/systemjs/dist/system.src.js .
133+
ln -s ../../../../node_modules/reflect-metadata/Reflect.js .
134+
ln -s ../../../../node_modules/rxjs .
135+
ln -s ../../../../node_modules/angular/angular.js .
136+
ln -s ../../../../bower_components/polymer .
137+
ln -s ../../../../node_modules/incremental-dom/dist/incremental-dom-cjs.js
138+
cd -
139+
travisFoldEnd "copy e2e files"
140+
141+
TSCONFIG=modules/tsconfig.json
142+
travisFoldStart "tsc -p ${TSCONFIG}"
143+
$TSC -p ${TSCONFIG}
144+
travisFoldEnd "tsc -p ${TSCONFIG}"
135145
fi
136146

137147
for PACKAGE in ${PACKAGES[@]}
138148
do
149+
travisFoldStart "build package: ${PACKAGE}"
139150
PWD=`pwd`
140151
ROOTDIR=${PWD}/modules/@angular
141152
SRCDIR=${PWD}/modules/@angular/${PACKAGE}
@@ -290,7 +301,7 @@ do
290301
$UGLIFYJS -c --screw-ie8 --comments -o ${UMD_ES5_MIN_PATH} ${UMD_ES5_PATH}
291302
fi
292303

293-
rm -f ${DISTDIR}/.babelrc
304+
rm -f ${DESTDIR}/.babelrc
294305
if [[ -d ${DEST_MODULE} ]]; then
295306
echo "====== Downleveling ES2015 to ESM/ES5"
296307
downlevelES2015 ${DESTDIR} ${JS_PATH} ${JS_PATH_ES5}
@@ -443,16 +454,25 @@ do
443454
echo "====== EXECUTE: perl -p -i -e \"s/0\.0\.0\-ROUTERPLACEHOLDER/${ROUTER_VERSION}/g\" $""(grep -ril 0\.0\.0\-ROUTERPLACEHOLDER .)"
444455
perl -p -i -e "s/0\.0\.0\-ROUTERPLACEHOLDER/${ROUTER_VERSION}/g" $(grep -ril 0\.0\.0\-ROUTERPLACEHOLDER .) < /dev/null 2> /dev/null
445456
)
457+
458+
travisFoldEnd "build package: ${PACKAGE}"
446459
done
447460

448461
if [[ ${BUILD_EXAMPLES} == true ]]; then
449-
echo ""
450-
echo "====== Building examples: ./modules/@angular/examples/build.sh ====="
451-
./modules/@angular/examples/build.sh
462+
travisFoldStart "build examples"
463+
echo "====== Building examples: ./modules/@angular/examples/build.sh ====="
464+
./modules/@angular/examples/build.sh
465+
travisFoldEnd "build examples"
452466
fi
453467

454468
if [[ ${REMOVE_BENCHPRESS} == true ]]; then
455-
echo ""
456-
echo "==== Removing benchpress from publication"
457-
rm -r dist/packages-dist/benchpress
469+
travisFoldStart "remove benchpress"
470+
echo ""
471+
echo "==== Removing benchpress from publication"
472+
rm -r dist/packages-dist/benchpress
473+
travisFoldEnd "remove benchpress"
458474
fi
475+
476+
477+
# Print return arrows as a log separator
478+
travisFoldReturnArrows

modules/@angular/examples/build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env bash
22

3-
set -e -o pipefail
3+
set -u -e -o pipefail
44

55
#
66
# This script is used to compile and copy the contents for each of

scripts/browserstack/start_tunnel.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,13 @@ tunnel.start(function(error) {
5656
tunnel.on('error', function(error) {
5757
console.error(error);
5858
});
59+
60+
61+
// TODO(i): we should properly stop the tunnel when tests are done.
62+
// tunnel.stop(function(error) {
63+
// if (error) {
64+
// console.log(error);
65+
// } else {
66+
// console.log('browserStack tunnel has stopped');
67+
// }
68+
//});
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
#!/bin/bash
2+
3+
set +x +v -u -e -o pipefail
4+
15
export BROWSER_STACK_ACCESS_KEY=`echo $BROWSER_STACK_ACCESS_KEY | rev`
26

37
node ./scripts/browserstack/start_tunnel.js &
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
#!/bin/bash
22

3-
set -e -o pipefail
3+
set -u -e -o pipefail
44

55

66
echo "Shutting down Browserstack tunnel"
7-
echo "TODO: implement me"
8-
exit 1
7+
echo "TODO: implement me, see start_tunnel.js for info on how to stop the tunnel"

scripts/ci-lite/_travis_fold.sh

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# private variable to track folds within this script
2+
travisFoldStack=()
3+
4+
function travisFoldStart() {
5+
local foldName="${0#./} ${1}"
6+
# get current time as nanoseconds since the beginning of the epoch
7+
foldStartTime=$(date +%s%N)
8+
# convert all non alphanum chars except for "-" and "." to "--"
9+
local sanitizedFoldName=${foldName//[^[:alnum:]\-\.]/--}
10+
# strip trailing "-"
11+
sanitizedFoldName=${sanitizedFoldName%-}
12+
# push the foldName onto the stack
13+
travisFoldStack+=("${sanitizedFoldName}|${foldStartTime}")
14+
15+
echo ""
16+
echo "travis_fold:start:${sanitizedFoldName}"
17+
echo "travis_time:start:${sanitizedFoldName}"
18+
local enterArrow="===> ${foldName} ==>==>==>==>==>==>==>==>==>==>==>==>==>==>==>==>==>==>==>==>==>==>==>==>==>==>==>==>==>"
19+
# keep all messages consistently wide 80chars regardless of the foldName
20+
echo ${enterArrow:0:100}
21+
# turn on verbose mode so that we have better visibility into what's going on
22+
# http://tldp.org/LDP/Bash-Beginners-Guide/html/sect_02_03.html#table_02_01
23+
set -x
24+
}
25+
26+
function travisFoldEnd() {
27+
set +x
28+
local foldName="${0#./} ${1}"
29+
# convert all non alphanum chars except for "-" and "." to "--"
30+
local sanitizedFoldName=${foldName//[^[:alnum:]\-\.]/--}
31+
# strip trailing "-"
32+
sanitizedFoldName=${sanitizedFoldName%-}
33+
34+
# consult and update travisFoldStack
35+
local lastFoldIndex=$(expr ${#travisFoldStack[@]} - 1)
36+
local lastFoldString=${travisFoldStack[$lastFoldIndex]}
37+
# split the string by | and then turn that into an array
38+
local lastFoldArray=(${lastFoldString//\|/ })
39+
local lastSanitizedFoldName=${lastFoldArray[0]}
40+
local lastFoldStartTime=${lastFoldArray[1]}
41+
local foldFinishTime=$(date +%s%N)
42+
local foldDuration=$(expr ${foldFinishTime} - ${lastFoldStartTime})
43+
44+
# write into build-perf.log file
45+
local logIndent=$(expr ${lastFoldIndex} \* 2)
46+
printf "%6ss%${logIndent}s: %s\n" $(expr ${foldDuration} / 1000000000) " " "${foldName}" >> ${LOGS_DIR}/build-perf.log
47+
48+
# pop
49+
travisFoldStack=(${travisFoldStack[@]:0:lastFoldIndex})
50+
51+
# check for misalignment
52+
if [[ ${lastSanitizedFoldName} != ${sanitizedFoldName} ]]; then
53+
echo "Travis fold mis-alignment detected! travisFoldEnd expected sanitized fold name '${lastSanitizedFoldName}', but received '${sanitizedFoldName}' (after sanitization)"
54+
exit 1
55+
fi
56+
57+
local returnArrow="<=== ${foldName} <==<==<==<==<==<==<==<==<==<==<==<==<==<==<==<==<==<==<==<==<==<==<==<==<==<==<==<==<==<==<==<=="
58+
# keep all messages consistently wide 80chars regardless of the foldName
59+
echo ${returnArrow:0:100}
60+
echo ""
61+
echo "travis_time:end:${sanitizedFoldName}:start=${lastFoldStartTime},finish=${foldFinishTime},duration=${foldDuration}"
62+
echo "travis_fold:end:${sanitizedFoldName}"
63+
}
64+
65+
66+
function travisFoldReturnArrows() {
67+
# print out return arrows so that it's easy to see the end of the script in the log
68+
echo ""
69+
returnArrow="<=== ${0#./} <==<==<==<==<==<==<==<==<==<==<==<==<==<==<==<==<==<==<==<==<==<==<==<==<==<==<==<==<==<==<=="
70+
# keep all messages consistently wide 80chars regardless of the foldName
71+
echo ${returnArrow:0:100}
72+
echo "<==<==<==<==<==<==<==<==<==<==<==<==<==<==<==<==<==<==<==<==<==<==<==<==<==<==<==<==<==<==<==<==<==="
73+
echo ""
74+
}

scripts/ci-lite/angular.sh

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/usr/bin/env bash
2+
3+
set -u -e -o pipefail
4+
5+
# created based on the official Angular logo from https://angular.io/presskit.html
6+
# converted using http://www.text-image.com/convert/
7+
# colors added based on http://stackoverflow.com/questions/5947742/how-to-change-the-output-color-of-echo-in-linux
8+
9+
10+
# If the previous commands in the `script` section of .travis.yaml failed, then abort.
11+
if [[ ${TRAVIS_TEST_RESULT} == 1 ]]; then
12+
exit 1;
13+
fi
14+
15+
16+
RED='\033[0;31m'
17+
LRED='\033[1;31m'
18+
WHITE='\033[1;37m'
19+
20+
21+
echo -e ${LRED}' ``'${RED}'`` '
22+
echo -e ${LRED}' `.--://'${RED}':::--.`'
23+
echo -e ${LRED}' `..-:////////'${RED}':::::::::-.``'
24+
echo -e ${LRED}' `.-::////////////'${WHITE}'oo'${RED}'::::::::::::::-.`'
25+
echo -e ${LRED}' `--://///////////////'${WHITE}'+NN+'${RED}'::::::::::::::::::-.`'
26+
echo -e ${LRED}' `///////////////////'${WHITE}'+NMMN/'${RED}':::::::::::::::::::`'
27+
echo -e ${LRED}' ///////////////////'${WHITE}'mMMMMm/'${RED}'::::::::::::::::::'
28+
echo -e ${LRED}' ://///////////////'${WHITE}'dMMMMMMd/'${RED}':::::::::::::::::'
29+
echo -e ${LRED}' -////////////////'${WHITE}'dMMMNNMMMh/'${RED}':::::::::::::::-'
30+
echo -e ${LRED}' .///////////////'${WHITE}'hMMMM++MMMMh'${RED}':::::::::::::::.'
31+
echo -e ${LRED}' `//////////////'${WHITE}'yMMMMs'${LRED}'/'${RED}':'${WHITE}'sMMMMy'${RED}'::::::::::::::`'
32+
echo -e ${LRED}' :////////////'${WHITE}'sMMMMy'${LRED}'//'${RED}'::'${WHITE}'yMMMMs'${RED}':::::::::::::'
33+
echo -e ${LRED}' -///////////'${WHITE}'oMMMMd'${LRED}'///'${RED}'::'${WHITE}'/dMMMMo'${RED}':::::::::::-'
34+
echo -e ${LRED}' .//////////'${WHITE}'+NMMMMddddddddMMMMN+'${RED}'::::::::::.'
35+
echo -e ${LRED}' `/////////'${WHITE}'+NMMMMMMMMMMMMMMMMMMN+'${RED}':::::::::`'
36+
echo -e ${LRED}' :////////'${WHITE}'mMMMMyyyyyyyyyyyyMMMMm/'${RED}'::::::::'
37+
echo -e ${LRED}' -///////'${WHITE}'mMMMMs'${LRED}'//////'${RED}'::::::'${WHITE}'sMMMMm/'${RED}'::::::-'
38+
echo -e ${LRED}' .//////'${WHITE}'dMMMMy'${LRED}'///////'${RED}':::::::'${WHITE}'yMMMMd/'${RED}':::::.'
39+
echo -e ${LRED}' `/////'${WHITE}'hMMMMd'${LRED}'////////'${RED}':::::::'${WHITE}'/dMMMMh'${RED}':::::`'
40+
echo -e ${LRED}' -://///////////////'${RED}'::::::::::::::::::-'
41+
echo -e ${LRED}' `.://////////////'${RED}'::::::::::::::-.`'
42+
echo -e ${LRED}' `-://////////'${RED}':::::::::::-`'
43+
echo -e ${LRED}' `.-://////'${RED}':::::::-.`'
44+
echo -e ${LRED}' `.:///'${RED}'::::.`'
45+
echo -e ${LRED}' .-'${RED}'-` '
46+

0 commit comments

Comments
 (0)