Skip to content

Commit 36df0f8

Browse files
committed
[ci] Parallelize and reduce overhead of MSBuiltd test stage.
1 parent 6fec194 commit 36df0f8

File tree

4 files changed

+121
-233
lines changed

4 files changed

+121
-233
lines changed

build-tools/automation/azure-pipelines.yaml

Lines changed: 6 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -550,98 +550,12 @@ 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+
645559
- template: yaml-templates/stage-msbuild-emulator-tests.yaml
646560
parameters:
647561
provisionatorChannel: ${{ parameters.provisionatorChannel }}

build-tools/automation/yaml-templates/run-msbuild-mac-tests.yaml

Lines changed: 0 additions & 66 deletions
This file was deleted.

build-tools/automation/yaml-templates/run-msbuild-win-tests.yaml

Lines changed: 0 additions & 75 deletions
This file was deleted.
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
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="${{ parameters.nunit_categories }} & cat != SmokeTests" `
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:
69+
vmImage: $(1ESWindowsPool)
70+
timeoutInMinutes: 180
71+
cancelTimeoutInMinutes: 5
72+
variables:
73+
androidSdkPlatforms: 33
74+
VSINSTALLDIR: C:\Program Files\Microsoft Visual Studio\2022\Enterprise
75+
steps:
76+
- script: netsh int ipv4 set global sourceroutingbehavior=drop
77+
78+
- template: kill-processes.yaml
79+
80+
- template: clean.yaml
81+
82+
- template: setup-test-environment.yaml
83+
parameters:
84+
provisionClassic: false
85+
provisionatorChannel: ${{ parameters.provisionatorChannel }}
86+
installTestSlicer: true
87+
remove_dotnet: true
88+
89+
- task: DownloadPipelineArtifact@2
90+
inputs:
91+
artifactName: $(TestAssembliesArtifactName)
92+
downloadPath: $(System.DefaultWorkingDirectory)/bin/Test$(XA.Build.Configuration)
93+
94+
- pwsh: |
95+
dotnet-test-slicer `
96+
--test-assembly="$(System.DefaultWorkingDirectory)/bin/Test$(XA.Build.Configuration)/${{ parameters.target_framework }}/Xamarin.Android.Build.Tests.dll" `
97+
--test-filter="${{ parameters.nunit_categories }} & cat != SmokeTests" `
98+
--slice-number=$(System.JobPositionInPhase) `
99+
--total-slices=$(System.TotalJobsInPhase) `
100+
--outfile="$(System.DefaultWorkingDirectory)/bin/Test$(XA.Build.Configuration)/${{ parameters.target_framework }}/Xamarin.Android.Build.Tests.runsettings"
101+
displayName: Slice unit tests
102+
103+
- template: run-nunit-tests.yaml
104+
parameters:
105+
useDotNet: true
106+
testRunTitle: Xamarin.Android.Build.Tests - macOS-$(System.JobPositionInPhase)
107+
testAssembly: $(System.DefaultWorkingDirectory)/bin/Test$(XA.Build.Configuration)/${{ parameters.target_framework }}/Xamarin.Android.Build.Tests.dll
108+
dotNetTestExtraArgs: --settings "$(System.DefaultWorkingDirectory)/bin/Test$(XA.Build.Configuration)/${{ parameters.target_framework }}/Xamarin.Android.Build.Tests.runsettings"
109+
testResultsFile: TestResult-MSBuildTests-win_msbuild_tests-$(System.JobPositionInPhase)-$(XA.Build.Configuration).xml
110+
111+
- template: upload-results.yaml
112+
parameters:
113+
artifactName: Test Results - MSBuild - Windows-$(System.JobPositionInPhase)
114+
115+
- template: fail-on-issue.yaml

0 commit comments

Comments
 (0)