Skip to content

Commit 2f3ff53

Browse files
authored
chore: retry failed Circle CI tests (#2814)
* chore: retry failed Circle CI tests W-10946477 * chore: fix * chore: fix * chore: fix * chore: fix * chore: fix * chore: fix * chore: fix * chore: deliberately fail a test to see what happens * chore: improve retry script * fix: whitespace * Revert "chore: deliberately fail a test to see what happens" This reverts commit 611fc34. * chore: rename to retry_karma
1 parent 54143ab commit 2f3ff53

File tree

1 file changed

+63
-16
lines changed

1 file changed

+63
-16
lines changed

.circleci/config.yml

Lines changed: 63 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,55 @@ executors:
2323

2424
# Custom commands definition
2525
commands:
26+
# Based on https://circleci.com/developer/orbs/orb/kimh/run-with-retry
27+
retry_karma:
28+
description: Retry command multiple times until it succeeds
29+
parameters:
30+
command:
31+
type: string
32+
command_name:
33+
type: string
34+
working_directory:
35+
type: string
36+
retry_count:
37+
type: integer
38+
default: 3
39+
coverage:
40+
type: boolean
41+
default: false
42+
compat:
43+
type: boolean
44+
default: false
45+
disable_synthetic:
46+
type: boolean
47+
default: false
48+
force_native_shadow_mode:
49+
type: boolean
50+
default: false
51+
steps:
52+
- run:
53+
name: << parameters.command_name >>
54+
working_directory: << parameters.working_directory >>
55+
command: |
56+
retry() {
57+
MAX_RETRY=<< parameters.retry_count >>
58+
n=0
59+
until [ $n -ge $MAX_RETRY ]
60+
do
61+
echo "Try $[$n+1]/$MAX_RETRY..."
62+
"$@" && break
63+
n=$[$n+1]
64+
done
65+
if [ $n -ge $MAX_RETRY ]; then
66+
echo "Failed: ${@}" >&2
67+
exit 1
68+
fi
69+
}
70+
<<# parameters.disable_synthetic >> DISABLE_SYNTHETIC=1 <</ parameters.disable_synthetic >> \
71+
<<# parameters.force_native_shadow_mode >> FORCE_NATIVE_SHADOW_MODE_FOR_TEST=1 <</ parameters.force_native_shadow_mode >> \
72+
<<# parameters.compat >> COMPAT=1 <</ parameters.compat >> \
73+
<<# parameters.coverage >> COVERAGE=1 <</ parameters.coverage >> \
74+
retry << parameters.command >>
2675
# Setup
2776
restore_yarn_cache:
2877
description: Restore Yarn cache from previous build
@@ -93,15 +142,14 @@ commands:
93142
type: boolean
94143
default: true
95144
steps:
96-
- run:
97-
name: Run karma integration tests
145+
- retry_karma:
146+
command_name: Run karma integration tests
98147
working_directory: packages/integration-karma
99-
command: >
100-
<<# parameters.disable_synthetic >> DISABLE_SYNTHETIC=1 <</ parameters.disable_synthetic >>
101-
<<# parameters.force_native_shadow_mode >> FORCE_NATIVE_SHADOW_MODE_FOR_TEST=1 <</ parameters.force_native_shadow_mode >>
102-
<<# parameters.compat >> COMPAT=1 <</ parameters.compat >>
103-
<<# parameters.coverage >> COVERAGE=1 <</ parameters.coverage >>
104-
yarn sauce
148+
disable_synthetic: << parameters.disable_synthetic >>
149+
force_native_shadow_mode: << parameters.force_native_shadow_mode >>
150+
compat: << parameters.compat >>
151+
coverage: << parameters.coverage >>
152+
command: yarn sauce
105153

106154

107155
# Jobs definition
@@ -162,12 +210,11 @@ jobs:
162210
disable_synthetic: false
163211
compat: false
164212
force_native_shadow_mode: true
165-
- run:
166-
name: Run karma hydration tests
213+
- retry_karma:
214+
command_name: Run karma hydration tests
167215
command: yarn hydration:sauce
168216
working_directory: packages/integration-karma
169-
environment:
170-
COVERAGE: 1
217+
coverage: true
171218
- run:
172219
name: Compute karma coverage
173220
command: yarn coverage
@@ -181,8 +228,8 @@ jobs:
181228
steps:
182229
- load_workspace
183230
- start_sauce_connect
184-
- run:
185-
name: Run integration test - Chrome SauceLabs
231+
- retry_karma:
232+
command_name: Run integration test - Chrome SauceLabs
186233
command: yarn sauce:prod --browsers chrome
187234
working_directory: packages/integration-tests
188235

@@ -194,8 +241,8 @@ jobs:
194241
steps:
195242
- load_workspace
196243
- start_sauce_connect
197-
- run:
198-
name: Run integration test - IE11 SauceLabs
244+
- retry_karma:
245+
command_name: Run integration test - IE11 SauceLabs
199246
command: yarn sauce:prod_compat --browsers ie11
200247
working_directory: packages/integration-tests
201248

0 commit comments

Comments
 (0)