Skip to content

Commit 165aa0c

Browse files
committed
add auto-retry logic to ci test scripts
1 parent 8a7ed36 commit 165aa0c

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

.circleci/test.sh

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,36 @@ set +e
55
set +o pipefail
66

77
EXIT_STATE=0
8+
MAX_AUTO_RETRY=5
9+
10+
# inspired by https://unix.stackexchange.com/a/82602
11+
retry () {
12+
local n=0
13+
14+
until [ $n -ge $MAX_AUTO_RETRY ]; do
15+
"$@" && break
16+
n=$[$n+1]
17+
echo ''
18+
echo run $n of $MAX_AUTO_RETRY failed, trying again ...
19+
echo ''
20+
sleep 15
21+
done
22+
23+
if [ $n -eq $MAX_AUTO_RETRY ]; then
24+
EXIT_STATE=1
25+
fi
26+
}
827

928
case $1 in
1029

1130
jasmine)
12-
npm run test-jasmine -- --skip-tags=gl,noCI || EXIT_STATE=$?
31+
retry npm run test-jasmine -- --skip-tags=gl,noCI
1332
exit $EXIT_STATE
1433
;;
1534

1635
jasmine2)
17-
npm run test-jasmine -- --tags=gl --skip-tags=noCI || EXIT_STATE=$?
18-
npm run test-bundle || EXIT_STATE=$?
36+
retry npm run test-jasmine -- --tags=gl --skip-tags=noCI
37+
retry npm run test-bundle
1938
exit $EXIT_STATE
2039
;;
2140

0 commit comments

Comments
 (0)