diff --git a/build-tools/Xamarin.Android.Tools.BootstrapTasks/result-packaging.targets b/build-tools/Xamarin.Android.Tools.BootstrapTasks/result-packaging.targets index 3acd5acbc4b..5d990189af8 100644 --- a/build-tools/Xamarin.Android.Tools.BootstrapTasks/result-packaging.targets +++ b/build-tools/Xamarin.Android.Tools.BootstrapTasks/result-packaging.targets @@ -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" /> @@ -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" /> diff --git a/build-tools/automation/azure-pipelines.yaml b/build-tools/automation/azure-pipelines.yaml index 6c20ef689a9..92c16aa7529 100644 --- a/build-tools/automation/azure-pipelines.yaml +++ b/build-tools/automation/azure-pipelines.yaml @@ -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. @@ -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 @@ -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() diff --git a/build-tools/automation/yaml-templates/apk-instrumentation.yaml b/build-tools/automation/yaml-templates/apk-instrumentation.yaml new file mode 100644 index 00000000000..22459d02ec9 --- /dev/null +++ b/build-tools/automation/yaml-templates/apk-instrumentation.yaml @@ -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() diff --git a/build-tools/automation/yaml-templates/run-installer.yaml b/build-tools/automation/yaml-templates/run-installer.yaml new file mode 100644 index 00000000000..c95c170b9e9 --- /dev/null +++ b/build-tools/automation/yaml-templates/run-installer.yaml @@ -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