Skip to content

Commit

Permalink
[ci] Split templates (dotnet#25953)
Browse files Browse the repository at this point in the history
undefined
  • Loading branch information
rmarinho authored Nov 19, 2024
1 parent fa519a2 commit 0fae06d
Show file tree
Hide file tree
Showing 5 changed files with 174 additions and 92 deletions.
106 changes: 106 additions & 0 deletions eng/pipelines/common/maui-templates-steps.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
parameters:
- name: condition
default: true

- name: artifactName
type: string
default: nuget

- name: artifactItemPattern
type: string
default: '**/*.nupkg'

- name: uploadPrefix
type: string
default: ''

- name: checkoutDirectory
type: string
default: $(System.DefaultWorkingDirectory)

- name: prepareSteps
type: stepList
default: []

- name: category
type: string
default: ''

steps:
- ${{ each step in parameters.prepareSteps }}:
- ${{ each pair in step }}:
${{ pair.key }}: ${{ pair.value }}

- template: provision.yml
parameters:
checkoutDirectory: ${{ parameters.checkoutDirectory }}
skipXcode: false
skipProvisioning: true

- task: DownloadBuildArtifacts@0
displayName: 'Download Packages'
inputs:
artifactName: ${{ parameters.artifactName }}
itemPattern: ${{ parameters.artifactItemPattern }}
downloadPath: $(System.DefaultWorkingDirectory)/artifacts

- pwsh: Move-Item -Path artifacts\${{ parameters.artifactName }}\*.nupkg -Destination artifacts -Force
displayName: Move the downloaded artifacts

- pwsh: |
Get-ChildItem artifacts -Filter 'Microsoft.Maui.Controls.*.nupkg' | Where-Object { $_.Name -match '^Microsoft\.Maui\.Controls\.([\d\.]+.*)\.nupkg$' }
$version = $Matches.1
if (!$version) {
Write-Error "Failed to extract the version from the nupkgs"
exit 1
}
Write-Host "Found .NET MAUI version (MAUI_PACKAGE_VERSION): $version"
Write-Host "##vso[task.setvariable variable=MAUI_PACKAGE_VERSION]$version"
displayName: Read the .NET MAUI version from the nugets

- pwsh: ./build.ps1 --target=dotnet-local-workloads --verbosity=diagnostic
displayName: 'Install .NET (Local Workloads)'
retryCountOnTaskFailure: 3
workingDirectory: ${{ parameters.checkoutDirectory }}
env:
DOTNET_TOKEN: $(dotnetbuilds-internal-container-read-token)
PRIVATE_BUILD: $(PrivateBuild)

- pwsh: ./build.ps1 --target=dotnet-integration-test --filter="Category=${{ parameters.category }}" --resultsfilename="integration-tests-${{ parameters.category }}" --verbosity=diagnostic
displayName: Run ${{ parameters.category }} templates build tests
workingDirectory: ${{ parameters.checkoutDirectory }}

- task: CopyFiles@2
displayName: Copy binlogs
inputs:
SourceFolder: '$(Build.SourcesDirectory)'
Contents: |
**/*.binlog
../**/*.binlog
../../**/*.binlog
TargetFolder: '$(Build.StagingDirectory)/IntegrationTestsBuildLogs'
continueOnError: true
condition: succeededOrFailed()

- task: PublishBuildArtifacts@1
displayName: Publish Artifacts
condition: always()
continueOnError: true
inputs:
PathToPublish: '$(Build.StagingDirectory)/IntegrationTestsBuildLogs'
ArtifactName: BuildTemplateBuildLogs

- task: PublishTestResults@2
displayName: Publish the ${{ parameters.category }} templates build tests
condition: always()
inputs:
testRunner: VSTest
testResultsFiles: '$(build.artifactstagingdirectory)/**/*.trx'
testRunTitle: ${{ parameters.category }} templates build tests

- pwsh: |
Write-Host "Current job status is: $env:AGENT_JOBSTATUS"
if ($env:AGENT_JOBSTATUS -eq "SucceededWithIssues") {
Write-Host "##vso[task.complete result=Failed;]DONE"
}
displayName: Fail if any issues occurred
116 changes: 36 additions & 80 deletions eng/pipelines/common/maui-templates.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,25 @@ parameters:
type: string
default: $(System.DefaultWorkingDirectory)

- name: MacBuildPool
type: object

- name: BuildPlatforms
type: object

- name: BuildCategoriesMac
type: object
default:
- macOSTemplates
- AOT

- name: BuildCategories
type: object
default:
- WindowsTemplates
- macOSTemplates
- Build
- Blazor
- MultiProject
- AOT

- name: RunPlatforms
type: object
Expand All @@ -39,6 +46,25 @@ parameters:
default: []

jobs:
- ${{ each category in parameters.BuildCategoriesMac }}:
- job: build_maui_templates_${{ category }}
workspace:
clean: all
displayName: 'Build ${{ category }}: macOS'
timeoutInMinutes: 240
condition: ${{ parameters.condition}}
pool: ${{ parameters.MacBuildPool}}
steps:
- template: maui-templates-steps.yml
parameters:
condition: ${{ parameters.condition }}
artifactName: ${{ parameters.artifactName }}
artifactItemPattern: ${{ parameters.artifactItemPattern }}
checkoutDirectory: ${{ parameters.checkoutDirectory }}
prepareSteps: ${{ parameters.prepareSteps }}
category: ${{ category }}


- ${{ each category in parameters.BuildCategories }}:
- job: build_maui_templates_${{ category }}
workspace:
Expand All @@ -61,84 +87,14 @@ jobs:
- macOS.Name -equals Sonoma
- macOS.Architecture -equals arm64
steps:

- ${{ each step in parameters.prepareSteps }}:
- ${{ each pair in step }}:
${{ pair.key }}: ${{ pair.value }}

- template: provision.yml
parameters:
checkoutDirectory: ${{ parameters.checkoutDirectory }}
skipXcode: false
skipProvisioning: true

- task: DownloadBuildArtifacts@0
displayName: 'Download Packages'
inputs:
artifactName: ${{ parameters.artifactName }}
itemPattern: ${{ parameters.artifactItemPattern }}
downloadPath: $(System.DefaultWorkingDirectory)/artifacts

- pwsh: Move-Item -Path artifacts\${{ parameters.artifactName }}\*.nupkg -Destination artifacts -Force
displayName: Move the downloaded artifacts

- pwsh: |
Get-ChildItem artifacts -Filter 'Microsoft.Maui.Controls.*.nupkg' | Where-Object { $_.Name -match '^Microsoft\.Maui\.Controls\.([\d\.]+.*)\.nupkg$' }
$version = $Matches.1
if (!$version) {
Write-Error "Failed to extract the version from the nupkgs"
exit 1
}
Write-Host "Found .NET MAUI version (MAUI_PACKAGE_VERSION): $version"
Write-Host "##vso[task.setvariable variable=MAUI_PACKAGE_VERSION]$version"
displayName: Read the .NET MAUI version from the nugets
- pwsh: ./build.ps1 --target=dotnet-local-workloads --verbosity=diagnostic
displayName: 'Install .NET (Local Workloads)'
retryCountOnTaskFailure: 3
workingDirectory: ${{ parameters.checkoutDirectory }}
env:
DOTNET_TOKEN: $(dotnetbuilds-internal-container-read-token)
PRIVATE_BUILD: $(PrivateBuild)

- pwsh: ./build.ps1 --target=dotnet-integration-test --filter="Category=${{ category }}" --resultsfilename="integration-tests" --verbosity=diagnostic
displayName: Run ${{ category }} templates build tests
workingDirectory: ${{ parameters.checkoutDirectory }}

- task: CopyFiles@2
displayName: Copy binlogs
inputs:
SourceFolder: '$(Build.SourcesDirectory)'
Contents: |
**/*.binlog
../**/*.binlog
../../**/*.binlog
TargetFolder: '$(Build.StagingDirectory)/IntegrationTestsBuildLogs'
continueOnError: true
condition: succeededOrFailed()

- task: PublishBuildArtifacts@1
displayName: Publish Artifacts
condition: always()
continueOnError: true
inputs:
PathToPublish: '$(Build.StagingDirectory)/IntegrationTestsBuildLogs'
ArtifactName: BuildTemplateBuildLogs

- task: PublishTestResults@2
displayName: Publish the ${{ category }} templates build tests
condition: always()
inputs:
testRunner: VSTest
testResultsFiles: '$(build.artifactstagingdirectory)/**/*.trx'
testRunTitle: ${{ category }} templates build tests

- pwsh: |
Write-Host "Current job status is: $env:AGENT_JOBSTATUS"
if ($env:AGENT_JOBSTATUS -eq "SucceededWithIssues") {
Write-Host "##vso[task.complete result=Failed;]DONE"
}
displayName: Fail if any issues occurred
- template: maui-templates-steps.yml
parameters:
condition: ${{ parameters.condition }}
artifactName: ${{ parameters.artifactName }}
artifactItemPattern: ${{ parameters.artifactItemPattern }}
checkoutDirectory: ${{ parameters.checkoutDirectory }}
prepareSteps: ${{ parameters.prepareSteps }}
category: ${{ category }}

- ${{ each RunPlatform in parameters.RunPlatforms }}:
- job: run_${{ RunPlatform.testName }}
Expand Down
6 changes: 6 additions & 0 deletions eng/pipelines/handlers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,12 @@ stages:
parameters:
RunPlatforms: ${{ parameters.RunTemplatePlatforms }}
BuildPlatforms: ${{ parameters.BuildTemplatePlatforms }}
MacBuildPool:
name: $(macOSXVmPool)
vmImage: $(macOSXVmImage)
demands:
- macOS.Name -equals Sonoma
- macOS.Architecture -equals x64

- ${{ if eq(variables['System.TeamProject'], 'devdiv') }}:
- template: common/localization-handoff.yml # Process outgoing strings [Localization Handoff]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ private List<string> PrepareNativeAotBuildProps()
extendedBuildProps.Add("_IsPublishing=true"); // This makes 'dotnet build -r iossimulator-x64' equivalent to 'dotnet publish -r iossimulator-x64'
extendedBuildProps.Add("IlcTreatWarningsAsErrors=false");
extendedBuildProps.Add("TrimmerSingleWarn=false");
extendedBuildProps.Add("_RequireCodeSigning=false"); // This is required to build the iOS app without a signing key
return extendedBuildProps;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ public void BuildWithCustomBundleResource(string id, string framework)
}

