Skip to content

Commit

Permalink
[build] Add APK test job
Browse files Browse the repository at this point in the history
  • Loading branch information
pjcollins committed May 31, 2019
1 parent 5f345b8 commit 804c4e0
Show file tree
Hide file tree
Showing 4 changed files with 155 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<_BuildStatusFiles Include="$(XamarinAndroidSourcePath)Configuration.OperatingSystem.props" Condition="Exists('$(XamarinAndroidSourcePath)Configuration.OperatingSystem.props')" />
<_BuildStatusFiles Include="$(XamarinAndroidSourcePath)Configuration.Override.props" Condition="Exists('$(XamarinAndroidSourcePath)Configuration.Override.props')" />
<_BuildStatusFiles Include="$(XamarinAndroidSourcePath)bin\Build$(Configuration)\XABuildConfig.cs" Condition="Exists('$(XamarinAndroidSourcePath)bin\Build$(Configuration)\XABuildConfig.cs')" />
<_BuildStatusFiles Include="$(XamarinAndroidSourcePath)bin\Build$(Configuration)\msbuild*.binlog" />
<_BuildStatusFiles Include="$(XamarinAndroidSourcePath)bin\Build$(Configuration)\*.binlog" />
<_BuildStatusFiles Include="$(XamarinAndroidSourcePath)**\config.log" />
<_BuildStatusFiles Include="$(XamarinAndroidSourcePath)**\config.status" />
<_BuildStatusFiles Include="$(XamarinAndroidSourcePath)**\config.h" />
Expand All @@ -20,7 +20,7 @@
<_TestResultFiles Include="$(XamarinAndroidSourcePath)bin\Test$(Configuration)\*.log" />
<_TestResultFiles Include="$(XamarinAndroidSourcePath)bin\Test$(Configuration)\compatibility\*" />
<_TestResultFiles Include="$(XamarinAndroidSourcePath)bin\Test$(Configuration)\logcat*" />
<_TestResultFiles Include="$(XamarinAndroidSourcePath)bin\Test$(Configuration)\msbuild*.binlog*" />
<_TestResultFiles Include="$(XamarinAndroidSourcePath)bin\Test$(Configuration)\*.binlog" />
<_TestResultFiles Include="$(XamarinAndroidSourcePath)bin\Test$(Configuration)\temp\**\*.binlog" />
<_TestResultFiles Include="$(XamarinAndroidSourcePath)bin\Test$(Configuration)\temp\**\*.log" />
<_TestResultFiles Include="$(XamarinAndroidSourcePath)bin\Test$(Configuration)\TestOutput-*.txt" />
Expand Down
105 changes: 104 additions & 1 deletion build-tools/automation/azure-pipelines.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ trigger:
# Global variables
variables:
BundleArtifactName: bundle
InstallerArtifactName: unsigned-installers
AutoProvisionArgs: /p:AutoProvision=True /p:AutoProvisionUsesSudo=True /p:IgnoreMaxMonoVersion=False

# Stage and Job "display names" are shortened because they are combined to form the name of the corresponding GitHub check.
Expand Down Expand Up @@ -113,7 +114,7 @@ stages:
- task: PublishPipelineArtifact@0
displayName: upload unsigned installers
inputs:
artifactName: unsigned
artifactName: $(InstallerArtifactName)
targetPath: bin/Build$(XA.Build.Configuration)/unsigned-installers

- task: MSBuild@1
Expand Down Expand Up @@ -216,3 +217,105 @@ stages:
artifactName: win-build-test-results
targetPath: $(Build.ArtifactStagingDirectory)
condition: always()

- stage: test
displayName: Test
dependsOn: mac_build
jobs:
- job: mac_apk_tests
displayName: APK Instrumentation
pool: $(XA.Build.Mac.Pool)
timeoutInMinutes: 240
cancelTimeoutInMinutes: 5
variables:
ApkTestConfiguration: Release
steps:
- task: DownloadPipelineArtifact@1
inputs:
artifactName: $(InstallerArtifactName)
itemPattern: "*.pkg"
downloadPath: $(System.DefaultWorkingDirectory)

- template: yaml-templates/run-installer.yaml

# HACK - Provision Emulator
- script: make prepare CONFIGURATION=$(ApkTestConfiguration) V=1 MSBUILD=msbuild MSBUILD_ARGS="$(AutoProvisionArgs)"
displayName: (hack) make prepare - provision emulator

- task: NuGetCommand@2
displayName: nuget restore Xamarin.Android.Tools.sln
inputs:
restoreSolution: external/xamarin-android-tools/Xamarin.Android.Tools.sln

- task: MSBuild@1
displayName: build Xamarin.Android.Tools.BootstrapTasks.csproj
inputs:
solution: build-tools/xamarin.Android.Tools.BootstrapTasks/Xamarin.Android.Tools.BootstrapTasks.csproj
configuration: $(ApkTestConfiguration)
msbuildArguments: /bl:$(System.DefaultWorkingDirectory)/bin/Test$(ApkTestConfiguration)/BootstrapTasks.binlog

- task: NuGetCommand@2
displayName: nuget restore Xamarin.Android-Tests.sln
inputs:
restoreSolution: Xamarin.Android-Tests.sln

