From df28d8e695c3db6262e07decab26bce4ac668393 Mon Sep 17 00:00:00 2001 From: Jonathan Pobst Date: Mon, 27 Feb 2023 13:50:04 -1000 Subject: [PATCH 1/7] [ci] Reduce overhead for MSBuildIntegration unit test jobs. --- .../automation/yaml-templates/stage-msbuild-emulator-tests.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build-tools/automation/yaml-templates/stage-msbuild-emulator-tests.yaml b/build-tools/automation/yaml-templates/stage-msbuild-emulator-tests.yaml index 2438d9af305..f7b113cceae 100644 --- a/build-tools/automation/yaml-templates/stage-msbuild-emulator-tests.yaml +++ b/build-tools/automation/yaml-templates/stage-msbuild-emulator-tests.yaml @@ -46,7 +46,7 @@ stages: - pwsh: | dotnet-test-slicer ` --test-assembly="$(System.DefaultWorkingDirectory)/bin/Test$(XA.Build.Configuration)/MSBuildDeviceIntegration/${{ parameters.target_framework }}/MSBuildDeviceIntegration.dll" ` - --test-filter="cat != TimeZoneInfo & cat != Localization ${{ parameters.nunit_categories }}" ` + --test-filter="cat != TimeZoneInfo & cat != Localization & cat != SmokeTests ${{ parameters.nunit_categories }}" ` --slice-number=$(System.JobPositionInPhase) ` --total-slices=$(System.TotalJobsInPhase) ` --outfile="$(System.DefaultWorkingDirectory)/bin/Test$(XA.Build.Configuration)/MSBuildDeviceIntegration/${{ parameters.target_framework }}/MSBuildDeviceIntegration.runsettings" From b83a68018978b16be5e63d60c6043e2211ffdb39 Mon Sep 17 00:00:00 2001 From: Jonathan Pobst Date: Tue, 28 Feb 2023 08:46:20 -1000 Subject: [PATCH 2/7] Migrate start-emulator to dotnet. --- .../stage-msbuild-emulator-tests.yaml | 20 ++++++++----------- .../yaml-templates/start-emulator.yaml | 18 +++++++++++++++++ 2 files changed, 26 insertions(+), 12 deletions(-) create mode 100644 build-tools/automation/yaml-templates/start-emulator.yaml diff --git a/build-tools/automation/yaml-templates/stage-msbuild-emulator-tests.yaml b/build-tools/automation/yaml-templates/stage-msbuild-emulator-tests.yaml index f7b113cceae..ccb5f84c6cd 100644 --- a/build-tools/automation/yaml-templates/stage-msbuild-emulator-tests.yaml +++ b/build-tools/automation/yaml-templates/stage-msbuild-emulator-tests.yaml @@ -52,12 +52,7 @@ stages: --outfile="$(System.DefaultWorkingDirectory)/bin/Test$(XA.Build.Configuration)/MSBuildDeviceIntegration/${{ parameters.target_framework }}/MSBuildDeviceIntegration.runsettings" displayName: Slice unit tests - - task: MSBuild@1 - displayName: start emulator - inputs: - solution: tests/Mono.Android-Tests/Mono.Android-Tests.csproj - configuration: $(XA.Build.Configuration) - msbuildArguments: /t:AcquireAndroidTarget /bl:$(System.DefaultWorkingDirectory)/bin/Test$(XA.Build.Configuration)/start-emulator.binlog + - template: start-emulator.yaml - template: run-nunit-tests.yaml parameters: @@ -121,12 +116,13 @@ stages: artifactName: $(TestAssembliesArtifactName) downloadPath: $(System.DefaultWorkingDirectory)/bin/Test$(XA.Build.Configuration) - - task: MSBuild@1 - displayName: install and launch emulator - inputs: - solution: tests/Mono.Android-Tests/Mono.Android-Tests.csproj - configuration: $(XA.Build.Configuration) - msbuildArguments: /t:InstallAvdImage;AcquireAndroidTarget /p:TestDeviceName=$(deviceName) /p:TestAvdApiLevel=$(avdApiLevel) /p:TestAvdAbi=$(avdAbi) /p:TestAvdType=$(avdType) /bl:$(System.DefaultWorkingDirectory)/bin/Test$(XA.Build.Configuration)/install-emulator-$(avdApiLevel).binlog + - template: start-emulator.yaml + parameters: + installImage: true + installDeviceName: $(deviceName) + installAvdApiLevel: $(avdApiLevel) + installAvdAbi: $(avdAbi) + installAvdType: $(avdType) - template: run-nunit-tests.yaml parameters: diff --git a/build-tools/automation/yaml-templates/start-emulator.yaml b/build-tools/automation/yaml-templates/start-emulator.yaml new file mode 100644 index 00000000000..84f2645e652 --- /dev/null +++ b/build-tools/automation/yaml-templates/start-emulator.yaml @@ -0,0 +1,18 @@ +parameters: + installImage: false # 'true' to create a new specific AVD image emulator, if 'true', other 'install*' parameters must be provided + installDeviceName: # Device name to install, like 'wear_square' + installAvdApiLevel: # Device API level to install, like '30' + installAvdAbi: # Device ABI to install, like 'x86' + installAvdType: # Device AVD to install, like 'android-wear' + +steps: +# This uses our in-tree 'dotnet' because the system one may not have the 'android' workload installed. +- template: run-dotnet-preview.yaml + parameters: + displayName: Start emulator + continueOnError: false + project: tests/Mono.Android-Tests/Runtime-Microsoft.Android.Sdk/Mono.Android.NET-Tests.csproj + ${{ if eq(parameters.installImage, true) }}: + arguments: -c $(XA.Build.Configuration) -t:InstallAvdImage;AcquireAndroidTarget -p:TestDeviceName=${{ parameters.installDeviceName }} -p:TestAvdApiLevel=${{ parameters.installAvdApiLevel }} -p:TestAvdAbi=${{ parameters.installAvdAbi }} -p:TestAvdType=${{ parameters.installAvdType }} -bl:$(System.DefaultWorkingDirectory)/bin/Test$(XA.Build.Configuration)/install-emulator-${{ parameters.installAvdApiLevel }}.binlog + ${{ else }}: + arguments: -c $(XA.Build.Configuration) -t:AcquireAndroidTarget -bl:$(System.DefaultWorkingDirectory)/bin/Test$(XA.Build.Configuration)/start-emulator.binlog From 472018494a05efc0f43718182bee953112ef31eb Mon Sep 17 00:00:00 2001 From: Jonathan Pobst Date: Tue, 28 Feb 2023 12:55:20 -1000 Subject: [PATCH 3/7] Don't install unneeded things. --- .../setup-test-environment.yaml | 37 ++++++++++------- .../yaml-templates/shut-down-emulator.yaml | 19 +++++++++ .../stage-msbuild-emulator-tests.yaml | 41 +++++++++++-------- .../yaml-templates/start-emulator.yaml | 2 +- 4 files changed, 65 insertions(+), 34 deletions(-) create mode 100644 build-tools/automation/yaml-templates/shut-down-emulator.yaml diff --git a/build-tools/automation/yaml-templates/setup-test-environment.yaml b/build-tools/automation/yaml-templates/setup-test-environment.yaml index 63dbd94e598..d17f5f30156 100644 --- a/build-tools/automation/yaml-templates/setup-test-environment.yaml +++ b/build-tools/automation/yaml-templates/setup-test-environment.yaml @@ -8,6 +8,10 @@ parameters: jdkTestFolder: $(JAVA_HOME_11_X64) remove_dotnet: false installTestSlicer: false + installApkDiff: true + installLegacyDotNet: true + restoreNUnitConsole: true + androidSdkPlatforms: 19,21,26,32,33 steps: - checkout: self @@ -40,11 +44,12 @@ steps: condition: and(succeeded(), eq(variables['agent.os'], 'Windows_NT')) # Install .NET 6 for legacy tests -- template: use-dot-net.yaml - parameters: - version: 6.0 - quality: GA - remove_dotnet: ${{ parameters.remove_dotnet }} +- ${{ if eq(parameters.installLegacyDotNet, true) }}: + - template: use-dot-net.yaml + parameters: + version: 6.0 + quality: GA + remove_dotnet: ${{ parameters.remove_dotnet }} # Install latest .NET - template: use-dot-net.yaml @@ -65,17 +70,18 @@ steps: - template: run-xaprepare.yaml parameters: - arguments: --s=AndroidTestDependencies --android-sdk-platforms="19,21,26,32,33" + arguments: --s=AndroidTestDependencies --android-sdk-platforms="${{ parameters.androidSdkPlatforms }}" xaSourcePath: ${{ parameters.xaSourcePath }} -- task: DotNetCoreCLI@2 - displayName: restore NUnit.Console - inputs: - command: restore - projects: ${{ parameters.xaSourcePath }}/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Xamarin.ProjectTools.csproj - restoreArguments: -bl:${{ parameters.xaSourcePath }}/bin/Test${{ parameters.configuration }}/restore-Xamarin.ProjectTools.binlog - nugetConfigPath: ${{ parameters.xaSourcePath }}/NuGet.config - feedsToUse: config +- ${{ if eq(parameters.restoreNUnitConsole, true) }}: + - task: DotNetCoreCLI@2 + displayName: restore NUnit.Console + inputs: + command: restore + projects: ${{ parameters.xaSourcePath }}/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Xamarin.ProjectTools.csproj + restoreArguments: -bl:${{ parameters.xaSourcePath }}/bin/Test${{ parameters.configuration }}/restore-Xamarin.ProjectTools.binlog + nugetConfigPath: ${{ parameters.xaSourcePath }}/NuGet.config + feedsToUse: config - task: DotNetCoreCLI@2 displayName: build Xamarin.Android.Tools.BootstrapTasks.csproj @@ -101,7 +107,8 @@ steps: projects: ${{ parameters.xaSourcePath }}/build-tools/create-packs/Microsoft.Android.Sdk.proj arguments: -t:ExtractWorkloadPacks -c ${{ parameters.configuration }} -v:n -bl:${{ parameters.xaSourcePath }}/bin/Test${{ parameters.configuration }}/extract-workloads.binlog -- template: install-apkdiff.yaml +- ${{ if eq(parameters.installApkDiff, true) }}: + - template: install-apkdiff.yaml - ${{ if eq(parameters.installTestSlicer, true) }}: - template: install-dotnet-test-slicer.yaml diff --git a/build-tools/automation/yaml-templates/shut-down-emulator.yaml b/build-tools/automation/yaml-templates/shut-down-emulator.yaml new file mode 100644 index 00000000000..aad489cc811 --- /dev/null +++ b/build-tools/automation/yaml-templates/shut-down-emulator.yaml @@ -0,0 +1,19 @@ +parameters: + releaseImage: false # 'true' to release a specific emulator, if 'true', other 'release*' parameters must be provided + releaseDeviceName: # Device name to release, like 'wear_square' + releaseAvdApiLevel: # Device API level to release, like '30' + releaseAvdAbi: # Device ABI to release, like 'x86' + releaseAvdType: # Device AVD to release, like 'android-wear' + +steps: +# This uses our in-tree 'dotnet' because the system one may not have the 'android' workload installed. +- template: run-dotnet-preview.yaml + parameters: + displayName: Shut down emulator + condition: always() + continueOnError: true + project: tests/Mono.Android-Tests/Runtime-Microsoft.Android.Sdk/Mono.Android.NET-Tests.csproj + ${{ if eq(parameters.releaseImage, true) }}: + arguments: -c $(XA.Build.Configuration) -t:"AcquireAndroidTarget,ReleaseAndroidTarget" -p:TestDeviceName=${{ parameters.releaseDeviceName }} -p:TestAvdApiLevel=${{ parameters.releaseAvdApiLevel }} -p:TestAvdAbi=${{ parameters.releaseAvdAbi }} -p:TestAvdType=${{ parameters.releaseAvdType }} -bl:$(System.DefaultWorkingDirectory)/bin/Test$(XA.Build.Configuration)/shutdown-emulator.binlog + ${{ else }}: + arguments: -c $(XA.Build.Configuration) -t:"AcquireAndroidTarget,ReleaseAndroidTarget" -bl:$(System.DefaultWorkingDirectory)/bin/Test$(XA.Build.Configuration)/shutdown-emulator.binlog diff --git a/build-tools/automation/yaml-templates/stage-msbuild-emulator-tests.yaml b/build-tools/automation/yaml-templates/stage-msbuild-emulator-tests.yaml index ccb5f84c6cd..e03fa744dab 100644 --- a/build-tools/automation/yaml-templates/stage-msbuild-emulator-tests.yaml +++ b/build-tools/automation/yaml-templates/stage-msbuild-emulator-tests.yaml @@ -26,17 +26,23 @@ stages: cancelTimeoutInMinutes: 5 workspace: clean: all + variables: + androidSdkPlatforms: 33 steps: - template: setup-test-environment.yaml parameters: provisionClassic: false provisionatorChannel: ${{ parameters.provisionatorChannel }} installTestSlicer: true + installApkDiff: false + installLegacyDotNet: false + restoreNUnitConsole: false + androidSdkPlatforms: $(androidSdkPlatforms) - template: run-xaprepare.yaml parameters: displayName: install emulator - arguments: --s=EmulatorTestDependencies --android-sdk-platforms="19,21,26,32,33" + arguments: --s=EmulatorTestDependencies --android-sdk-platforms="$(androidSdkPlatforms)" - task: DownloadPipelineArtifact@2 inputs: @@ -62,15 +68,7 @@ stages: dotNetTestExtraArgs: --settings "$(System.DefaultWorkingDirectory)/bin/Test$(XA.Build.Configuration)/MSBuildDeviceIntegration/${{ parameters.target_framework }}/MSBuildDeviceIntegration.runsettings" testResultsFile: TestResult-MSBuildDeviceIntegration-${{ parameters.job_name }}-$(System.JobPositionInPhase)-$(XA.Build.Configuration).xml - - task: MSBuild@1 - displayName: shut down emulator - inputs: - solution: tests/Mono.Android-Tests/Mono.Android-Tests.csproj - configuration: $(XA.Build.Configuration) - msbuildArguments: >- - /t:AcquireAndroidTarget,ReleaseAndroidTarget - /bl:$(System.DefaultWorkingDirectory)/bin/Test$(XA.Build.Configuration)/shutdown-emulator.binlog - condition: always() + - template: shut-down-emulator.yaml - template: upload-results.yaml parameters: @@ -89,6 +87,7 @@ stages: avdAbi: x86 avdType: android-wear deviceName: wear_square + androidSdkPlatforms: 33 pool: vmImage: $(HostedMacImage) workspace: @@ -96,7 +95,13 @@ stages: steps: - template: setup-test-environment.yaml parameters: + provisionClassic: false + provisionatorChannel: ${{ parameters.provisionatorChannel }} configuration: $(XA.Build.Configuration) + installApkDiff: false + installLegacyDotNet: false + restoreNUnitConsole: false + androidSdkPlatforms: $(androidSdkPlatforms) - template: run-xaprepare.yaml parameters: @@ -106,7 +111,7 @@ stages: - template: run-xaprepare.yaml parameters: displayName: install emulator - arguments: --s=EmulatorTestDependencies + arguments: --s=EmulatorTestDependencies --android-sdk-platforms="$(androidSdkPlatforms)" - script: echo "##vso[task.setvariable variable=Java8SdkDirectory]$JAVA_HOME_8_X64" displayName: set Java8SdkDirectory @@ -131,13 +136,13 @@ stages: dotNetTestExtraArgs: --filter "TestCategory = WearOS" testResultsFile: TestResult-WearOS--$(XA.Build.Configuration).xml - - task: MSBuild@1 - displayName: shut down emulator - inputs: - solution: tests/Mono.Android-Tests/Mono.Android-Tests.csproj - configuration: $(XA.Build.Configuration) - msbuildArguments: /t:AcquireAndroidTarget,ReleaseAndroidTarget /p:TestDeviceName=$(deviceName) /p:TestAvdApiLevel=$(avdApiLevel) /p:TestAvdAbi=$(avdAbi) /p:TestAvdType=$(avdType) /bl:$(System.DefaultWorkingDirectory)/bin/Test$(XA.Build.Configuration)/shutdown-emulator.binlog - condition: always() + - template: shut-down-emulator.yaml + parameters: + releaseImage: true + releaseDeviceName: $(deviceName) + releaseAvdApiLevel: $(avdApiLevel) + releaseAvdAbi: $(avdAbi) + releaseAvdType: $(avdType) - template: upload-results.yaml parameters: diff --git a/build-tools/automation/yaml-templates/start-emulator.yaml b/build-tools/automation/yaml-templates/start-emulator.yaml index 84f2645e652..56b9e278bac 100644 --- a/build-tools/automation/yaml-templates/start-emulator.yaml +++ b/build-tools/automation/yaml-templates/start-emulator.yaml @@ -13,6 +13,6 @@ steps: continueOnError: false project: tests/Mono.Android-Tests/Runtime-Microsoft.Android.Sdk/Mono.Android.NET-Tests.csproj ${{ if eq(parameters.installImage, true) }}: - arguments: -c $(XA.Build.Configuration) -t:InstallAvdImage;AcquireAndroidTarget -p:TestDeviceName=${{ parameters.installDeviceName }} -p:TestAvdApiLevel=${{ parameters.installAvdApiLevel }} -p:TestAvdAbi=${{ parameters.installAvdAbi }} -p:TestAvdType=${{ parameters.installAvdType }} -bl:$(System.DefaultWorkingDirectory)/bin/Test$(XA.Build.Configuration)/install-emulator-${{ parameters.installAvdApiLevel }}.binlog + arguments: -c $(XA.Build.Configuration) -t:"InstallAvdImage;AcquireAndroidTarget" -p:TestDeviceName=${{ parameters.installDeviceName }} -p:TestAvdApiLevel=${{ parameters.installAvdApiLevel }} -p:TestAvdAbi=${{ parameters.installAvdAbi }} -p:TestAvdType=${{ parameters.installAvdType }} -bl:$(System.DefaultWorkingDirectory)/bin/Test$(XA.Build.Configuration)/install-emulator-${{ parameters.installAvdApiLevel }}.binlog ${{ else }}: arguments: -c $(XA.Build.Configuration) -t:AcquireAndroidTarget -bl:$(System.DefaultWorkingDirectory)/bin/Test$(XA.Build.Configuration)/start-emulator.binlog From 9e70332d130a132eee6b5bec9381c9f841e876ac Mon Sep 17 00:00:00 2001 From: Jonathan Pobst Date: Tue, 28 Feb 2023 14:28:02 -1000 Subject: [PATCH 4/7] Don't update Mono. --- .../yaml-templates/setup-test-environment.yaml | 14 ++++++++------ .../stage-msbuild-emulator-tests.yaml | 2 ++ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/build-tools/automation/yaml-templates/setup-test-environment.yaml b/build-tools/automation/yaml-templates/setup-test-environment.yaml index d17f5f30156..42c113deec0 100644 --- a/build-tools/automation/yaml-templates/setup-test-environment.yaml +++ b/build-tools/automation/yaml-templates/setup-test-environment.yaml @@ -11,6 +11,7 @@ parameters: installApkDiff: true installLegacyDotNet: true restoreNUnitConsole: true + updateMono: true androidSdkPlatforms: 19,21,26,32,33 steps: @@ -61,12 +62,13 @@ steps: custom: build-server arguments: shutdown -- template: run-xaprepare.yaml - parameters: - displayName: run xaprepare-UpdateMono - arguments: --s=UpdateMono --auto-provision=yes --auto-provision-uses-sudo=yes - condition: and(succeeded(), eq(variables['agent.os'], 'Darwin')) - xaSourcePath: ${{ parameters.xaSourcePath }} +- ${{ if eq(parameters.updateMono, true) }}: + - template: run-xaprepare.yaml + parameters: + displayName: run xaprepare-UpdateMono + arguments: --s=UpdateMono --auto-provision=yes --auto-provision-uses-sudo=yes + condition: and(succeeded(), eq(variables['agent.os'], 'Darwin')) + xaSourcePath: ${{ parameters.xaSourcePath }} - template: run-xaprepare.yaml parameters: diff --git a/build-tools/automation/yaml-templates/stage-msbuild-emulator-tests.yaml b/build-tools/automation/yaml-templates/stage-msbuild-emulator-tests.yaml index e03fa744dab..fbed3314a09 100644 --- a/build-tools/automation/yaml-templates/stage-msbuild-emulator-tests.yaml +++ b/build-tools/automation/yaml-templates/stage-msbuild-emulator-tests.yaml @@ -37,6 +37,7 @@ stages: installApkDiff: false installLegacyDotNet: false restoreNUnitConsole: false + updateMono: false androidSdkPlatforms: $(androidSdkPlatforms) - template: run-xaprepare.yaml @@ -101,6 +102,7 @@ stages: installApkDiff: false installLegacyDotNet: false restoreNUnitConsole: false + updateMono: false androidSdkPlatforms: $(androidSdkPlatforms) - template: run-xaprepare.yaml From a86a40d5532b5d56f4a5840e7c73f26614041ba8 Mon Sep 17 00:00:00 2001 From: Jonathan Pobst Date: Tue, 28 Feb 2023 15:47:17 -1000 Subject: [PATCH 5/7] Specify the Mono version that is already available on Mac agents. --- Configuration.props | 4 ++-- .../yaml-templates/stage-msbuild-emulator-tests.yaml | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/Configuration.props b/Configuration.props index 447a8fda27f..8f3976d620b 100644 --- a/Configuration.props +++ b/Configuration.props @@ -109,8 +109,8 @@ armeabi-v7a:arm64-v8a:x86:x86_64 $(MSBuildThisFileDirectory)external\Java.Interop $(MSBuildThisFileDirectory)external\mono - https://xamjenkinsartifact.azureedge.net/build-package-osx-mono/2020-02/151/c633fe923832f0c3db3c4e6aa98e5592bf5a06e7/MonoFramework-MDK-6.12.0.145.macos10.xamarin.universal.pkg - 6.12.0.145 + https://download.mono-project.com/archive/6.12.0/macos-10-universal/MonoFramework-MDK-6.12.0.188.macos10.xamarin.universal.pkg + 6.12.0.188 $(MonoRequiredMinimumVersion) False True diff --git a/build-tools/automation/yaml-templates/stage-msbuild-emulator-tests.yaml b/build-tools/automation/yaml-templates/stage-msbuild-emulator-tests.yaml index fbed3314a09..945af95c45a 100644 --- a/build-tools/automation/yaml-templates/stage-msbuild-emulator-tests.yaml +++ b/build-tools/automation/yaml-templates/stage-msbuild-emulator-tests.yaml @@ -102,7 +102,6 @@ stages: installApkDiff: false installLegacyDotNet: false restoreNUnitConsole: false - updateMono: false androidSdkPlatforms: $(androidSdkPlatforms) - template: run-xaprepare.yaml From 24b348b92defe31a76f9cd9b4af3afac19d47b1e Mon Sep 17 00:00:00 2001 From: Jonathan Pobst Date: Thu, 2 Mar 2023 08:32:45 -1000 Subject: [PATCH 6/7] Address emulator YAML review feedback. --- .../yaml-templates/shut-down-emulator.yaml | 19 ------------ .../stage-msbuild-emulator-tests.yaml | 31 ++++++++++--------- .../yaml-templates/start-emulator.yaml | 18 ----------- .../yaml-templates/start-stop-emulator.yaml | 31 +++++++++++++++++++ 4 files changed, 48 insertions(+), 51 deletions(-) delete mode 100644 build-tools/automation/yaml-templates/shut-down-emulator.yaml delete mode 100644 build-tools/automation/yaml-templates/start-emulator.yaml create mode 100644 build-tools/automation/yaml-templates/start-stop-emulator.yaml diff --git a/build-tools/automation/yaml-templates/shut-down-emulator.yaml b/build-tools/automation/yaml-templates/shut-down-emulator.yaml deleted file mode 100644 index aad489cc811..00000000000 --- a/build-tools/automation/yaml-templates/shut-down-emulator.yaml +++ /dev/null @@ -1,19 +0,0 @@ -parameters: - releaseImage: false # 'true' to release a specific emulator, if 'true', other 'release*' parameters must be provided - releaseDeviceName: # Device name to release, like 'wear_square' - releaseAvdApiLevel: # Device API level to release, like '30' - releaseAvdAbi: # Device ABI to release, like 'x86' - releaseAvdType: # Device AVD to release, like 'android-wear' - -steps: -# This uses our in-tree 'dotnet' because the system one may not have the 'android' workload installed. -- template: run-dotnet-preview.yaml - parameters: - displayName: Shut down emulator - condition: always() - continueOnError: true - project: tests/Mono.Android-Tests/Runtime-Microsoft.Android.Sdk/Mono.Android.NET-Tests.csproj - ${{ if eq(parameters.releaseImage, true) }}: - arguments: -c $(XA.Build.Configuration) -t:"AcquireAndroidTarget,ReleaseAndroidTarget" -p:TestDeviceName=${{ parameters.releaseDeviceName }} -p:TestAvdApiLevel=${{ parameters.releaseAvdApiLevel }} -p:TestAvdAbi=${{ parameters.releaseAvdAbi }} -p:TestAvdType=${{ parameters.releaseAvdType }} -bl:$(System.DefaultWorkingDirectory)/bin/Test$(XA.Build.Configuration)/shutdown-emulator.binlog - ${{ else }}: - arguments: -c $(XA.Build.Configuration) -t:"AcquireAndroidTarget,ReleaseAndroidTarget" -bl:$(System.DefaultWorkingDirectory)/bin/Test$(XA.Build.Configuration)/shutdown-emulator.binlog diff --git a/build-tools/automation/yaml-templates/stage-msbuild-emulator-tests.yaml b/build-tools/automation/yaml-templates/stage-msbuild-emulator-tests.yaml index 945af95c45a..35dfd624638 100644 --- a/build-tools/automation/yaml-templates/stage-msbuild-emulator-tests.yaml +++ b/build-tools/automation/yaml-templates/stage-msbuild-emulator-tests.yaml @@ -59,7 +59,7 @@ stages: --outfile="$(System.DefaultWorkingDirectory)/bin/Test$(XA.Build.Configuration)/MSBuildDeviceIntegration/${{ parameters.target_framework }}/MSBuildDeviceIntegration.runsettings" displayName: Slice unit tests - - template: start-emulator.yaml + - template: start-stop-emulator.yaml - template: run-nunit-tests.yaml parameters: @@ -69,7 +69,9 @@ stages: dotNetTestExtraArgs: --settings "$(System.DefaultWorkingDirectory)/bin/Test$(XA.Build.Configuration)/MSBuildDeviceIntegration/${{ parameters.target_framework }}/MSBuildDeviceIntegration.runsettings" testResultsFile: TestResult-MSBuildDeviceIntegration-${{ parameters.job_name }}-$(System.JobPositionInPhase)-$(XA.Build.Configuration).xml - - template: shut-down-emulator.yaml + - template: start-stop-emulator.yaml + parameters: + command: stop - template: upload-results.yaml parameters: @@ -122,13 +124,13 @@ stages: artifactName: $(TestAssembliesArtifactName) downloadPath: $(System.DefaultWorkingDirectory)/bin/Test$(XA.Build.Configuration) - - template: start-emulator.yaml + - template: start-stop-emulator.yaml parameters: - installImage: true - installDeviceName: $(deviceName) - installAvdApiLevel: $(avdApiLevel) - installAvdAbi: $(avdAbi) - installAvdType: $(avdType) + specificImage: true + deviceName: $(deviceName) + avdApiLevel: $(avdApiLevel) + avdAbi: $(avdAbi) + avdType: $(avdType) - template: run-nunit-tests.yaml parameters: @@ -137,13 +139,14 @@ stages: dotNetTestExtraArgs: --filter "TestCategory = WearOS" testResultsFile: TestResult-WearOS--$(XA.Build.Configuration).xml - - template: shut-down-emulator.yaml + - template: start-stop-emulator.yaml parameters: - releaseImage: true - releaseDeviceName: $(deviceName) - releaseAvdApiLevel: $(avdApiLevel) - releaseAvdAbi: $(avdAbi) - releaseAvdType: $(avdType) + command: stop + specificImage: true + deviceName: $(deviceName) + avdApiLevel: $(avdApiLevel) + avdAbi: $(avdAbi) + avdType: $(avdType) - template: upload-results.yaml parameters: diff --git a/build-tools/automation/yaml-templates/start-emulator.yaml b/build-tools/automation/yaml-templates/start-emulator.yaml deleted file mode 100644 index 56b9e278bac..00000000000 --- a/build-tools/automation/yaml-templates/start-emulator.yaml +++ /dev/null @@ -1,18 +0,0 @@ -parameters: - installImage: false # 'true' to create a new specific AVD image emulator, if 'true', other 'install*' parameters must be provided - installDeviceName: # Device name to install, like 'wear_square' - installAvdApiLevel: # Device API level to install, like '30' - installAvdAbi: # Device ABI to install, like 'x86' - installAvdType: # Device AVD to install, like 'android-wear' - -steps: -# This uses our in-tree 'dotnet' because the system one may not have the 'android' workload installed. -- template: run-dotnet-preview.yaml - parameters: - displayName: Start emulator - continueOnError: false - project: tests/Mono.Android-Tests/Runtime-Microsoft.Android.Sdk/Mono.Android.NET-Tests.csproj - ${{ if eq(parameters.installImage, true) }}: - arguments: -c $(XA.Build.Configuration) -t:"InstallAvdImage;AcquireAndroidTarget" -p:TestDeviceName=${{ parameters.installDeviceName }} -p:TestAvdApiLevel=${{ parameters.installAvdApiLevel }} -p:TestAvdAbi=${{ parameters.installAvdAbi }} -p:TestAvdType=${{ parameters.installAvdType }} -bl:$(System.DefaultWorkingDirectory)/bin/Test$(XA.Build.Configuration)/install-emulator-${{ parameters.installAvdApiLevel }}.binlog - ${{ else }}: - arguments: -c $(XA.Build.Configuration) -t:AcquireAndroidTarget -bl:$(System.DefaultWorkingDirectory)/bin/Test$(XA.Build.Configuration)/start-emulator.binlog diff --git a/build-tools/automation/yaml-templates/start-stop-emulator.yaml b/build-tools/automation/yaml-templates/start-stop-emulator.yaml new file mode 100644 index 00000000000..72a617fb3dc --- /dev/null +++ b/build-tools/automation/yaml-templates/start-stop-emulator.yaml @@ -0,0 +1,31 @@ +parameters: + command: start # 'start' or 'stop' + specificImage: false # 'true' to use a specific emulator AVD image + deviceName: # Device name, like 'wear_square', required if 'specificImage' is 'true' + avdApiLevel: # Device API level, like '30', required if 'specificImage' is 'true' + avdAbi: # Device ABI, like 'x86', required if 'specificImage' is 'true' + avdType: # Device AVD, like 'android-wear', required if 'specificImage' is 'true' + +steps: +- ${{ if eq(parameters.command, 'start') }}: + - task: DotNetCoreCLI@2 + inputs: + displayName: Start emulator + continueOnError: false + projects: src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Emulator.csproj + ${{ if eq(parameters.specificImage, true) }}: + arguments: -c $(XA.Build.Configuration) -t:"InstallAvdImage;AcquireAndroidTarget" -p:TestDeviceName=${{ parameters.deviceName }} -p:TestAvdApiLevel=${{ parameters.avdApiLevel }} -p:TestAvdAbi=${{ parameters.avdAbi }} -p:TestAvdType=${{ parameters.avdType }} -bl:$(System.DefaultWorkingDirectory)/bin/Test$(XA.Build.Configuration)/install-emulator-${{ parameters.avdApiLevel }}.binlog + ${{ else }}: + arguments: -c $(XA.Build.Configuration) -t:AcquireAndroidTarget -bl:$(System.DefaultWorkingDirectory)/bin/Test$(XA.Build.Configuration)/start-emulator.binlog + +- ${{ if eq(parameters.command, 'stop') }}: + - task: DotNetCoreCLI@2 + inputs: + displayName: Shut down emulator + condition: always() + continueOnError: true + projects: src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Emulator.csproj + ${{ if eq(parameters.specificImage, true) }}: + arguments: -c $(XA.Build.Configuration) -t:"AcquireAndroidTarget,ReleaseAndroidTarget" -p:TestDeviceName=${{ parameters.deviceName }} -p:TestAvdApiLevel=${{ parameters.avdApiLevel }} -p:TestAvdAbi=${{ parameters.avdAbi }} -p:TestAvdType=${{ parameters.avdType }} -bl:$(System.DefaultWorkingDirectory)/bin/Test$(XA.Build.Configuration)/shutdown-emulator.binlog + ${{ else }}: + arguments: -c $(XA.Build.Configuration) -t:"AcquireAndroidTarget,ReleaseAndroidTarget" -bl:$(System.DefaultWorkingDirectory)/bin/Test$(XA.Build.Configuration)/shutdown-emulator.binlog From 3367647549c626309ebf4780ba0b76f4bdaf657e Mon Sep 17 00:00:00 2001 From: Jonathan Pobst Date: Thu, 2 Mar 2023 10:15:23 -1000 Subject: [PATCH 7/7] Make Emulator.csproj work without specifying a working directory. --- .../automation/yaml-templates/start-stop-emulator.yaml | 10 +++++----- .../Tests/Xamarin.Android.Build.Tests/Emulator.csproj | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/build-tools/automation/yaml-templates/start-stop-emulator.yaml b/build-tools/automation/yaml-templates/start-stop-emulator.yaml index 72a617fb3dc..200637f1b51 100644 --- a/build-tools/automation/yaml-templates/start-stop-emulator.yaml +++ b/build-tools/automation/yaml-templates/start-stop-emulator.yaml @@ -9,9 +9,9 @@ parameters: steps: - ${{ if eq(parameters.command, 'start') }}: - task: DotNetCoreCLI@2 + displayName: Start emulator + continueOnError: false inputs: - displayName: Start emulator - continueOnError: false projects: src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Emulator.csproj ${{ if eq(parameters.specificImage, true) }}: arguments: -c $(XA.Build.Configuration) -t:"InstallAvdImage;AcquireAndroidTarget" -p:TestDeviceName=${{ parameters.deviceName }} -p:TestAvdApiLevel=${{ parameters.avdApiLevel }} -p:TestAvdAbi=${{ parameters.avdAbi }} -p:TestAvdType=${{ parameters.avdType }} -bl:$(System.DefaultWorkingDirectory)/bin/Test$(XA.Build.Configuration)/install-emulator-${{ parameters.avdApiLevel }}.binlog @@ -20,10 +20,10 @@ steps: - ${{ if eq(parameters.command, 'stop') }}: - task: DotNetCoreCLI@2 + displayName: Stop emulator + condition: always() + continueOnError: true inputs: - displayName: Shut down emulator - condition: always() - continueOnError: true projects: src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Emulator.csproj ${{ if eq(parameters.specificImage, true) }}: arguments: -c $(XA.Build.Configuration) -t:"AcquireAndroidTarget,ReleaseAndroidTarget" -p:TestDeviceName=${{ parameters.deviceName }} -p:TestAvdApiLevel=${{ parameters.avdApiLevel }} -p:TestAvdAbi=${{ parameters.avdAbi }} -p:TestAvdType=${{ parameters.avdType }} -bl:$(System.DefaultWorkingDirectory)/bin/Test$(XA.Build.Configuration)/shutdown-emulator.binlog diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Emulator.csproj b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Emulator.csproj index 2d8b1d786a5..1962bfdcd1a 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Emulator.csproj +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Emulator.csproj @@ -3,6 +3,6 @@ netstandard2.0 false - - + + \ No newline at end of file