Skip to content

Commit

Permalink
Merge pull request #16962 from unoplatform/dev/jela/ios-net8-test
Browse files Browse the repository at this point in the history
Move to macOS14, Xcode 15.4, iOS tests net8.0-ios17.0
  • Loading branch information
jeromelaban authored Jun 8, 2024
2 parents 3846ac8 + c11134b commit 95ae2db
Show file tree
Hide file tree
Showing 19 changed files with 158 additions and 105 deletions.
10 changes: 4 additions & 6 deletions .vsts-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,10 @@ variables:
windowsScaledPool: 'Windows2022-20240421'
linuxVMImage: 'ubuntu-latest'
linuxScaledPool: 'Ubuntu2204-20230918'
macOSVMImage: 'macOS-13'
macOSVMImage_UITests: 'macOS-12'
xCodeRoot: '/Applications/Xcode_15.2.app'
XamarinSDKVersion: 6_12_24
xCodeRoot_iOS_UITests: '/Applications/Xcode_14.1.app'
XamarinSDKVersion_iOS_UITests: 6_12_24
macOSVMImage: 'macOS-14'
macOSVMImage_UITests: 'macOS-14'
xCodeRoot: '/Applications/Xcode_15.4.app'
xCodeRoot_iOS_UITests: '/Applications/Xcode_15.4.app'

# Offline validation to improve build performance
NUGET_CERT_REVOCATION_MODE: offline
Expand Down
1 change: 0 additions & 1 deletion build/ci/.azure-devops-android-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ parameters:
vmLinuxImage: ''
vmLinuxPool: ''
xCodeRoot: ''
XamarinSDKVersion: ''

automatedTestsBuckets:
- 1
Expand Down
7 changes: 4 additions & 3 deletions build/ci/.azure-devops-ios-tests-run.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
parameters:
vmImage: ''
xCodeRoot: ''
XamarinSDKVersion: ''
JobName: ''
JobTimeoutInMinutes: ''
JobDisplayName: ''
Expand All @@ -27,6 +26,9 @@ jobs:
NUGET_PACKAGES: $(Pipeline.Workspace)/.nuget/packages
UITEST_ALLOW_RERUN: ${{ parameters.UITEST_ALLOW_RERUN }}

# Only build for NetPrevious
UnoDisableNetCurrentMobile: true
UnoDisableNetCurrent: true

UNO_UITEST_BUCKET_COUNT: 5

Expand All @@ -48,7 +50,7 @@ jobs:
artifactName: uitests-failure-results
downloadPath: '$(build.sourcesdirectory)/build'

- template: templates/dotnet7-mobile-install-mac.yml
- template: templates/dotnet-install.yml

- template: templates/nuget-cache.yml
parameters:
Expand All @@ -57,7 +59,6 @@ jobs:
- template: templates/ios-build-select-version.yml
parameters:
xCodeRoot: ${{ parameters.xCodeRoot }}
XamarinSDKVersion: ${{ parameters.XamarinSDKVersion }}

- bash: |
rm -f ${HOME}/Library/Preferences/Xamarin/Settings.plist
Expand Down
20 changes: 6 additions & 14 deletions build/ci/.azure-devops-ios-tests.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
parameters:
vmImage: ''
xCodeRootTest: ''
XamarinSDKVersionTest: ''
xCodeRootBuild: ''
XamarinSDKVersionBuild: ''

# Align with SnapShotTestGenerator.GroupCount
SNAPSHOT_GROUPS:
Expand Down Expand Up @@ -73,12 +71,11 @@ jobs:
parameters:
nugetPackages: $(NUGET_PACKAGES)

- template: templates/dotnet7-mobile-install-mac.yml
- template: templates/dotnet-mobile-install-mac.yml

- template: templates/ios-build-select-version.yml
parameters:
xCodeRoot: ${{ parameters.xCodeRootBuild }}
XamarinSDKVersion: ${{ parameters.XamarinSDKVersionBuild }}

- template: templates/gitversion.yml

