Skip to content

Commit 18a99fd

Browse files
authored
fix: Flaky iOS smoke tests (#1969)
1 parent d18a6f2 commit 18a99fd

File tree

2 files changed

+32
-33
lines changed

2 files changed

+32
-33
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,7 @@ jobs:
514514

515515
- name: iOS smoke test
516516
if: ${{ matrix.platform == 'iOS' }}
517-
run: ./scripts/smoke-test-ios.ps1 Build -IsIntegrationTest -UnityVersion "${{ matrix.unity-version }}"
517+
run: ./scripts/smoke-test-ios.ps1 Build -IsIntegrationTest -UnityVersion "${{ matrix.unity-version }}" -iOSMinVersion "16.1"
518518
timeout-minutes: 10
519519

520520
- name: Upload integration-test project on failure
@@ -579,7 +579,7 @@ jobs:
579579

580580
- name: Smoke test
581581
id: smoke-test-ios
582-
timeout-minutes: 10
582+
timeout-minutes: 20
583583
run: |
584584
$runtime = "${{ matrix.ios }}"
585585
If ($runtime -ne "latest")

scripts/smoke-test-ios.ps1

Lines changed: 30 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ param (
33
[string] $SelectedRuntime,
44
[Int32] $DevicesToRun = 1,
55
[Switch] $IsIntegrationTest,
6-
[string] $UnityVersion = ""
6+
[string] $UnityVersion = "",
7+
[string] $iOSMinVersion = ""
78
)
89
Write-Host "Args received Action=$Action, SelectedRuntime=$SelectedRuntime, IsIntegrationTest=$IsIntegrationTest"
910
# $Action: 'Build' for build only
@@ -60,6 +61,9 @@ function Build()
6061
-scheme "Unity-iPhone" `
6162
-configuration "Release" `
6263
-sdk "iphonesimulator" `
64+
-destination "platform=iOS Simulator,OS=$iOSMinVersion" `
65+
-destination "platform=iOS Simulator,OS=latest" `
66+
-parallel-testing-enabled YES `
6367
-derivedDataPath "$ArchivePath/$ProjectName" `
6468
| Write-Host
6569
}
@@ -84,9 +88,10 @@ function Test
8488
{
8589
Write-Host "Retrieving list of available simulators" -ForegroundColor Green
8690
$deviceListRaw = xcrun simctl list devices
87-
Write-Host "Available simulators:" -ForegroundColor Green
91+
Write-Host "::group::Available simulators:"
8892
$deviceListRaw | Write-Host
89-
93+
Write-Host "::endgroup::"
94+
9095
[AppleDevice[]]$deviceList = @()
9196

9297
Write-Host "Picking simulator based on selected runtime" -ForegroundColor Green
@@ -142,39 +147,33 @@ function Test
142147

143148
function RunTest([string] $Name, [string] $SuccessString)
144149
{
145-
Write-Host "::group::Test: '$name'"
146-
try
147-
{
148-
Write-Host "Launching '$Name' test on '$($device.Name)'" -ForegroundColor Green
149-
$consoleOut = xcrun simctl launch --console-pty $($device.UUID) $AppName "--test" $Name
150+
Write-Host "Test: '$name'"
151+
Write-Host "Launching '$Name' test on '$($device.Name)'" -ForegroundColor Green
152+
$consoleOut = xcrun simctl launch --console-pty $($device.UUID) $AppName "--test" $Name
150153

151-
if ("$SuccessString" -eq "")
152-
{
153-
$SuccessString = "$($Name.ToUpper()) TEST: PASS"
154-
}
154+
if ("$SuccessString" -eq "")
155+
{
156+
$SuccessString = "$($Name.ToUpper()) TEST: PASS"
157+
}
155158

156-
Write-Host -NoNewline "'$Name' test STATUS: "
157-
$stdout = $consoleOut | Select-String $SuccessString
158-
If ($null -ne $stdout)
159-
{
160-
Write-Host "PASSED" -ForegroundColor Green
161-
}
162-
Else
163-
{
164-
$device.TestFailed = $True
165-
Write-Host "FAILED" -ForegroundColor Red
166-
Write-Host "===== START OF '$($device.Name)' CONSOLE ====="
167-
foreach ($consoleLine in $consoleOut)
168-
{
169-
Write-Host $consoleLine
170-
}
171-
Write-Host " ===== END OF CONSOLE ====="
172-
}
159+
Write-Host -NoNewline "'$Name' test STATUS: "
160+
$stdout = $consoleOut | Select-String $SuccessString
161+
If ($null -ne $stdout)
162+
{
163+
Write-Host "PASSED" -ForegroundColor Green
173164
}
174-
finally
165+
Else
175166
{
176-
Write-Host "::endgroup::"
167+
$device.TestFailed = $True
168+
Write-Host "FAILED" -ForegroundColor Red
177169
}
170+
171+
Write-Host "::group::$($device.Name) Console Output"
172+
foreach ($consoleLine in $consoleOut)
173+
{
174+
Write-Host $consoleLine
175+
}
176+
Write-Host "::endgroup::"
178177
}
179178

180179
RunTest "smoke"

0 commit comments

Comments
 (0)