Repository navigation
ci: retry iOS smoke e2e launch failures #19012
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
SelaseKay
wants to merge
4
commits into
main
Choose a base branch
from
invertase/e2e-smoke-ios-retry-009d
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
2f27956
ci: retry iOS smoke e2e launch failures
SelaseKay 6ea5234
Merge branch 'main' into invertase/e2e-smoke-ios-retry-009d
SelaseKay 810d23b
ci: size iOS smoke retries for the smoke job and share the wrapper
SelaseKay d5763af
ci: correct the iOS job timeout budget comment
SelaseKay File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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() { | ||
| 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 | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.