Expand All @@ -93,7 +90,7 @@ jobs:
- task: CopyFiles@2
inputs:
SourceFolder: $(build.sourcesdirectory)/src/SamplesApp/SamplesApp.netcoremobile/bin/Release/net7.0-ios/iossimulator-x64/SamplesApp.app
SourceFolder: $(build.sourcesdirectory)/src/SamplesApp/SamplesApp.netcoremobile/bin/Release/net8.0-ios17.0/iossimulator-x64/SamplesApp.app
Contents: '**'
TargetFolder: $(build.artifactstagingdirectory)/SamplesApp.app
CleanTargetFolder: false
Expand Down Expand Up @@ -151,23 +148,22 @@ jobs:
parameters:
nugetPackages: $(NUGET_PACKAGES)

- template: templates/dotnet7-mobile-install-mac.yml
- template: templates/dotnet-mobile-install-mac.yml

- template: templates/ios-build-select-version.yml
parameters:
xCodeRoot: ${{ parameters.xCodeRootBuild }}
XamarinSDKVersion: ${{ parameters.XamarinSDKVersionBuild }}

- template: templates/gitversion.yml

- bash: |
cd $(BUILD.SOURCESDIRECTORY)/src/SamplesApp/SamplesApp.netcoremobile
dotnet publish \
-f net7.0-ios \
-f net8.0-ios17.0 \
-c Release \
-r:ios-arm64 \
-p:BuildForTestFlight=true \
-p:UnoTargetFrameworkOverride=net7.0-ios \
-p:UnoTargetFrameworkOverride=net8.0-ios17.0 \
/bl:$(build.artifactstagingdirectory)/ios-netcoremobile-sampleapp-testflight.binlog
displayName: Build iOS App for TestFlight
Expand All @@ -179,7 +175,7 @@ jobs:
- task: CopyFiles@2
inputs:
SourceFolder: $(build.sourcesdirectory)/src/SamplesApp/SamplesApp.netcoremobile/bin/Release/net7.0-ios/ios-arm64/publish
SourceFolder: $(build.sourcesdirectory)/src/SamplesApp/SamplesApp.netcoremobile/bin/Release/net8.0-ios17.0/ios-arm64/publish
Contents: '**'
TargetFolder: $(build.artifactstagingdirectory)/TestFlight
CleanTargetFolder: false
Expand Down Expand Up @@ -210,7 +206,6 @@ jobs:
UITEST_TEST_TIMEOUT: '20m'
UITEST_ALLOW_RERUN: 'true'
xCodeRoot: ${{ parameters.xCodeRootTest }}
XamarinSDKVersion: ${{ parameters.XamarinSDKVersionTest }}

##
## Runtime tests
Expand All @@ -230,7 +225,6 @@ jobs:
UITEST_RUNTIME_TEST_GROUP_COUNT: ${{ parameters.UITEST_RUNTIME_TEST_GROUP_COUNT }}
UITEST_ALLOW_RERUN: 'false'
xCodeRoot: ${{ parameters.xCodeRootTest }}
XamarinSDKVersion: ${{ parameters.XamarinSDKVersionTest }}

# Disabled for benchmkarks timeout
# - template: .azure-devops-ios-tests-run.yml
Expand All @@ -243,7 +237,6 @@ jobs:
# UITEST_SNAPSHOTS_ONLY: false
# UITEST_AUTOMATED_GROUP: Benchmarks
# xCodeRoot: ${{ parameters.xCodeRootTest }}
# XamarinSDKVersion: ${{ parameters.XamarinSDKVersionTest }}

- ${{ each snapshotGroup in parameters.SNAPSHOT_GROUPS }}:
- template: .azure-devops-ios-tests-run.yml
Expand All @@ -258,4 +251,3 @@ jobs:
UITEST_TEST_TIMEOUT: '10m'
UITEST_ALLOW_RERUN: 'false'
xCodeRoot: ${{ parameters.xCodeRootTest }}
XamarinSDKVersion: ${{ parameters.XamarinSDKVersionTest }}
2 changes: 0 additions & 2 deletions build/ci/.azure-devops-macos.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
parameters:
vmImage: ''
xCodeRoot: ''
XamarinSDKVersion: ''

