Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ci] Add MAUI integration job #8200

Merged
merged 3 commits into from
Jul 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
135 changes: 133 additions & 2 deletions build-tools/automation/azure-pipelines.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ resources:
name: xamarin/release-scripts
ref: refs/heads/sign-and-notarized
endpoint: xamarin
- repository: maui
type: github
name: dotnet/maui
ref: refs/heads/net8.0
endpoint: xamarin

parameters:
- name: provisionatorChannel
Expand Down Expand Up @@ -277,13 +282,139 @@ stages:
artifactName: Test Results - MSBuild Smoke - Linux

- template: yaml-templates/fail-on-issue.yaml

- template: yaml-templates/stage-msbuild-tests.yaml

- template: yaml-templates/stage-msbuild-emulator-tests.yaml
parameters:
usesCleanImages: ${{ parameters.macTestAgentsUseCleanImages }}

- stage: maui_tests
displayName: MAUI Tests
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's nice this doesn't actually take that long:

image

dependsOn: mac_build
condition: eq(variables['System.PullRequest.TargetBranch'], 'main')
jobs:
# Check - "Xamarin.Android (MAUI Tests MAUI Integration)"
- job: maui_tests_integration
displayName: MAUI Integration
pool: $(1ESWindowsPool)
timeoutInMinutes: 180
workspace:
clean: all
variables:
BuildVersion: $(Build.BuildId)
steps:
- checkout: maui
clean: true
submodules: recursive
path: s/maui
persistCredentials: true

- template: yaml-templates/setup-test-environment.yaml
parameters:
xaSourcePath: $(Build.SourcesDirectory)/xamarin-android
provisionClassic: false
provisionatorChannel: ${{ parameters.provisionatorChannel }}
installLegacyDotNet: false
restoreNUnitConsole: false
updateMono: false
androidSdkPlatforms: 23,24,25,26,27,28,29,30,31,32,$(DefaultTestSdkPlatforms)

- task: NuGetAuthenticate@0
displayName: authenticate with azure artifacts
inputs:
forceReinstallCredentialProvider: true

- script: |
echo ##vso[task.setvariable variable=JI_JAVA_HOME]%JAVA_HOME_11_X64%
echo ##vso[task.setvariable variable=JAVA_HOME]%JAVA_HOME_11_X64%
displayName: set JI_JAVA_HOME, JAVA_HOME

- task: DownloadPipelineArtifact@2
inputs:
artifactName: $(NuGetArtifactName)
downloadPath: $(Build.StagingDirectory)/android-packs

- pwsh: |
$searchPath = Join-Path $(Build.StagingDirectory) android-packs
$wlmanPack = Get-ChildItem $searchPath -Filter *Android*Manifest*.nupkg | Select-Object -First 1
$dest = Join-Path $searchPath "tmp-wlman" "$($wlmanPack.BaseName)"
Expand-Archive -LiteralPath $wlmanPack -DestinationPath $dest
$wlmanJsonPath = Join-Path $dest "data" "WorkloadManifest.json"
$json = Get-Content $wlmanJsonPath | ConvertFrom-Json -AsHashtable
Write-Host "Setting variable ANDROID_PACK_VERSION = $($json["version"])"
Write-Host "##vso[task.setvariable variable=ANDROID_PACK_VERSION;]$($json["version"])"
displayName: Set ANDROID_PACK_VERSION

- pwsh: >-
$(Build.SourcesDirectory)/maui/eng/scripts/update-version-props.ps1
-xmlFileName "$(Build.SourcesDirectory)/maui/eng/Versions.props"
-androidVersion $(ANDROID_PACK_VERSION)
displayName: Update MAUI's Android dependency

- pwsh: ./build.ps1 --target=dotnet --configuration="$(XA.Build.Configuration)" --nugetsource="$(Build.StagingDirectory)\android-packs" --verbosity=diagnostic
displayName: Install .NET
retryCountOnTaskFailure: 3
workingDirectory: $(Build.SourcesDirectory)/maui

- pwsh: ./build.ps1 --target=dotnet-pack --configuration="$(XA.Build.Configuration)" --nugetsource="$(Build.StagingDirectory)\android-packs" --verbosity=diagnostic
displayName: Pack .NET Maui
workingDirectory: $(Build.SourcesDirectory)/maui

- task: DotNetCoreCLI@2
displayName: Install MAUI workload packs
retryCountOnTaskFailure: 3
inputs:
projects: $(Build.SourcesDirectory)/xamarin-android/Xamarin.Android.sln
arguments: -t:InstallMaui -p:MauiUseLocalPacks=true -p:MauiWorkloadToInstall=maui -c $(XA.Build.Configuration) --no-restore -v:n -bl:$(Build.StagingDirectory)/logs/install-maui.binlog
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-p:MauiWorkloadToInstall=maui would install the ios workload, for example. I guess that is fine?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought this would be easier than trying to edit the target frameworks of the template project file, but we can revisit this if it becomes problematic at all in the future.