- template: yaml-templates/apk-instrumentation.yaml
parameters:
configuration: $(ApkTestConfiguration)
testName: Mono.Android_Tests
project: src/Mono.Android/Test/Mono.Android-Tests.csproj
testResultsFiles: bin/Test$(ApkTestConfiguration)/TestResult-Mono.Android_Tests.xml

- template: yaml-templates/apk-instrumentation.yaml
parameters:
configuration: $(ApkTestConfiguration)
testName: Mono.Android_TestsAppBundle
project: tests/Runtime-AppBundle/Mono.Android-TestsAppBundle.csproj
testResultsFiles: bin/Test$(ApkTestConfiguration)/TestResult-Mono.Android_TestsAppBundle.xml
packageType: Aab

- template: yaml-templates/apk-instrumentation.yaml
parameters:
configuration: $(ApkTestConfiguration)
testName: Mono.Android_TestsMultiDex
project: tests/Runtime-MultiDex/Mono.Android-TestsMultiDex.csproj
testResultsFiles: bin/Test$(ApkTestConfiguration)/TestResult-Mono.Android_TestsMultiDex.xml

- template: yaml-templates/apk-instrumentation.yaml
parameters:
configuration: $(ApkTestConfiguration)
testName: Xamarin.Android.JcwGen_Tests
project: tests/CodeGen-Binding/Xamarin.Android.JcwGen-Tests/Xamarin.Android.JcwGen-Tests.csproj
testResultsFiles: bin/Test$(ApkTestConfiguration)/TestResult-Xamarin.Android.JcwGen_Tests.xml

- template: yaml-templates/apk-instrumentation.yaml
parameters:
configuration: $(ApkTestConfiguration)
testName: Xamarin.Android.Locale_Tests
project: tests/locales/Xamarin.Android.Locale-Tests/Xamarin.Android.Locale-Tests.csproj
testResultsFiles: bin/Test$(ApkTestConfiguration)/TestResult-Xamarin.Android.Locale_Tests.xml

- template: yaml-templates/apk-instrumentation.yaml
parameters:
configuration: $(ApkTestConfiguration)
testName: Xamarin.Android.EmbeddedDSO_Test
project: tests/EmbeddedDSOs/EmbeddedDSO/EmbeddedDSO.csproj
testResultsFiles: bin/Test$(ApkTestConfiguration)/TestResult-Xamarin.Android.EmbeddedDSO_Test.nunit.xml

- task: MSBuild@1
displayName: shut down emulator
inputs:
solution: src/Mono.Android/Test/Mono.Android-Tests.csproj
configuration: $(ApkTestConfiguration)
msbuildArguments: >
/t:AcquireAndroidTarget,ReleaseAndroidTarget
/bl:$(System.DefaultWorkingDirectory)/bin/Test$(ApkTestConfiguration)/shutdown-emulator.binlog
condition: succeededOrFailed()

- task: MSBuild@1
displayName: package results
inputs:
solution: build-tools\Xamarin.Android.Tools.BootstrapTasks\Xamarin.Android.Tools.BootstrapTasks.csproj
configuration: $(ApkTestConfiguration)
msbuildArguments: /t:ZipTestResults /p:TestResultZipOutputPath=$(Build.ArtifactStagingDirectory)
condition: always()
27 changes: 27 additions & 0 deletions build-tools/automation/yaml-templates/apk-instrumentation.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
parameters:
configuration: []
testName: []
project: []
testResultsFiles: []
testResultsFormat: NUnit
packageType: Apk

steps:
- task: MSBuild@1
displayName: run ${{ parameters.testName }}
inputs:
solution: ${{ parameters.project }}
configuration: ${{ parameters.configuration }}
msbuildArguments: >
/t:AcquireAndroidTarget,SignAndroidPackage,DeployTest${{ parameters.packageType }}s,RunTest${{ parameters.packageType }}s,ReportComponentFailures
/bl:$(System.DefaultWorkingDirectory)/bin/Test${{ parameters.configuration }}run${{ parameters.testName }}.binlog
condition: succeededOrFailed()

- task: PublishTestResults@2
displayName: publish ${{ parameters.testName }} results
inputs:
testResultsFormat: ${{ parameters.testResultsFormat }}
testResultsFiles: ${{ parameters.testResultsFiles }}
failTaskOnFailedTests: true
testRunTitle: ${{ parameters.testName }}
condition: succeededOrFailed()
22 changes: 22 additions & 0 deletions build-tools/automation/yaml-templates/run-installer.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
parameters:
artifactDirectory: $(System.DefaultWorkingDirectory)

steps:
- powershell: |
if ([Environment]::OSVersion.Platform -eq "Unix") {
$installer = Get-ChildItem -Path "${{ parameters.artifactDirectory }}/*" -Include *.pkg -File
} else {
$installer = Get-ChildItem -Path "${{ parameters.artifactDirectory }}\*" -Include *.vsix -File
}
if (![System.IO.File]::Exists($installer)) {
throw [System.IO.FileNotFoundException] "Installer not found in $artifactDirectory."
}
Write-Host "##vso[task.setvariable variable=XA.Provisionator.Args]$installer"
displayName: find installer and set provisionator variable

- task: provisionator@2
inputs:
provisionator_uri: $(provisionator-uri)
github_token: $(GitHub.Token)
provisioning_script: $(XA.Provisionator.Args)
provisioning_extra_args: -vv

0 comments on commit 804c4e0

Please sign in to comment.