Skip to content

Commit

Permalink
[ci] Optimize 'APK's .NET' test job overhead.
Browse files Browse the repository at this point in the history
  • Loading branch information
jpobst committed Mar 21, 2023
1 parent 8102a8b commit 82a372f
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 21 deletions.
25 changes: 13 additions & 12 deletions build-tools/automation/azure-pipelines.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ variables:
value: '& TestCategory != DotNetIgnore & TestCategory != HybridAOT & TestCategory != MkBundle & TestCategory != MonoSymbolicate & TestCategory != PackagesConfig & TestCategory != StaticProject & TestCategory != SystemApplication'
- name: ExcludedNUnitCategories
value: '& cat != DotNetIgnore & cat != HybridAOT & cat != MkBundle & cat != MonoSymbolicate & cat != PackagesConfig & cat != StaticProject & cat != SystemApplication'
- name: DefaultTestSdkPlatforms # Comma-separated SDK Platform(s) to install on test agents (no spaces)
value: 33
- ${{ if eq(variables['Build.DefinitionName'], 'Xamarin.Android-Private') }}:
- group: AzureDevOps-Artifact-Feeds-Pats
- group: DotNet-MSRC-Storage
Expand Down Expand Up @@ -312,11 +314,14 @@ stages:
parameters:
provisionClassic: false
provisionatorChannel: ${{ parameters.provisionatorChannel }}
installLegacyDotNet: false
restoreNUnitConsole: false
updateMono: false

- template: yaml-templates/run-xaprepare.yaml
parameters:
displayName: install emulator
arguments: --s=EmulatorTestDependencies
arguments: --s=EmulatorTestDependencies --android-sdk-platforms="$(DefaultTestSdkPlatforms)"

- task: DownloadPipelineArtifact@2
inputs:
Expand All @@ -334,17 +339,19 @@ stages:
parameters:
project: Xamarin.Android.sln
arguments: >-
-t:PrepareJavaInterop -c Debug -m:1 -v:n
-t:PrepareJavaInterop -c Debug --no-restore
-p:DotNetPreviewTool=$(System.DefaultWorkingDirectory)/bin/$(XA.Build.Configuration)/dotnet/dotnet
displayName: prepare java.interop Debug
continueOnError: false

- template: yaml-templates/run-dotnet-preview.yaml
parameters:
project: Xamarin.Android.sln
arguments: -t:PrepareJavaInterop -c $(XA.Build.Configuration) -m:1 -v:n
arguments: -t:PrepareJavaInterop -c $(XA.Build.Configuration) --no-restore
displayName: prepare java.interop $(XA.Build.Configuration)
continueOnError: false

- template: yaml-templates/start-stop-emulator.yaml

- template: yaml-templates/apk-instrumentation.yaml
parameters:
Expand Down Expand Up @@ -411,15 +418,9 @@ stages:
testAssembly: $(System.DefaultWorkingDirectory)/bin/Test$(XA.Build.Configuration)/$(DotNetStableTargetFramework)/Xamarin.Android.Tools.Aidl-Tests.dll
testResultsFile: TestResult-Aidl-Tests-macOS-$(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: yaml-templates/start-stop-emulator.yaml
parameters:
command: stop

- template: yaml-templates/upload-results.yaml
parameters:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ steps:
- script: >
DEST="$(Build.StagingDirectory)/Test${{ parameters.configuration }}/${{ parameters.artifactFolder }}/" &&
mkdir -p "$DEST" &&
cp "${{ parameters.artifactSource }}" "$DEST"
cp "${{ parameters.artifactSource }}" "$DEST" ||
echo "copy apk/aab failed" # We don't need to report the error
displayName: copy apk/aab
condition: ne(variables['Agent.JobStatus'], 'Succeeded')
continueOnError: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ parameters:
installLegacyDotNet: true
restoreNUnitConsole: true
updateMono: true
androidSdkPlatforms: 33
androidSdkPlatforms: $(DefaultTestSdkPlatforms)

steps:
- checkout: self
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ stages:
cancelTimeoutInMinutes: 5
workspace:
clean: all
variables:
androidSdkPlatforms: 33
steps:
- template: setup-test-environment.yaml
parameters:
Expand All @@ -38,7 +36,7 @@ stages:
- template: run-xaprepare.yaml
parameters:
displayName: install emulator
arguments: --s=EmulatorTestDependencies --android-sdk-platforms="$(androidSdkPlatforms)"
arguments: --s=EmulatorTestDependencies --android-sdk-platforms="$(DefaultTestSdkPlatforms)"

- task: DownloadPipelineArtifact@2
inputs:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ parameters:
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'
launchTimeoutMin: 15 # Minutes to wait for the emulator to start

steps:
- ${{ if eq(parameters.command, 'start') }}:
Expand All @@ -14,9 +15,9 @@ steps:
inputs:
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
arguments: -c $(XA.Build.Configuration) -t:"InstallAvdImage;AcquireAndroidTarget" -p:TestDeviceName=${{ parameters.deviceName }} -p:TestAvdApiLevel=${{ parameters.avdApiLevel }} -p:TestAvdAbi=${{ parameters.avdAbi }} -p:TestAvdType=${{ parameters.avdType }} -p:AvdLaunchTimeoutMinutes=${{ parameters.launchTimeoutMin }} -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
arguments: -c $(XA.Build.Configuration) -t:AcquireAndroidTarget -p:AvdLaunchTimeoutMinutes=${{ parameters.launchTimeoutMin }} -bl:$(System.DefaultWorkingDirectory)/bin/Test$(XA.Build.Configuration)/start-emulator.binlog

- ${{ if eq(parameters.command, 'stop') }}:
- task: DotNetCoreCLI@2
Expand All @@ -26,6 +27,6 @@ steps:
inputs:
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
arguments: -c $(XA.Build.Configuration) -t:"AcquireAndroidTarget,ReleaseAndroidTarget" -p:TestDeviceName=${{ parameters.deviceName }} -p:TestAvdApiLevel=${{ parameters.avdApiLevel }} -p:TestAvdAbi=${{ parameters.avdAbi }} -p:TestAvdType=${{ parameters.avdType }} -p:AvdLaunchTimeoutMinutes=${{ parameters.launchTimeoutMin }} -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
arguments: -c $(XA.Build.Configuration) -t:"AcquireAndroidTarget,ReleaseAndroidTarget" -p:AvdLaunchTimeoutMinutes=${{ parameters.launchTimeoutMin }} -bl:$(System.DefaultWorkingDirectory)/bin/Test$(XA.Build.Configuration)/shutdown-emulator.binlog

0 comments on commit 82a372f

Please sign in to comment.