jobs:

Expand Down Expand Up @@ -33,7 +32,6 @@ jobs:
- template: templates/ios-build-select-version.yml
parameters:
xCodeRoot: ${{ parameters.xCodeRoot }}
XamarinSDKVersion: ${{ parameters.XamarinSDKVersion }}

- script: |
cd src/SamplesApp/SamplesApp.netcoremobile
Expand Down
1 change: 0 additions & 1 deletion build/ci/.azure-devops-project-template-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ jobs:
- template: templates/ios-build-select-version.yml
parameters:
xCodeRoot: ${{ parameters.xCodeRoot }}
XamarinSDKVersion: ${{ parameters.XamarinSDKVersion }}

- template: templates/dotnet-mobile-install-mac.yml

Expand Down
5 changes: 0 additions & 5 deletions build/ci/.azure-devops-stages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ stages:
vmPoolLinux: '$(linuxScaledPool)'
macOSImageName: '$(macOSVMImage)'
xCodeRoot: '$(xCodeRoot)'
XamarinSDKVersion: '$(XamarinSDKVersion)'

- stage: unit_tests
displayName: Tests - Unit
Expand Down Expand Up @@ -176,7 +175,6 @@ stages:
parameters:
vmImage: '$(macOSVMImage)'
xCodeRoot: '$(xCodeRoot)'
XamarinSDKVersion: '$(XamarinSDKVersion)'

- stage: android_tests
displayName: Tests - Android
Expand All @@ -191,7 +189,6 @@ stages:
vmMacOSImage: '$(macOSVMImage)'
vmLinuxPool: '$(linuxScaledPool)'
xCodeRoot: '$(xCodeRoot)'
XamarinSDKVersion: '$(XamarinSDKVersion)'

- stage: ios_tests
displayName: Tests - iOS
Expand All @@ -204,9 +201,7 @@ stages:
vmImage: '$(macOSVMImage)'
vmImageTest: '$(macOSVMImage_UITests)'
xCodeRootBuild: '$(xCodeRoot)'
XamarinSDKVersionBuild: '$(XamarinSDKVersion)'
xCodeRootTest: '$(xCodeRoot_iOS_UITests)'
XamarinSDKVersionTest: '$(XamarinSDKVersion_iOS_UITests)'

- stage: wasdk_tests
displayName: Tests - WinAppSDK
Expand Down
1 change: 0 additions & 1 deletion build/ci/templates/ios-build-select-version.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
parameters:
xCodeRoot: ''
XamarinSDKVersion: ''

steps:
- bash: |
Expand Down
2 changes: 1 addition & 1 deletion build/test-scripts/ios-uitest-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ IFS=$'\n\t'

cd $BUILD_SOURCESDIRECTORY/src/SamplesApp/SamplesApp.netcoremobile

dotnet build -f net7.0-ios -r iossimulator-x64 -c Release -p:UnoTargetFrameworkOverride=net7.0-ios /bl:$BUILD_ARTIFACTSTAGINGDIRECTORY/ios-netcoremobile-sampleapp.binlog
dotnet build -f net8.0-ios17.0 -r iossimulator-x64 -c Release -p:UnoTargetFrameworkOverride=net8.0-ios17.0 /bl:$BUILD_ARTIFACTSTAGINGDIRECTORY/ios-netcoremobile-sampleapp.binlog
33 changes: 24 additions & 9 deletions build/test-scripts/ios-uitest-run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,9 @@ export UNO_UITEST_BENCHMARKS_PATH=$BUILD_ARTIFACTSTAGINGDIRECTORY/benchmarks/ios
export UNO_UITEST_RUNTIMETESTS_RESULTS_FILE_PATH=$BUILD_SOURCESDIRECTORY/build/RuntimeTestResults-ios-automated.xml