- template: yaml-templates/run-dotnet-preview.yaml
parameters:
command: new
arguments: maui -o $(Build.StagingDirectory)/MauiTestProj
xaSourcePath: $(Build.SourcesDirectory)/xamarin-android
displayName: Create MAUI template
continueOnError: false

- template: yaml-templates/run-dotnet-preview.yaml
parameters:
project: $(Build.StagingDirectory)/MauiTestProj/MauiTestProj.csproj
arguments: >-
-f $(DotNetTargetFramework)-android -c Debug
--configfile $(Build.SourcesDirectory)/maui/NuGet.config
-bl:$(Build.StagingDirectory)/logs/MauiTestProj-Debug.binlog
xaSourcePath: $(Build.SourcesDirectory)/xamarin-android
displayName: Build MAUI template - Debug

- template: yaml-templates/run-dotnet-preview.yaml
parameters:
project: $(Build.StagingDirectory)/MauiTestProj/MauiTestProj.csproj
arguments: >-
-f $(DotNetTargetFramework)-android -c Release
--configfile $(Build.SourcesDirectory)/maui/NuGet.config
-bl:$(Build.StagingDirectory)/logs/MauiTestProj-Release.binlog
xaSourcePath: $(Build.SourcesDirectory)/xamarin-android
displayName: Build MAUI template - Release

