Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 30 additions & 8 deletions .github/workflows/e2e_tests_smoke.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,9 @@ jobs:
permissions:
contents: read
runs-on: xcode-27
timeout-minutes: ${{ inputs.nightly_test_mode && 5 || 35 }}
# Build Application is capped at 25 (the SPM retry stays inside that step),
# Ensure Simulator Ready at 13, E2E at 85, plus setup and the failure crash dump.
timeout-minutes: ${{ inputs.nightly_test_mode && 5 || 160 }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
- uses: ./.github/actions/setup-flutterfire
Expand Down Expand Up @@ -290,18 +292,38 @@ jobs:
working-directory: ./.github/workflows/scripts
# Covers booting the emulator suite as well as the tests themselves, since
# `emulators:exec` now owns both.
timeout-minutes: 20
# ~2 min emulator boot + 20 + 1.5 log show + 20 + up to 11 recycle + 20
# ≈ 74.5 min. Longer than the reusable_e2e_ios.yaml step.
timeout-minutes: 85
env:
SIMULATOR: ${{ steps.simulator.outputs.udid }}
STORAGE_EMULATOR_DEBUG: 'true'
TEST_TARGET: integration_test/core_shard_test.dart
# Last six passing main runs: 660, 672, 684, 722, 800, 821s
# (300–554s of Xcode build still inside flutter test). 1200 > 821.
FLUTTER_TEST_ALARM_SECONDS: '1200'
FLUTTER_TEST_RETRY_ALARM_SECONDS: '1200'
FLUTTER_TEST_FINAL_ALARM_SECONDS: '1200'
run: |
# Uncomment following line to have simulator logs printed out for debugging purposes.
# xcrun simctl spawn booted log stream --predicate 'eventMessage contains "flutter"' &
# Once the integration test runner has launched, leave it running rather
# than starting a second app instance from a retry.
# `emulators:exec` boots the suite, runs the command and tears the suite
# down, exiting with the command's exit code.
firebase emulators:exec --project flutterfire-e2e-tests "cd ${GITHUB_WORKSPACE}/tests && flutter test integration_test/core_shard_test.dart -d \"$SIMULATOR\" --timeout 10x --dart-define=CI=true"
# down, exiting with the command's exit code. The retry script decides
# whether launch failures are retried and whether the tally passes.
firebase emulators:exec --project flutterfire-e2e-tests "cd ${GITHUB_WORKSPACE}/tests && ${GITHUB_WORKSPACE}/.github/workflows/scripts/flutter-test-ios-retry.sh"
- name: Dump crash reports
# The recurring "Unable to start the app on the device" launch failures
# give the Flutter tool nothing to print; simulator app crashes land in
# the host's crash reporter with the real reason. Only runs on failure.
if: failure()
run: |
found=0
while IFS= read -r report; do
found=1
echo "::group::$(basename "$report")"
head -c 20000 "$report"
echo
echo "::endgroup::"
done < <(find "$HOME/Library/Logs/DiagnosticReports" -name '*.ips' -newermt '-2 hours' 2>/dev/null)
[ "$found" -eq 1 ] || echo "No crash reports in the last two hours."
- name: Save Firestore Emulator Cache
# Branches can read main cache but main cannot read branch cache. Avoid LRU eviction with main-only cache.
if: github.ref == 'refs/heads/main'
Expand Down
140 changes: 10 additions & 130 deletions .github/workflows/reusable_e2e_ios.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,9 @@ jobs:
TEST_TARGET: ${{ inputs.test-target }}
NATIVE_CONFIG_ARGS: ${{ inputs.native-config-args }}
INFO_PLIST_OVERRIDES: ${{ inputs.info-plist-overrides }}
timeout-minutes: ${{ inputs.nightly_test_mode && 5 || 60 }}
# Build Application is capped at 25 (the SPM retry stays inside that step),
# Ensure Simulator Ready at 13, E2E at 55, plus setup and the failure crash dump.
timeout-minutes: ${{ inputs.nightly_test_mode && 5 || 130 }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
# Use the xcode-27 image default (Xcode 27 / iOS 27). Do not pin an older
Expand Down Expand Up @@ -271,145 +273,23 @@ jobs:
working-directory: ./.github/workflows/scripts
# Covers booting the emulator suite as well as the tests themselves, since
# `emulators:exec` now owns both.
# Fits one cold (15 min) and two warm (10 min) alarm-bounded test
# attempts plus one simulator recycle.
timeout-minutes: 45
# 900 + 90 + 600 + 660 + 600 = 47.5 min, plus ~2 min emulator boot.
timeout-minutes: 55
env:
SIMULATOR: ${{ steps.simulator.outputs.udid }}
STORAGE_EMULATOR_DEBUG: ${{ inputs.storage-emulator-debug && 'true' || '' }}
run: |
TEST_COMMAND=$(cat <<'EOF'
cd "${GITHUB_WORKSPACE}/${PACKAGE_PATH}/example"
# flutter test on Apple simulators may exit 1 (e.g. "Failed to
# foreground app") even when every test passed - same behaviour the
# macOS job launders. Check the actual results to decide.
run_flutter_test() {
rm -f flutter_test_output.log
# File redirect, never capture (iOS spawns log streamers that hold
# a captured pipe open forever). The alarm ($1) bounds the known
# zero-output hang well below the step timeout.
perl -e 'alarm shift; exec @ARGV' "$1" \
flutter test "$TEST_TARGET" -d "$SIMULATOR" --timeout 10x --dart-define=CI=true > flutter_test_output.log 2>&1
FT_EXIT=$?
cat flutter_test_output.log
}
attempt_failed() {
{ ! grep -Eq '[0-9]+ tests? passed' flutter_test_output.log && ! grep -Eq '[0-9]+ failed' flutter_test_output.log; } \
|| grep -q "Unable to start the app on the device" flutter_test_output.log
}
set +e
# Three bounded attempts. The zero-output hang is in the tool
# process, not the app or the device: the simulator log shows the
# app up and serving network traffic while `flutter test` waits
# forever for the VM service URI its log reader missed. Retries are
# therefore the effective lever; the first alarm covers the cold
# build, the later attempts run against a warm build cache.
run_flutter_test 900
if attempt_failed; then
echo "Launch failure - retrying (attempt 2/3)."
echo "::group::Simulator log around the hang (Runner)"
perl -e 'alarm shift; exec @ARGV' 90 \
xcrun simctl spawn "$SIMULATOR" log show --last 16m --style compact \
--predicate 'process == "Runner" OR eventMessage CONTAINS "Runner"' 2>/dev/null | tail -80 || true
echo "::endgroup::"
run_flutter_test 600
fi
if attempt_failed; then
# Last resort: recycle the simulator too, in case the device is
# the wedged part after all.
echo "Launch failure - recycling the simulator and retrying (attempt 3/3)."
xcrun simctl shutdown "$SIMULATOR" 2>/dev/null || true
xcrun simctl erase "$SIMULATOR" 2>/dev/null || true
xcrun simctl boot "$SIMULATOR" 2>/dev/null || true
"${GITHUB_WORKSPACE}/.github/workflows/scripts/ensure-simulator-ready.sh" || true
run_flutter_test 600
fi
# Trust only the runner's own tally, parsed numerically. Substring
# checks are how '0 tests passed, 1 failed' once laundered into a
# green job.
PASSED=$(grep -Eo '[0-9]+ tests? passed' flutter_test_output.log | tail -1 | grep -Eo '^[0-9]+')
FAILED=$(grep -Eo '[0-9]+ failed' flutter_test_output.log | tail -1 | grep -Eo '^[0-9]+')
: "${PASSED:=0}"; : "${FAILED:=0}"
echo "Result tally: passed=$PASSED failed=$FAILED (flutter test exit $FT_EXIT)"
if [ "$FAILED" -gt 0 ] || [ "$PASSED" -eq 0 ]; then
exit 1
fi
if [ "$FT_EXIT" -ne 0 ]; then
echo "All $PASSED tests passed; tolerating flutter test exit $FT_EXIT (simulator foreground quirk)."
fi
exit 0
EOF
)
# `emulators:exec` boots the suite, runs the command and tears the suite
# down, exiting with the command's exit code - the laundering above
# decides whether this step passes.
firebase emulators:exec --project flutterfire-e2e-tests "$TEST_COMMAND"
# down, exiting with the command's exit code.
firebase emulators:exec --project flutterfire-e2e-tests "cd ${GITHUB_WORKSPACE}/${PACKAGE_PATH}/example && ${GITHUB_WORKSPACE}/.github/workflows/scripts/flutter-test-ios-retry.sh"
- name: 'E2E Tests'
if: ${{ !inputs.use-firebase-emulators }}
working-directory: ${{ inputs.package-path }}/example
# Fits one cold (15 min) and two warm (10 min) alarm-bounded test
# attempts plus one simulator recycle.
timeout-minutes: 45
# 900 + 90 + 600 + 660 + 600 = 47.5 min.
timeout-minutes: 55
env:
SIMULATOR: ${{ steps.simulator.outputs.udid }}
run: |
# Same "exit 1 despite all tests passing" laundering as the
# emulator-tier step above and the macOS job.
run_flutter_test() {
rm -f flutter_test_output.log
# File redirect, never capture (iOS spawns log streamers that hold
# a captured pipe open forever). The alarm ($1) bounds the known
# zero-output hang well below the step timeout.
perl -e 'alarm shift; exec @ARGV' "$1" \
flutter test "$TEST_TARGET" -d "$SIMULATOR" --timeout 10x --dart-define=CI=true > flutter_test_output.log 2>&1
FT_EXIT=$?
cat flutter_test_output.log
}
attempt_failed() {
{ ! grep -Eq '[0-9]+ tests? passed' flutter_test_output.log && ! grep -Eq '[0-9]+ failed' flutter_test_output.log; } \
|| grep -q "Unable to start the app on the device" flutter_test_output.log
}
set +e
# Three bounded attempts. The zero-output hang is in the tool
# process, not the app or the device: the simulator log shows the
# app up and serving network traffic while `flutter test` waits
# forever for the VM service URI its log reader missed. Retries are
# therefore the effective lever; the first alarm covers the cold
# build, the later attempts run against a warm build cache.
run_flutter_test 900
if attempt_failed; then
echo "Launch failure - retrying (attempt 2/3)."
echo "::group::Simulator log around the hang (Runner)"
perl -e 'alarm shift; exec @ARGV' 90 \
xcrun simctl spawn "$SIMULATOR" log show --last 16m --style compact \
--predicate 'process == "Runner" OR eventMessage CONTAINS "Runner"' 2>/dev/null | tail -80 || true
echo "::endgroup::"
run_flutter_test 600
fi
if attempt_failed; then
# Last resort: recycle the simulator too, in case the device is
# the wedged part after all.
echo "Launch failure - recycling the simulator and retrying (attempt 3/3)."
xcrun simctl shutdown "$SIMULATOR" 2>/dev/null || true
xcrun simctl erase "$SIMULATOR" 2>/dev/null || true
xcrun simctl boot "$SIMULATOR" 2>/dev/null || true
"${GITHUB_WORKSPACE}/.github/workflows/scripts/ensure-simulator-ready.sh" || true
run_flutter_test 600
fi
# Trust only the runner's own tally, parsed numerically. Substring
# checks are how '0 tests passed, 1 failed' once laundered into a
# green job.
PASSED=$(grep -Eo '[0-9]+ tests? passed' flutter_test_output.log | tail -1 | grep -Eo '^[0-9]+')
FAILED=$(grep -Eo '[0-9]+ failed' flutter_test_output.log | tail -1 | grep -Eo '^[0-9]+')
: "${PASSED:=0}"; : "${FAILED:=0}"
echo "Result tally: passed=$PASSED failed=$FAILED (flutter test exit $FT_EXIT)"
if [ "$FAILED" -gt 0 ] || [ "$PASSED" -eq 0 ]; then
exit 1
fi
if [ "$FT_EXIT" -ne 0 ]; then
echo "All $PASSED tests passed; tolerating flutter test exit $FT_EXIT (simulator foreground quirk)."
fi
exit 0
run: ${GITHUB_WORKSPACE}/.github/workflows/scripts/flutter-test-ios-retry.sh
- name: Dump crash reports
# The recurring "Unable to start the app on the device" launch failures
# give the Flutter tool nothing to print; simulator app crashes land in
Expand Down
98 changes: 98 additions & 0 deletions .github/workflows/scripts/flutter-test-ios-retry.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
#!/usr/bin/env bash
# iOS twin of flutter-test-android-retry.sh. Shared by the smoke iOS job and
# reusable_e2e_ios.yaml. `flutter test` against an Apple simulator can fail
# before any test runs ("Unable to start the app on the device", empty
# xcodebuild settings, or a zero-output hang). Bound each attempt with an
# alarm, retry only that pre-start failure, recycle the simulator on the last
# try, and trust only the runner's numeric tally for the verdict.
#
# Alarm defaults are the per-package timings. Override
# FLUTTER_TEST_ALARM_SECONDS, FLUTTER_TEST_RETRY_ALARM_SECONDS, and
# FLUTTER_TEST_FINAL_ALARM_SECONDS for a slower suite.
set -euo pipefail

: "${TEST_TARGET:?TEST_TARGET is required}"
: "${SIMULATOR:?SIMULATOR is required}"
: "${FLUTTER_TEST_ALARM_SECONDS:=900}"
: "${FLUTTER_TEST_RETRY_ALARM_SECONDS:=600}"
: "${FLUTTER_TEST_FINAL_ALARM_SECONDS:=600}"

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

run_flutter_test() {
rm -f flutter_test_output.log
# File redirect, never capture: iOS spawns log streamers that hold a
# captured pipe open forever. The alarm ($1) bounds the known zero-output
# hang well below the step timeout.
perl -e 'alarm shift; exec @ARGV' "$1" \
flutter test "$TEST_TARGET" -d "$SIMULATOR" --timeout 10x --dart-define=CI=true \
> flutter_test_output.log 2>&1
FT_EXIT=$?
cat flutter_test_output.log
}

# "✅ <test>" means a test finished (run 46515339312); "❌ loading <file> (failed)" does not (run 45442661602).
test_has_started() {
if grep -Eq '^✅ ' flutter_test_output.log; then
return 0
fi
if grep -E '❌ .+ \(failed\)' flutter_test_output.log \
| grep -v -E '❌ loading .+ \(failed\)' \
| grep -q .; then
return 0
fi
return 1
}

attempt_failed() {
Comment thread
SelaseKay marked this conversation as resolved.
Resolved
if test_has_started; then
return 1
fi
if grep -q "Unable to start the app on the device" flutter_test_output.log \
|| grep -q "No Xcode build settings have been found" flutter_test_output.log; then
return 0
fi
if ! grep -Eq '[0-9]+ tests? passed' flutter_test_output.log \
&& ! grep -Eq '[0-9]+ failed' flutter_test_output.log; then
return 0
fi
attempt_passed=$(grep -Eo '[0-9]+ tests? passed' flutter_test_output.log | tail -1 | grep -Eo '^[0-9]+' || true)
if [ "${attempt_passed:-0}" -eq 0 ]; then
return 0
fi
return 1
}

set +e
run_flutter_test "$FLUTTER_TEST_ALARM_SECONDS"
if attempt_failed; then
echo "Launch failure - retrying (attempt 2/3)."
echo "::group::Simulator log around the hang (Runner)"
perl -e 'alarm shift; exec @ARGV' 90 \
xcrun simctl spawn "$SIMULATOR" log show --last 16m --style compact \
--predicate 'process == "Runner" OR eventMessage CONTAINS "Runner"' 2>/dev/null | tail -80 || true
echo "::endgroup::"
run_flutter_test "$FLUTTER_TEST_RETRY_ALARM_SECONDS"
fi
if attempt_failed; then
echo "Launch failure - recycling the simulator and retrying (attempt 3/3)."
xcrun simctl shutdown "$SIMULATOR" 2>/dev/null || true
xcrun simctl erase "$SIMULATOR" 2>/dev/null || true
xcrun simctl boot "$SIMULATOR" 2>/dev/null || true
"${SCRIPT_DIR}/ensure-simulator-ready.sh" || true
run_flutter_test "$FLUTTER_TEST_FINAL_ALARM_SECONDS"
fi

# Trust only the runner's own tally, parsed numerically. Substring checks are
# how '0 tests passed, 1 failed' once laundered into a green job.
PASSED=$(grep -Eo '[0-9]+ tests? passed' flutter_test_output.log | tail -1 | grep -Eo '^[0-9]+')
FAILED=$(grep -Eo '[0-9]+ failed' flutter_test_output.log | tail -1 | grep -Eo '^[0-9]+')
: "${PASSED:=0}"; : "${FAILED:=0}"
echo "Result tally: passed=$PASSED failed=$FAILED (flutter test exit $FT_EXIT)"
if [ "$FAILED" -gt 0 ] || [ "$PASSED" -eq 0 ]; then
exit 1
fi
if [ "$FT_EXIT" -ne 0 ]; then
echo "All $PASSED tests passed; tolerating flutter test exit $FT_EXIT (simulator foreground quirk)."
fi
exit 0
Loading