11#! /bin/bash
22
3- trap ' exit ' INT
3+ set -uo pipefail
44
5- PLATFORM=${1:- }
5+ PLATFORM=" "
6+ RECORD_ON_FAILURE=false
7+ IS_RECORDING=false
8+ NEW_ARCH_ENABLED=${NEW_ARCH_ENABLED:- false}
9+
10+ stop_recording () {
11+ local recording_dir=$1
12+
13+ if [ " $IS_RECORDING " = true ]; then
14+ echo " Stopping recording..."
15+
16+ if [ " $PLATFORM " = " android" ]; then
17+ adb shell " kill -2 \$ (cat /data/local/tmp/recording_pid.txt)" 2> /dev/null || true
18+ sleep 2
19+ adb pull /data/local/tmp/recording.mp4 " $recording_dir /recording.mp4" 2> /dev/null || true
20+ adb shell " rm -f /data/local/tmp/recording.mp4 /data/local/tmp/recording_pid.txt" 2> /dev/null || true
21+
22+ elif [ " $PLATFORM " = " ios" ]; then
23+ killall -SIGINT simctl || true
24+ fi
25+
26+ IS_RECORDING=false
27+ echo " Recording saved to $recording_dir /recording.mp4"
28+ fi
29+ }
30+
31+ start_recording () {
32+ local recording_dir=$1
33+
34+ echo " Starting screen recording..."
35+ mkdir -p " $recording_dir "
36+
37+ if [ " $PLATFORM " = " android" ]; then
38+ adb shell " screenrecord --bugreport /data/local/tmp/recording.mp4 & echo \$ ! > /data/local/tmp/recording_pid.txt" &
39+ IS_RECORDING=true
40+ elif [ " $PLATFORM " = " ios" ]; then
41+ xcrun simctl io booted recordVideo --codec=h264 -f " $recording_dir /recording.mp4" &
42+ IS_RECORDING=true
43+ fi
44+ }
45+
46+ cleanup () {
47+ if [ " $IS_RECORDING " = true ]; then
48+ echo " Interrupt cleanup - stopping recording..."
49+ if [ " $PLATFORM " = " android" ]; then
50+ adb shell " kill -2 \$ (cat /data/local/tmp/recording_pid.txt)" 2> /dev/null || true
51+ elif [ " $PLATFORM " = " ios" ]; then
52+ killall -SIGINT simctl || true
53+ fi
54+ IS_RECORDING=false
55+ fi
56+ }
57+
58+ handle_interrupt () {
59+ cleanup
60+ exit 130
61+ }
62+
63+ trap cleanup EXIT
64+ trap handle_interrupt INT TERM
65+
66+ # Parse arguments
67+ while [[ $# -gt 0 ]]; do
68+ case " $1 " in
69+ --record-on-failure)
70+ RECORD_ON_FAILURE=true
71+ ;;
72+ * )
73+ if [ -z " $PLATFORM " ]; then
74+ PLATFORM=" $1 "
75+ fi
76+ ;;
77+ esac
78+ shift
79+ done
680
781# Validate passed platform
882case $PLATFORM in
@@ -32,6 +106,8 @@ mkdir -p e2e-artifacts
32106
33107# Optional sharding configuration via environment variables
34108# Set SHARD_COUNT to the total number of shards and SHARD_INDEX to the index for this job (0-based)
109+ SHARD_COUNT=${SHARD_COUNT:- }
110+ SHARD_INDEX=${SHARD_INDEX:- }
35111if { [ -n " $SHARD_COUNT " ] || [ -n " $SHARD_INDEX " ]; } && { [ -z " $SHARD_COUNT " ] || [ -z " $SHARD_INDEX " ]; }; then
36112 echo " Error! Both SHARD_COUNT and SHARD_INDEX must be set to enable sharding."
37113 exit 1
@@ -49,9 +125,9 @@ if [ -n "$SHARD_COUNT" ]; then
49125 echo " Sharding enabled: SHARD_INDEX=$SHARD_INDEX SHARD_COUNT=$SHARD_COUNT "
50126fi
51127
52- # Retry timing configuration (in seconds)
53- RETRY_SLEEP_FAST= ${RETRY_SLEEP_FAST :- 30}
54- RETRY_SLEEP_SLOW= ${RETRY_SLEEP_SLOW :- 120}
128+ # Retry configuration
129+ MAX_ATTEMPTS=3
130+ RETRY_DELAYS=(30 120) # Delay before retry 1, retry 2, etc.
55131
56132idx=0
57133for file in $allTestFiles
68144 fi
69145 fi
70146
71- if ! eval " $testCmd --debug-output e2e-artifacts/$testName " ;
72- then
73- echo " Test ${file} failed. Retrying in ${RETRY_SLEEP_FAST} s..."
74- sleep " $RETRY_SLEEP_FAST "
75- if ! eval " $testCmd --debug-output e2e-artifacts/$testName -retry-1" ;
76- then
77- echo " Test ${file} failed again. Retrying for the last time in ${RETRY_SLEEP_SLOW} s..."
78- sleep " $RETRY_SLEEP_SLOW "
79- if ! eval " $testCmd --debug-output e2e-artifacts/$testName -retry-2" ;
80- then
81- failedTests+=(" $file " )
82- # Check if this is a Financial Connections test
83- if [[ " $testName " == * " financial-connections" * ]]; then
84- failedFinancialConnectionsTests+=(" $file " )
85- fi
147+ success=false
148+ for attempt in $( seq 1 $MAX_ATTEMPTS ) ; do
149+ # Determine artifact directory name
150+ if [ " $attempt " -eq 1 ]; then
151+ artifactDir=" e2e-artifacts/$testName "
152+ else
153+ artifactDir=" e2e-artifacts/$testName -retry-$(( attempt - 1 )) "
154+ fi
155+
156+ # Start recording on retry attempts (after first failure)
157+ if [ " $attempt " -gt 1 ] && [ " $RECORD_ON_FAILURE " = " true" ]; then
158+ start_recording " $artifactDir "
159+ fi
160+
161+ if eval " $testCmd --debug-output $artifactDir " ; then
162+ # Stop recording if it was running
163+ if [ " $attempt " -gt 1 ] && [ " $RECORD_ON_FAILURE " = " true" ]; then
164+ stop_recording " $artifactDir "
86165 fi
166+ success=true
167+ break
168+ fi
169+
170+ # Stop recording if it was running
171+ if [ " $attempt " -gt 1 ] && [ " $RECORD_ON_FAILURE " = " true" ]; then
172+ stop_recording " $artifactDir "
173+ fi
174+
175+ # If not the last attempt, wait before retrying
176+ if [ " $attempt " -lt " $MAX_ATTEMPTS " ]; then
177+ delay=${RETRY_DELAYS[$((attempt - 1))]}
178+ echo " Test ${file} failed. Retrying in ${delay} s..."
179+ sleep " $delay "
180+ fi
181+ done
182+
183+ if [ " $success " = false ]; then
184+ failedTests+=(" $file " )
185+ if [[ " $testName " == * " financial-connections" * ]]; then
186+ failedFinancialConnectionsTests+=(" $file " )
87187 fi
88188 fi
189+
89190 idx=$(( idx + 1 ))
90191done
91192
92- # Output information for GitHub Actions
93- if [ ${# failedFinancialConnectionsTests[@]} -gt 0 ]; then
94- echo " FINANCIAL_CONNECTIONS_TESTS_FAILED=true" >> $GITHUB_OUTPUT
95- echo " FAILED_FC_TESTS=${failedFinancialConnectionsTests[*]} " >> $GITHUB_OUTPUT
96- echo " FINANCIAL_CONNECTIONS_TESTS_FAILED=true" > e2e-artifacts/fincon.env
97- echo " FAILED_FC_TESTS=${failedFinancialConnectionsTests[*]} " >> e2e-artifacts/fincon.env
98- else
99- echo " FINANCIAL_CONNECTIONS_TESTS_FAILED=false" >> $GITHUB_OUTPUT
100- echo " FINANCIAL_CONNECTIONS_TESTS_FAILED=false" > e2e-artifacts/fincon.env
101- fi
102-
103193if [ ${# failedTests[@]} -eq 0 ]; then
104194 exit 0
105195else
0 commit comments