- task: CopyFiles@2
displayName: copy build logs
condition: always()
inputs:
Contents: |
$(Build.SourcesDirectory)/maui/artifacts/logs/**
TargetFolder: $(Build.StagingDirectory)/logs
flattenFolders: true

- template: yaml-templates/publish-artifact.yaml
parameters:
displayName: upload build and test results
artifactName: Test Results - MAUI Integration
targetPath: $(Build.StagingDirectory)/logs
condition: or(ne(variables['Agent.JobStatus'], 'Succeeded'), eq(variables['XA.PublishAllLogs'], 'true'))

- template: yaml-templates/fail-on-issue.yaml


- stage: dotnet_prepare_release
displayName: Prepare .NET Release
dependsOn:
Expand Down
35 changes: 32 additions & 3 deletions build-tools/scripts/DotNet.targets
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,28 @@
<_Root>$(MSBuildThisFileDirectory)..\..\</_Root>
<_BinlogPathPrefix>$(_Root)bin/Build$(Configuration)/msbuild-$([System.DateTime]::Now.ToString("yyyyMMddTHHmmss"))</_BinlogPathPrefix>
</PropertyGroup>

<Target Name="BuildExternal">
<Exec
Command="&quot;$(DotNetPreviewTool)&quot; build monodroid.proj -c $(Configuration) -p:DebuggingToolsOutputDirectory=$(MicrosoftAndroidSdkOutDir) -p:CompatTargetsOutputDirectory=$(XAInstallPrefix)xbuild/Novell -bl:$(_BinlogPathPrefix)-build-monodroid.binlog"
WorkingDirectory="$(_Root)external\monodroid"
/>
</Target>

<Target Name="PrepareJavaInterop">
<Exec
Command="&quot;$(DotNetPreviewTool)&quot; build -t:Prepare Java.Interop.sln -c $(Configuration) -p:JdksRoot=$(JavaSdkDirectory) -p:DotnetToolPath=$(DotNetPreviewTool) -bl:$(_BinlogPathPrefix)-prepare-java-interop.binlog"
WorkingDirectory="$(_Root)external\Java.Interop"
/>
</Target>

<Target Name="BuildDotNet"
DependsOnTargets="PrepareJavaInterop">
<MSBuild Projects="$(_Root)build-tools\xa-prep-tasks\xa-prep-tasks.csproj" />
<MSBuild Projects="$(_Root)Xamarin.Android.sln" Properties="DisableApiCompatibilityCheck=true" />
<MSBuild Projects="$(_Root)build-tools\create-packs\Microsoft.Android.Sdk.proj" Targets="ConfigureLocalWorkload" />
</Target>

<Target Name="PackDotNet">
<!-- Build extra versions of Mono.Android.dll if necessary -->
<MSBuild
Expand All @@ -42,34 +46,59 @@
</ItemGroup>
<RemoveDir Directories="@(_DirectoriesToRemove)" />
</Target>

<Target Name="InstallMaui">
<Error Text="%24(MauiVersion) must be specified." Condition=" '$(MauiVersion)' == '' " />
<Error Text="%24(MauiVersion) must be specified." Condition=" '$(MauiVersion)' == '' and '$(MauiUseLocalPacks)' != 'true' " />
<PropertyGroup>
<_TempDirectory>$(DotNetPreviewPath)..\.xa-workload-temp-$([System.IO.Path]::GetRandomFileName())</_TempDirectory>
<MauiVersionBand Condition=" '$(MauiVersionBand)' == '' ">$(DotNetSdkManifestsFolder)</MauiVersionBand>
<MauiUseLocalPacks Condition=" '$(MauiUseLocalPacks)' == '' ">false</MauiUseLocalPacks>
<MauiSourcePath Condition=" '$(MauiSourcePath)' == '' ">$(XamarinAndroidSourcePath)..\maui</MauiSourcePath>
<MauiPackagePath Condition=" '$(MauiPackagePath)' == '' ">$(MauiSourcePath)\artifacts</MauiPackagePath>
<MauiWorkloadToInstall Condition=" '$(MauiWorkloadToInstall)' == '' ">maui-android</MauiWorkloadToInstall>
</PropertyGroup>
<MakeDir Directories="$(_TempDirectory)" />

<!-- Restore or extract WorkloadManifest.* files-->
<Exec
Condition=" '$(MauiUseLocalPacks)' != 'true' "
Command="&quot;$(DotNetPreviewTool)&quot; restore maui.proj -p:MauiVersion=$(MauiVersion) -p:MauiVersionBand=$(MauiVersionBand)"
WorkingDirectory="$(MSBuildThisFileDirectory)"
EnvironmentVariables="NUGET_PACKAGES=$(_TempDirectory);DOTNET_MULTILEVEL_LOOKUP=0"
/>
<ItemGroup>
<_WLManifestPack Include="$(MauiPackagePath)\Microsoft.NET.Sdk.Maui.Manifest-$(MauiVersionBand.Substring (0,3))*.nupkg" />
</ItemGroup>
<Unzip
Condition=" '$(MauiUseLocalPacks)' == 'true' "
SourceFiles="@(_WLManifestPack)"
DestinationFolder="$(_TempDirectory)"
/>

<!-- Copy WorkloadManifest.* files-->
<ItemGroup>
<_WLManifest Include="$(_TempDirectory)\microsoft.net.sdk.maui.manifest-$(MauiVersionBand)\$(MauiVersion)\data\WorkloadManifest.*" />
<_WLManifest Condition=" '$(MauiUseLocalPacks)' != 'true' " Include="$(_TempDirectory)\microsoft.net.sdk.maui.manifest-$(MauiVersionBand)\$(MauiVersion)\data\WorkloadManifest.*" />
<_WLManifest Condition=" '$(MauiUseLocalPacks)' == 'true' " Include="$(_TempDirectory)\data\*" />
</ItemGroup>
<Copy SourceFiles="@(_WLManifest)" DestinationFolder="$(DotNetPreviewPath)sdk-manifests\$(DotNetSdkManifestsFolder)\microsoft.net.sdk.maui" />

<!-- Parse NuGet.config -->
<XmlPeek
Condition=" '$(MauiUseLocalPacks)' != 'true' "
XmlInputPath="$(XamarinAndroidSourcePath)NuGet.config"
Query="/configuration/packageSources/add/@value">
<Output TaskParameter="Result" ItemName="_NuGetSources" />
</XmlPeek>
<XmlPeek
Condition=" '$(MauiUseLocalPacks)' == 'true' "
XmlInputPath="$(MauiSourcePath)\NuGet.config"
Query="/configuration/packageSources/add/@value">
<Output TaskParameter="Result" ItemName="_NuGetSources" />
</XmlPeek>

<!-- dotnet workload install maui-android -->
<ItemGroup>
<_NuGetSources Condition=" '$(MauiUseLocalPacks)' == 'true' " Include="$(MauiPackagePath.TrimEnd('\'))" />
<_NuGetSources Include="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet7/nuget/v3/index.json" />
<_NuGetSources Include="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet6/nuget/v3/index.json" />
<_InstallArguments Include="--skip-manifest-update" />
Expand All @@ -78,7 +107,7 @@
<_InstallArguments Include="--temp-dir &quot;$(_TempDirectory)&quot;" />
</ItemGroup>
<Exec
Command="&quot;$(DotNetPreviewTool)&quot; workload install maui-android @(_InstallArguments, ' ')"
Command="&quot;$(DotNetPreviewTool)&quot; workload install $(MauiWorkloadToInstall) @(_InstallArguments, ' ')"
WorkingDirectory="$(_TempDirectory)"
EnvironmentVariables="DOTNET_MULTILEVEL_LOOKUP=0"
/>
Expand Down
Loading