Skip to content

Commit 7315264

Browse files
fix: test retry
1 parent 8cc1d58 commit 7315264

2 files changed

Lines changed: 46 additions & 7 deletions

File tree

.maestro/enrichedInput/flows/scrolling_with_paragraph_styles.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,10 @@ appId: swmansion.enriched.example
9898
id: 'editor-input'
9999
point: '0%,0%'
100100

101-
- scroll
101+
- swipe:
102+
from:
103+
id: 'editor-input'
104+
direction: UP
102105

103106
- waitForAnimationToEnd
104107

.maestro/scripts/run-tests.sh

Lines changed: 42 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@
2121
# Android → --driver devicelab
2222
# iOS → default driver
2323
#
24-
# Failed test runs are retried in CI only (iOS and Android). Override with
25-
# MAESTRO_MAX_RETRIES (default: 1 locally, 2 in CI). DeviceLab driver startup
26-
# crashes on CI Android get extra cleanup between attempts.
24+
# In CI, failed flows are retried individually (not the whole suite). Override
25+
# with MAESTRO_MAX_RETRIES (default: 1 locally, 2 in CI). DeviceLab driver
26+
# startup crashes on CI Android get extra cleanup between attempts.
2727

2828
set -euo pipefail
2929

@@ -167,7 +167,29 @@ cleanup_devicelab_driver() {
167167
sleep 8
168168
}
169169

170-
run_maestro() {
170+
collect_flow_files() {
171+
local item
172+
for item in $FLOWS; do
173+
[ "$item" = "$ASSETS_DIR" ] && continue
174+
if [ -d "$item" ]; then
175+
find "$item" -name '*.yaml' | sort
176+
elif [ -f "$item" ]; then
177+
echo "$item"
178+
fi
179+
done
180+
}
181+
182+
maestro_test_paths() {
183+
local flow="$1"
184+
local paths=""
185+
[ -d "$ASSETS_DIR" ] && paths="$ASSETS_DIR "
186+
paths+="$flow"
187+
echo "$paths"
188+
}
189+
190+
run_maestro_with_targets() {
191+
local test_targets="$1"
192+
shift
171193
local max_attempts rc tmp attempt=1 delayed_retry=0
172194
if [ -n "${MAESTRO_MAX_RETRIES:-}" ]; then
173195
max_attempts="$MAESTRO_MAX_RETRIES"
@@ -184,11 +206,11 @@ run_maestro() {
184206
# Global flags (--device, --driver, --env, tags) come before `test`.
185207
if [[ "$OSTYPE" == darwin* ]]; then
186208
# shellcheck disable=SC2086
187-
script -q /dev/null "$MAESTRO_BIN" --platform "$PLATFORM" --device "$DEVICE_ID" $DRIVER_ARGS $EXTRA "$@" test $FLOWS 2>&1 | tee "$tmp"
209+
script -q /dev/null "$MAESTRO_BIN" --platform "$PLATFORM" --device "$DEVICE_ID" $DRIVER_ARGS $EXTRA "$@" test $test_targets 2>&1 | tee "$tmp"
188210
else
189211
local cmd
190212
# shellcheck disable=SC2086
191-
cmd=$(printf '%q ' "$MAESTRO_BIN" --platform "$PLATFORM" --device "$DEVICE_ID" $DRIVER_ARGS $EXTRA "$@" test $FLOWS)
213+
cmd=$(printf '%q ' "$MAESTRO_BIN" --platform "$PLATFORM" --device "$DEVICE_ID" $DRIVER_ARGS $EXTRA "$@" test $test_targets)
192214
script -qec "$cmd" /dev/null 2>&1 | tee "$tmp"
193215
fi
194216
rc=${PIPESTATUS[0]}
@@ -236,6 +258,20 @@ run_maestro() {
236258
done
237259
}
238260

261+
run_maestro() {
262+
if is_ci; then
263+
local flow failed=0
264+
while IFS= read -r flow; do
265+
[ -z "$flow" ] && continue
266+
echo "=== Running flow: $flow ==="
267+
run_maestro_with_targets "$(maestro_test_paths "$flow")" "$@" || failed=1
268+
done < <(collect_flow_files)
269+
return "$failed"
270+
fi
271+
272+
run_maestro_with_targets "$FLOWS" "$@"
273+
}
274+
239275
set +e
240276

241277
echo "=== Running maestro tests ==="

0 commit comments

Comments
 (0)