export UNO_UITEST_SIMULATOR_VERSION="com.apple.CoreSimulator.SimRuntime.iOS-16-1"
export UNO_UITEST_SIMULATOR_NAME="iPad Pro (12.9-inch) (5th generation)"
export UNO_UITEST_SIMULATOR_NAME="iPad Pro (12.9-inch) (6th generation)"

export UnoTargetFrameworkOverride="net7.0-ios"
export UnoTargetFrameworkOverride="net8.0-ios17.0"

UITEST_IGNORE_RERUN_FILE="${UITEST_IGNORE_RERUN_FILE:=false}"

Expand All @@ -109,16 +109,27 @@ fi
echo "Current system date"
date

## Install iOS 16.4 simulators
xcodes runtimes install --keep-archive 'iOS 16.1' || true

# Wait while ios runtime 16.1 is not having simulators. The install process may
# take a few seconds and "simctl list devices" may not return devices.
while true; do
export UITEST_IOSDEVICE_ID=`xcrun simctl list -j | jq -r --arg sim "$UNO_UITEST_SIMULATOR_VERSION" --arg name "$UNO_UITEST_SIMULATOR_NAME" '.devices[$sim] | .[] | select(.name==$name) | .udid'`
export UITEST_IOSDEVICE_DATA_PATH=`xcrun simctl list -j | jq -r --arg sim "$UNO_UITEST_SIMULATOR_VERSION" --arg name "$UNO_UITEST_SIMULATOR_NAME" '.devices[$sim] | .[] | select(.name==$name) | .dataPath'`

if [ -n "$UITEST_IOSDEVICE_ID" ]; then
break
fi

echo "Waiting for the simulator to be available"
sleep 5
done

export DEVICELIST_FILEPATH=$LOG_FILEPATH/DeviceList-$LOG_PREFIX.json
echo "Listing iOS simulators to $DEVICELIST_FILEPATH"
xcrun simctl list devices --json > $DEVICELIST_FILEPATH

##
## Pre-install the application to avoid https://github.com/microsoft/appcenter/issues/2389
##
export UITEST_IOSDEVICE_ID=`xcrun simctl list -j | jq -r --arg sim "$UNO_UITEST_SIMULATOR_VERSION" --arg name "$UNO_UITEST_SIMULATOR_NAME" '.devices[$sim] | .[] | select(.name==$name) | .udid'`
export UITEST_IOSDEVICE_DATA_PATH=`xcrun simctl list -j | jq -r --arg sim "$UNO_UITEST_SIMULATOR_VERSION" --arg name "$UNO_UITEST_SIMULATOR_NAME" '.devices[$sim] | .[] | select(.name==$name) | .dataPath'`

# check for the presence of idb, and install it if it's not present
export PATH=$PATH:~/.local/bin

Expand All @@ -134,6 +145,9 @@ else
echo "Using idb from:" `command -v idb`
fi

##
## Pre-install the application to avoid https://github.com/microsoft/appcenter/issues/2389
##
echo "Starting simulator: [$UITEST_IOSDEVICE_ID] ($UNO_UITEST_SIMULATOR_VERSION / $UNO_UITEST_SIMULATOR_NAME)"
xcrun simctl boot "$UITEST_IOSDEVICE_ID" || true

Expand Down Expand Up @@ -226,6 +240,7 @@ else
-c Release \
-l:"console;verbosity=normal" \
--logger "nunit;LogFileName=$UNO_ORIGINAL_TEST_RESULTS" \
--logger "console;verbosity=detailed" \
--filter "$UNO_TESTS_FILTER" \
--blame-hang-timeout $UITEST_TEST_TIMEOUT \
-v m \
Expand All @@ -248,7 +263,7 @@ xcrun simctl io "$UITEST_IOSDEVICE_ID" screenshot $LOG_FILEPATH/capture-$LOG_PRE
## Capture the device logs
xcrun simctl spawn booted log collect --output $TMP_LOG_FILEPATH

echo "Dumping device logs"
echo "Dumping device logs to $LOG_FILEPATH_FULL"
log show --style syslog $TMP_LOG_FILEPATH > $LOG_FILEPATH_FULL