[Test]
[TestCase("maui-blazor", "Debug", DotNetCurrent)]
[TestCase("maui-blazor", "Release", DotNetCurrent)]
public void CheckEntitlementsForMauiBlazorOnMacCatalyst(string id, string config, string framework)
[TestCase("maui-blazor", "Debug", DotNetCurrent, true)]
[TestCase("maui-blazor", "Release", DotNetCurrent, true)]
public void CheckEntitlementsForMauiBlazorOnMacCatalyst(string id, string config, string framework, bool sign)
{
if (TestEnvironment.IsWindows)
{
Expand All @@ -59,7 +59,7 @@ public void CheckEntitlementsForMauiBlazorOnMacCatalyst(string id, string config

List<string> buildWithCodeSignProps = new List<string>(BuildProps)
{
"EnableCodeSigning=true"
$"EnableCodeSigning={sign}"
};

Assert.IsTrue(DotnetInternal.New(id, projectDir, framework), $"Unable to create template {id}. Check test output for errors.");
Expand All @@ -74,13 +74,13 @@ public void CheckEntitlementsForMauiBlazorOnMacCatalyst(string id, string config
}

[Test]
[TestCase("maui-blazor", "Debug", DotNetCurrent)]
[TestCase("maui-blazor", "Release", DotNetCurrent)]
[TestCase("maui", "Debug", DotNetCurrent)]
[TestCase("maui", "Release", DotNetCurrent)]
[TestCase("maui-multiproject", "Debug", DotNetCurrent)]
[TestCase("maui-multiproject", "Release", DotNetCurrent)]
public void CheckPrivacyManifestForiOS(string id, string config, string framework)
[TestCase("maui-blazor", "Debug", DotNetCurrent, false)]
[TestCase("maui-blazor", "Release", DotNetCurrent, false)]
[TestCase("maui", "Debug", DotNetCurrent, false)]
[TestCase("maui", "Release", DotNetCurrent, false)]
[TestCase("maui-multiproject", "Debug", DotNetCurrent, false)]
[TestCase("maui-multiproject", "Release", DotNetCurrent, false)]
public void CheckPrivacyManifestForiOS(string id, string config, string framework, bool sign)
{
if (TestEnvironment.IsWindows)
{
Expand All @@ -107,8 +107,21 @@ public void CheckPrivacyManifestForiOS(string id, string config, string framewor
Path.Combine(projectDir, $"{Path.GetFileName(projectDir)}.iOS", "bin", config, $"{framework}-ios", $"iossimulator-{arch}", appFileName);
}

List<string> buildWithCodeSignProps = new List<string>(BuildProps);

if(!sign && config == "Release")
{
// Skipping Release build without code signing."
buildWithCodeSignProps.Add("EnableCodeSigning=false");
buildWithCodeSignProps.Add("_RequireCodeSigning=false");
}
else if (sign)
{
buildWithCodeSignProps.Add("EnableCodeSigning=true");
}

Assert.IsTrue(DotnetInternal.New(id, projectDir, framework), $"Unable to create template {id}. Check test output for errors.");
Assert.IsTrue(DotnetInternal.Build(projectFile, config, framework: $"{framework}-ios", msbuildWarningsAsErrors: true),
Assert.IsTrue(DotnetInternal.Build(projectFile, config, framework: $"{framework}-ios", properties: buildWithCodeSignProps, msbuildWarningsAsErrors: true),
$"Project {Path.GetFileName(projectFile)} failed to build. Check test output/attachments for errors.");

string manifestLocation = Path.Combine(appLocation, "PrivacyInfo.xcprivacy");
Expand Down

0 comments on commit 0fae06d

Please sign in to comment.