Skip to content

Commit c16e1a4

Browse files
committed
[ci] Parallelize and reduce overhead of MSBuild test stage.
1 parent 6fec194 commit c16e1a4

File tree

2 files changed

+121
-92
lines changed

2 files changed

+121
-92
lines changed

build-tools/automation/azure-pipelines.yaml

Lines changed: 7 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -550,98 +550,13 @@ stages:
550550
artifactName: Test Results - MSBuild Smoke - Linux
551551

552552
- template: yaml-templates/fail-on-issue.yaml
553-
554-
- stage: msbuild_dotnet
555-
displayName: One .NET Tests
556-
dependsOn: mac_build
557-
condition: and(succeeded(), or(eq(variables['RunAllTests'], true), contains(dependencies.mac_build.outputs['mac_build_create_installers.TestConditions.TestAreas'], 'MSBuild')))
558-
jobs:
559-
# Xamarin.Android (Test MSBuild One .NET - macOS)
560-
- template: yaml-templates\run-msbuild-mac-tests.yaml
561-
parameters:
562-
node_id: 1
563-
job_name: mac_dotnet_tests_1
564-
job_suffix: One .NET
565-
nunit_categories: $(DotNetNUnitCategories) & TestCategory != SmokeTests
566-
target_framework: $(DotNetStableTargetFramework)
567-
provisionatorChannel: ${{ parameters.provisionatorChannel }}
568-
569-
- template: yaml-templates\run-msbuild-mac-tests.yaml
570-
parameters:
571-
node_id: 2
572-
job_name: mac_dotnet_tests_2
573-
job_suffix: One .NET
574-
nunit_categories: $(DotNetNUnitCategories) & TestCategory != SmokeTests
575-
target_framework: $(DotNetStableTargetFramework)
576-
provisionatorChannel: ${{ parameters.provisionatorChannel }}
577-
578-
- template: yaml-templates\run-msbuild-mac-tests.yaml
579-
parameters:
580-
node_id: 3
581-
job_name: mac_dotnet_tests_3
582-
job_suffix: One .NET
583-
nunit_categories: $(DotNetNUnitCategories) & TestCategory != SmokeTests
584-
target_framework: $(DotNetStableTargetFramework)
585-
provisionatorChannel: ${{ parameters.provisionatorChannel }}
586-
587-
- template: yaml-templates\run-msbuild-mac-tests.yaml
588-
parameters:
589-
node_id: 4
590-
job_name: mac_dotnet_tests_4
591-
job_suffix: One .NET
592-
nunit_categories: $(DotNetNUnitCategories) & TestCategory != SmokeTests
593-
target_framework: $(DotNetStableTargetFramework)
594-
provisionatorChannel: ${{ parameters.provisionatorChannel }}
595-
596-
- template: yaml-templates\run-msbuild-mac-tests.yaml
597-
parameters:
598-
node_id: 5
599-
job_name: mac_dotnet_tests_5
600-
job_suffix: One .NET
601-
nunit_categories: $(DotNetNUnitCategories) & TestCategory != SmokeTests
602-
target_framework: $(DotNetStableTargetFramework)
603-
provisionatorChannel: ${{ parameters.provisionatorChannel }}
604-
605-
- template: yaml-templates\run-msbuild-mac-tests.yaml
606-
parameters:
607-
node_id: 6
608-
job_name: mac_dotnet_tests_6
609-
job_suffix: One .NET
610-
nunit_categories: $(DotNetNUnitCategories) & TestCategory != SmokeTests
611-
target_framework: $(DotNetStableTargetFramework)
612-
provisionatorChannel: ${{ parameters.provisionatorChannel }}
613-
614-
# Xamarin.Android (Test MSBuild One .NET - Windows)
615-
- template: yaml-templates\run-msbuild-win-tests.yaml
616-
parameters:
617-
node_id: 1
618-
additional_node_id: 4
619-
job_name: win_dotnet_tests_1
620-
job_suffix: One .NET
621-
nunit_categories: $(DotNetNUnitCategories) & TestCategory != SmokeTests
622-
target_framework: $(DotNetStableTargetFramework)
623-
provisionatorChannel: ${{ parameters.provisionatorChannel }}
624-
625-
- template: yaml-templates\run-msbuild-win-tests.yaml
626-
parameters:
627-
node_id: 2
628-
additional_node_id: 5
629-
job_name: win_dotnet_tests_2
630-
job_suffix: One .NET
631-
nunit_categories: $(DotNetNUnitCategories) & TestCategory != SmokeTests
632-
target_framework: $(DotNetStableTargetFramework)
633-
provisionatorChannel: ${{ parameters.provisionatorChannel }}
634-
635-
- template: yaml-templates\run-msbuild-win-tests.yaml
636-
parameters:
637-
node_id: 3
638-
additional_node_id: 6
639-
job_name: win_dotnet_tests_3
640-
job_suffix: One .NET
641-
nunit_categories: $(DotNetNUnitCategories) & TestCategory != SmokeTests
642-
target_framework: $(DotNetStableTargetFramework)
643-
provisionatorChannel: ${{ parameters.provisionatorChannel }}
644-
553+
554+
- template: yaml-templates/stage-msbuild-tests.yaml
555+
parameters:
556+
provisionatorChannel: ${{ parameters.provisionatorChannel }}
557+
stageCondition: and(succeeded(), or(eq(variables['RunAllTests'], true), contains(dependencies.mac_build.outputs['mac_build_create_installers.TestConditions.TestAreas'], 'MSBuild')))
558+
nunit_categories: '& cat != DotNetIgnore & cat != HybridAOT & cat != MkBundle & cat != MonoSymbolicate & cat != PackagesConfig & cat != StaticProject & cat != SystemApplication'
559+
645560
- template: yaml-templates/stage-msbuild-emulator-tests.yaml
646561
parameters:
647562
provisionatorChannel: ${{ parameters.provisionatorChannel }}
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
# Runs MSBuild tests that do not require devices on Mac/Windows
2+
3+
parameters:
4+
mac_agent_count: 8
5+
win_agent_count: 4
6+
nunit_categories: $(DotNetNUnitCategories)
7+
target_framework: $(DotNetStableTargetFramework)
8+
provisionatorChannel: latest
9+
stageCondition: succeeded()
10+
11+
stages:
12+
- stage: msbuild_dotnet
13+
displayName: MSBuild Tests
14+
dependsOn: mac_build
15+
condition: ${{ parameters.stageCondition }}
16+
jobs:
17+
- job: mac_msbuild_tests
18+
strategy:
19+
parallel: ${{ parameters.mac_agent_count }}
20+
displayName: "macOS > Tests > MSBuild"
21+
pool:
22+
vmImage: $(HostedMacImage)
23+
timeoutInMinutes: 180
24+
cancelTimeoutInMinutes: 5
25+
workspace:
26+
clean: all
27+
variables:
28+
androidSdkPlatforms: 33
29+
steps:
30+
- template: setup-test-environment.yaml
31+
parameters:
32+
provisionClassic: false
33+
provisionatorChannel: ${{ parameters.provisionatorChannel }}
34+
installTestSlicer: true
35+
36+
- task: DownloadPipelineArtifact@2
37+
inputs:
38+
artifactName: $(TestAssembliesArtifactName)
39+
downloadPath: $(System.DefaultWorkingDirectory)/bin/Test$(XA.Build.Configuration)
40+
41+
- pwsh: |
42+
dotnet-test-slicer `
43+
--test-assembly="$(System.DefaultWorkingDirectory)/bin/Test$(XA.Build.Configuration)/${{ parameters.target_framework }}/Xamarin.Android.Build.Tests.dll" `
44+
--test-filter="cat != SmokeTests ${{ parameters.nunit_categories }}" `
45+
--slice-number=$(System.JobPositionInPhase) `
46+
--total-slices=$(System.TotalJobsInPhase) `
47+
--outfile="$(System.DefaultWorkingDirectory)/bin/Test$(XA.Build.Configuration)/${{ parameters.target_framework }}/Xamarin.Android.Build.Tests.runsettings"
48+
displayName: Slice unit tests
49+
50+
- template: run-nunit-tests.yaml
51+
parameters:
52+
useDotNet: true
53+
testRunTitle: Xamarin.Android.Build.Tests - macOS-$(System.JobPositionInPhase)
54+
testAssembly: $(System.DefaultWorkingDirectory)/bin/Test$(XA.Build.Configuration)/${{ parameters.target_framework }}/Xamarin.Android.Build.Tests.dll
55+
dotNetTestExtraArgs: --settings "$(System.DefaultWorkingDirectory)/bin/Test$(XA.Build.Configuration)/${{ parameters.target_framework }}/Xamarin.Android.Build.Tests.runsettings"
56+
testResultsFile: TestResult-MSBuildTests-mac_msbuild_tests-$(System.JobPositionInPhase)-$(XA.Build.Configuration).xml
57+
58+
- template: upload-results.yaml
59+
parameters:
60+
artifactName: Test Results - MSBuild - macOS-$(System.JobPositionInPhase)
61+
62+
- template: fail-on-issue.yaml
63+
64+
- job: win_msbuild_tests
65+
strategy:
66+
parallel: ${{ parameters.win_agent_count }}
67+
displayName: "Windows > Tests > MSBuild"
68+
pool: $(1ESWindowsPool)
69+
timeoutInMinutes: 180
70+
cancelTimeoutInMinutes: 5
71+
variables:
72+
androidSdkPlatforms: 33
73+
VSINSTALLDIR: C:\Program Files\Microsoft Visual Studio\2022\Enterprise
74+
steps:
75+
- script: netsh int ipv4 set global sourceroutingbehavior=drop
76+
77+
- template: kill-processes.yaml
78+
79+
- template: clean.yaml
80+
81+
- template: setup-test-environment.yaml
82+
parameters:
83+
provisionClassic: false
84+
provisionatorChannel: ${{ parameters.provisionatorChannel }}
85+
installTestSlicer: true
86+
remove_dotnet: true
87+
88+
- task: DownloadPipelineArtifact@2
89+
inputs:
90+
artifactName: $(TestAssembliesArtifactName)
91+
downloadPath: $(System.DefaultWorkingDirectory)/bin/Test$(XA.Build.Configuration)
92+
93+
- pwsh: |
94+
dotnet-test-slicer `
95+
--test-assembly="$(System.DefaultWorkingDirectory)/bin/Test$(XA.Build.Configuration)/${{ parameters.target_framework }}/Xamarin.Android.Build.Tests.dll" `
96+
--test-filter="cat != SmokeTests ${{ parameters.nunit_categories }}" `
97+
--slice-number=$(System.JobPositionInPhase) `
98+
--total-slices=$(System.TotalJobsInPhase) `
99+
--outfile="$(System.DefaultWorkingDirectory)/bin/Test$(XA.Build.Configuration)/${{ parameters.target_framework }}/Xamarin.Android.Build.Tests.runsettings"
100+
displayName: Slice unit tests
101+
102+
- template: run-nunit-tests.yaml
103+
parameters:
104+
useDotNet: true
105+
testRunTitle: Xamarin.Android.Build.Tests - macOS-$(System.JobPositionInPhase)
106+
testAssembly: $(System.DefaultWorkingDirectory)/bin/Test$(XA.Build.Configuration)/${{ parameters.target_framework }}/Xamarin.Android.Build.Tests.dll
107+
dotNetTestExtraArgs: --settings "$(System.DefaultWorkingDirectory)/bin/Test$(XA.Build.Configuration)/${{ parameters.target_framework }}/Xamarin.Android.Build.Tests.runsettings"
108+
testResultsFile: TestResult-MSBuildTests-win_msbuild_tests-$(System.JobPositionInPhase)-$(XA.Build.Configuration).xml
109+
110+
- template: upload-results.yaml
111+
parameters:
112+
artifactName: Test Results - MSBuild - Windows-$(System.JobPositionInPhase)
113+
114+
- template: fail-on-issue.yaml

0 commit comments

Comments
 (0)