echo "Searching for failures in device logs"
Expand Down
2 changes: 1 addition & 1 deletion src/Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
<PackageReference Update="Uno.Fonts.Fluent" version="2.3.1" />
<PackageReference Update="Uno.Resizetizer" Version="1.2.0-dev.72" />
<PackageReference Update="Xamarin.DuoSdk" Version="0.0.3.4" />
<PackageReference Update="Xamarin.UITest" Version="4.3.4" />
<PackageReference Update="Xamarin.UITest" Version="4.3.5" />
<PackageReference Update="Xamarin.TestCloud.Agent" Version="0.23.2" />
<PackageReference Update="System.Numerics.Vectors" Version="4.5.0" />

Expand Down
3 changes: 0 additions & 3 deletions src/SamplesApp/SamplesApp.Shared/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,6 @@ override void OnLaunched(LaunchActivatedEventArgs e)
SetupAndroidEnvironment();

#if __IOS__ && !__MACCATALYST__ && !TESTFLIGHT
// requires Xamarin Test Cloud Agent
Xamarin.Calabash.Start();

LaunchiOSWatchDog();
#endif
var activationKind =
Expand Down
2 changes: 1 addition & 1 deletion src/SamplesApp/SamplesApp.UITests/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace SamplesApp.UITests
public partial class Constants
{
public const string WebAssemblyDefaultUri = "https://localhost:44375/";
public const string iOSAppName = "uno.platform.uitestsample";
public const string iOSAppName = "uno.platform.samplesdev";
public const string AndroidAppName = "uno.platform.unosampleapp";
public const string iOSDeviceNameOrId = "iPad Pro (12.9-inch) (5th generation)";

Expand Down
30 changes: 19 additions & 11 deletions src/SamplesApp/SamplesApp.UITests/SampleControlUITestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,21 +64,29 @@ static SampleControlUITestBase()

try
{
// Start the app only once, so the tests runs don't restart it
// and gain some time for the tests.
var coldStartTask = Task.Run(() => AppInitializer.ColdStartApp());
if (AppInitializer.GetLocalPlatform() == Platform.iOS)
{
AppInitializer.ColdStartApp();
}
else
{
// Start the app only once, so the tests runs don't restart it
// and gain some time for the tests.
var coldStartTask = Task.Run(() => AppInitializer.ColdStartApp());

// Force an explicit timeout to avoid excessive waiting on iOS
var timeout = TimeSpan.FromMinutes(5);
var timeoutTask = Task.Delay(timeout);
// Force an explicit timeout to avoid excessive waiting on iOS
var timeout = TimeSpan.FromMinutes(5);
var timeoutTask = Task.Delay(timeout);

var allTasks = Task.WhenAny(coldStartTask, timeoutTask);
allTasks.Wait();
var allTasks = Task.WhenAny(coldStartTask, timeoutTask);
allTasks.Wait();

if (allTasks.Result == timeoutTask)
{
throw new Exception("Cold start timeout after timeout");
if (allTasks.Result == timeoutTask)
{
throw new Exception($"Cold start timeout after {timeout}");
}
}

}
catch
{
Expand Down
6 changes: 6 additions & 0 deletions src/SamplesApp/SamplesApp.netcoremobile/iOS/Main.iOS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ public class Application
// This is the main entry point of the application.
static void Main(string[] args)
{
#if __IOS__ && !__MACCATALYST__ && !TESTFLIGHT
// requires Xamarin Test Cloud Agent
Xamarin.Calabash.Start();
#endif


// if you want to use a different Application Delegate class from "AppDelegate"
// you can specify it here.
UIApplication.Main(args, null, typeof(App));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,7 @@ private async Task FocusTextBoxWithSoftKeyboard(TextBox textBox)
var inputPane = InputPane.GetForCurrentView();
void OnShowing(InputPane sender, InputPaneVisibilityEventArgs args)
{
tcs.SetResult(true);
tcs.TrySetResult(true);
}
try
{
Expand Down
Loading

0 comments on commit 95ae2db

Please sign in to comment.