Skip to content

Commit 0d4220b

Browse files
rmarinhoCopilotCopilot
authored
[ci] Run android on MAUI-Dnceng (dotnet#33997)
### Description of Change This pull request updates the CI pipeline configuration to introduce and use a new Linux-based pool for running Android tests, replacing the previous macOS-based pools. The main changes are the addition of the `AndroidPoolLinux` parameter and updating the relevant test stage to use this new pool. **Pipeline configuration updates:** * Added a new `AndroidPoolLinux` parameter to `parameters:` in `eng/pipelines/ci.yml` for specifying a Linux pool (`MAUI-DNCENG`) with the `1ESPT-Ubuntu22.04` image for Android test runs. * Updated the `mac_runandroid_tests` stage to use the new `AndroidPoolLinux` pool instead of the previous macOS-based pools, ensuring Android tests run on Linux infrastructure. --------- Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com> Co-authored-by: rmarinho <1235097+rmarinho@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 5219b88 commit 0d4220b

7 files changed

Lines changed: 46 additions & 20 deletions

File tree

eng/pipelines/arcade/setup-test-env.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ steps:
1212
fetchDepth: 1
1313
clean: true
1414

15+
- template: /eng/pipelines/common/enable-kvm.yml@self
16+
1517
- template: /eng/pipelines/common/provision.yml@self
1618
parameters:
1719
checkoutDirectory: '$(System.DefaultWorkingDirectory)'

eng/pipelines/ci.yml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,13 @@ parameters:
108108
- ImageOverride -equals ACES_VM_SharedPool_Tahoe
109109
label: macOS
110110

111+
- name: AndroidPoolLinux
112+
type: object
113+
default:
114+
name: MAUI-DNCENG
115+
demands:
116+
- ImageOverride -equals 1ESPT-Ubuntu22.04
117+
111118

112119
# Condition for MacOSPool comparison lanes (non-ARM64)
113120
# Runs on: (non-PR on main/net*.0/release/*/inflight/*) OR (PR targeting net*.0/release/*/inflight/*)
@@ -277,12 +284,9 @@ stages:
277284
# TODO: macOSTemplates and AOT template categories
278285
- name: mac_runandroid_tests
279286
${{ if eq(variables['Build.DefinitionName'], 'maui-pr') }}:
280-
pool:
281-
name: AcesShared
282-
demands:
283-
- ImageOverride -equals ACES_arm64_Sequoia_Xcode
287+
pool: ${{ parameters.AndroidPoolLinux }}
284288
${{ else }}:
285-
pool: ${{ parameters.MacOSPool.internal }}
289+
pool: ${{ parameters.AndroidPoolLinux }}
286290
timeout: 240
287291
testCategory: RunOnAndroid
288292

eng/pipelines/common/device-tests-steps.yml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,8 @@ steps:
3535
continueOnError: true
3636
timeoutInMinutes: 60
3737
38-
# Enable KVM for Android builds on Linux
3938
- ${{ if and(ne(parameters.buildType, 'buildOnly'), eq(parameters.platform, 'android')) }}:
40-
- bash: |
41-
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
42-
sudo udevadm control --reload-rules
43-
sudo udevadm trigger --name-match=kvm
44-
displayName: Enable KVM
45-
condition: and(succeeded(), eq(variables['Agent.OS'], 'Linux'))
39+
- template: enable-kvm.yml
4640

4741
# Provision the various SDKs that are needed
4842
- template: provision.yml
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Enable KVM for Android tests on Linux
2+
steps:
3+
- bash: |
4+
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
5+
sudo udevadm control --reload-rules
6+
sudo udevadm trigger --name-match=kvm
7+
displayName: Enable KVM
8+
condition: and(succeeded(), eq(variables['Agent.OS'], 'Linux'))

eng/pipelines/common/ui-tests-steps.yml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,8 @@ steps:
5050
continueOnError: true
5151
timeoutInMinutes: 60
5252
53-
# Enable KVM for Android builds on Linux
5453
- ${{ if and(ne(parameters.buildType, 'buildOnly'), eq(parameters.platform, 'android')) }}:
55-
- bash: |
56-
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
57-
sudo udevadm control --reload-rules
58-
sudo udevadm trigger --name-match=kvm
59-
displayName: Enable KVM
60-
condition: and(succeeded(), eq(variables['Agent.OS'], 'Linux'))
54+
- template: enable-kvm.yml
6155

6256
- ${{ if eq(parameters.platform, 'catalyst')}}:
6357
- bash: |

src/DotNet/DotNet.csproj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,9 @@
7878
<!-- Run 'dotnet workload install' for the current running 'dotnet' install -->
7979
<ItemGroup>
8080
<_WorkloadSource Include="$(NugetArtifactsPath)" />
81-
<_LocalWorkloadIds Include="maui" />
81+
<!-- On Linux, install maui-android instead of maui to avoid iOS/macOS dependencies -->
82+
<_LocalWorkloadIds Include="maui-android" Condition="$([MSBuild]::IsOSPlatform('linux'))" />
83+
<_LocalWorkloadIds Include="maui" Condition="!$([MSBuild]::IsOSPlatform('linux'))" />
8284

8385
<_LocalWorkloadIds Include="tizen" Condition=" '$(IncludeTizenTargetFrameworks)' == 'true' " />
8486
</ItemGroup>

src/TestUtils/src/Microsoft.Maui.IntegrationTests/AndroidTemplateTests.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System.Diagnostics;
22
using System.Runtime.InteropServices;
3+
using System.Text.RegularExpressions;
34
using Microsoft.Maui.IntegrationTests.Android;
45

56
namespace Microsoft.Maui.IntegrationTests
@@ -94,6 +95,12 @@ public void RunOnAndroid(string id, string framework, string config, string? tri
9495
Assert.True(DotnetInternal.New(id, projectDir, framework, output: _output),
9596
$"Unable to create template {id}. Check test output for errors.");
9697

98+
// On Linux, only the maui-android workload is installed. Previous .NET
99+
// templates may still include iOS/macOS TFMs causing NETSDK1178 errors
100+
// during restore. Strip them so only Android remains.
101+
if (TestEnvironment.IsLinux)
102+
StripNonAndroidTfms(projectFile, framework);
103+
97104
var buildProps = BuildProps;
98105
if (!string.IsNullOrEmpty(trimMode))
99106
{
@@ -128,5 +135,20 @@ void AddInstrumentation(string projectDir)
128135
"MainLauncher = true, Name = \"com.microsoft.mauitemplate.MainActivity\"");
129136
}
130137

138+
static void StripNonAndroidTfms(string projectFile, string framework)
139+
{
140+
var content = File.ReadAllText(projectFile);
141+
var androidTfm = $"{framework}-android";
142+
// Remove conditional TargetFrameworks lines (iOS/macOS/Windows additions)
143+
content = Regex.Replace(content,
144+
@"\s*<TargetFrameworks\s+Condition=""[^""]*"">[^<]*</TargetFrameworks>",
145+
"");
146+
// Set the base TargetFrameworks to Android only
147+
content = Regex.Replace(content,
148+
@"<TargetFrameworks>[^<]*</TargetFrameworks>",
149+
$"<TargetFrameworks>{androidTfm}</TargetFrameworks>");
150+
File.WriteAllText(projectFile, content);
151+
}
152+
131153
}
132154
}

0 commit comments

Comments
 (0)