Skip to content

Commit

Permalink
[ci] Try static macOS pool for test jobs
Browse files Browse the repository at this point in the history
Moves MSBuild emulator test jobs to a static machine pool containing
static mac minis to try to improve reliability and performance.
  • Loading branch information
pjcollins committed Jul 21, 2023
1 parent fc944ee commit 9b74c6e
Show file tree
Hide file tree
Showing 15 changed files with 69 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ parameters:
installTestSlicer: false
installApkDiff: true
installLegacyDotNet: true
installLegacyXamarinAndroid: false
restoreNUnitConsole: true
updateMono: true
androidSdkPlatforms: $(DefaultTestSdkPlatforms)
Expand Down Expand Up @@ -66,6 +67,12 @@ steps:
condition: and(succeeded(), eq(variables['agent.os'], 'Darwin'))
xaSourcePath: ${{ parameters.xaSourcePath }}

- ${{ if eq(parameters.installLegacyXamarinAndroid, true) }}:
- powershell: |
& dotnet tool update --global boots --version 1.1.0.36
& boots --stable Xamarin.Android
displayName: install Xamarin.Android
- template: run-xaprepare.yaml
parameters:
arguments: --s=${{ parameters.xaprepareScenario }} --android-sdk-platforms="${{ parameters.androidSdkPlatforms }}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ parameters:
stageName: msbuilddevice_tests
job_name: 'mac_dotnetdevice_tests'
dependsOn: mac_build
agent_count: 8
agent_count: 4
stageCondition: succeeded()
stagePrefix: ''
xaSourcePath: $(System.DefaultWorkingDirectory)
Expand All @@ -25,19 +25,25 @@ stages:
parallel: ${{ parameters.agent_count }}
displayName: "macOS > Tests > MSBuild+Emulator"
pool:
vmImage: $(HostedMacImage)
name: VSEng-VSMac-Xamarin-Shared
demands:
- macOS.Name -equals Ventura
- macOS.Architecture -equals x64
timeoutInMinutes: 90
cancelTimeoutInMinutes: 5
workspace:
clean: all
steps:
- template: agent-cleanser/v1.yml@yaml-templates

- template: setup-test-environment.yaml
parameters:
installTestSlicer: true
installApkDiff: false
installLegacyDotNet: false
installLegacyXamarinAndroid: true
restoreNUnitConsole: false
updateMono: false
updateMono: true
xaSourcePath: ${{ parameters.xaSourcePath }}
repositoryAlias: ${{ parameters.repositoryAlias }}
commit: ${{ parameters.commit }}
Expand All @@ -53,6 +59,8 @@ stages:
xaSourcePath: ${{ parameters.xaSourcePath }}
startContinueOnError: ${{ parameters.emulatorStartContinueOnError }}

- script: /Users/builder/android-toolchain/sdk/platform-tools/adb shell dumpsys wifi

- template: run-sliced-nunit-tests.yaml
parameters:
testAssembly: ${{ parameters.xaSourcePath }}/bin/Test$(XA.Build.Configuration)/MSBuildDeviceIntegration/$(DotNetStableTargetFramework)/MSBuildDeviceIntegration.dll
Expand Down Expand Up @@ -87,10 +95,15 @@ stages:
deviceName: wear_square
androidSdkPlatforms: 33
pool:
vmImage: $(HostedMacImage)
name: VSEng-VSMac-Xamarin-Shared
demands:
- macOS.Name -equals Ventura
- macOS.Architecture -equals x64
workspace:
clean: all
steps:
- template: agent-cleanser/v1.yml@yaml-templates

- template: setup-test-environment.yaml
parameters:
installTestSlicer: true
Expand Down
5 changes: 5 additions & 0 deletions build-tools/create-packs/Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@
<_WLExtractedFiles Include="$(_SdkManifestsFolder)temp\LICENSE" />
<_WLExtractedFiles Include="$(_SdkManifestsFolder)temp\data\*" />
</ItemGroup>
<Touch Files="@(_WLExtractedFiles)" />
<Move SourceFiles="@(_WLExtractedFiles)" DestinationFolder="$(_SdkManifestsFolder)microsoft.net.sdk.android" />
<RemoveDir Directories="$(_SdkManifestsFolder)temp\" />

Expand Down Expand Up @@ -140,6 +141,10 @@
WorkingDirectory="$(_TempDirectory)"
/>
<RemoveDir Directories="$(_TempDirectory)" />
<ItemGroup>
<_ExtractedPackContent Include="$(DotNetPreviewPath)packs\Microsoft.Android*\**" />
</ItemGroup>
<Touch Files="@(_ExtractedPackContent)" />
</Target>

<Target Name="DeleteExtractedWorkloadPacks" >
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ public static string GetAndroidNdkPath ()
public static string GetJavaSdkPath ()
{
var javaSdkPath = Environment.GetEnvironmentVariable ("TEST_ANDROID_JDK_PATH");
if (string.IsNullOrEmpty (javaSdkPath))
javaSdkPath = JavaSdkPath ??= RunPathsTargets ("GetJavaSdkDirectory");
if (string.IsNullOrEmpty (javaSdkPath))
javaSdkPath = JavaSdkPath ??= Environment.GetEnvironmentVariable ("JI_JAVA_HOME");
if (string.IsNullOrEmpty (javaSdkPath))
javaSdkPath = JavaSdkPath ??= RunPathsTargets ("GetJavaSdkDirectory");
if (string.IsNullOrEmpty (javaSdkPath))
javaSdkPath = JavaSdkPath ??= Environment.GetEnvironmentVariable ("JAVA_HOME");
if (string.IsNullOrEmpty (javaSdkPath))
Expand Down Expand Up @@ -88,17 +88,18 @@ public static string GetJavaSdkVersionString ()
static string RunPathsTargets (string target)
{
var targets = Path.Combine (XABuildPaths.TopDirectory, "build-tools", "scripts", "Paths.targets");
var msbuild = TestEnvironment.IsWindows ? TestEnvironment.GetVisualStudioInstance ().MSBuildPath : "msbuild";
var args = $"/nologo /v:minimal /t:{target} \"{targets}\"";
var psi = new ProcessStartInfo (msbuild, args) {
var dotnet = Path.Combine (TestEnvironment.DotNetPreviewDirectory, "dotnet");
var args = $"build /nologo /v:minimal /t:{target} \"{targets}\"";
var psi = new ProcessStartInfo (dotnet, args) {
CreateNoWindow = true,
RedirectStandardOutput = true,
WindowStyle = ProcessWindowStyle.Hidden,
UseShellExecute = false,
WorkingDirectory = XABuildPaths.TestAssemblyOutputDirectory,
};
using (var p = Process.Start (psi)) {
p.WaitForExit ();
string path = p.StandardOutput.ReadToEnd ().Trim ();
string path = p.StandardOutput.ReadLine ().Trim ();
return Directory.Exists (path) ? path : null;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
<GenerateDocumentation>True</GenerateDocumentation>
</PropertyGroup>

<Import Project="..\..\Configuration.props" />

<ItemGroup>
<Compile Include="..\..\src-ThirdParty\NUnitLite\**\*.cs" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public static string Post ()
{
var client = new HttpClient ();
var data = new StringContent ("{\"foo\": \"bar\" }", Encoding.UTF8, "application/json");
var response = client.PostAsync ("https://httpbin.org/post", data).Result;
var response = client.PostAsync ("https://webhook.site/c8e3ec94-673c-45dd-a660-a44779c9ac69/post", data).Result;
response.EnsureSuccessStatusCode ();
var json = response.Content.ReadAsStringAsync ().Result;
return $"[PASS] {nameof (HttpClientTest)}.{nameof (Post)}";
Expand Down
2 changes: 1 addition & 1 deletion tests/MSBuildDeviceIntegration/Tests/AotProfileTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public void BuildBasicApplicationAndAotProfileIt ()
IsRelease = true,
AotAssemblies = false,
};
proj.SetAndroidSupportedAbis ("armeabi-v7a", "x86", "x86_64");
proj.SetAndroidSupportedAbis ("arm64-v8a", "x86_64");

if (Builder.UseDotNet) {
// TODO: only needed in .NET 6+
Expand Down
8 changes: 4 additions & 4 deletions tests/MSBuildDeviceIntegration/Tests/DebuggingTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public void ApplicationRunsWithoutDebugger ([Values (false, true)] bool isReleas
IsRelease = isRelease,
};
if (isRelease || !CommercialBuildAvailable) {
proj.SetAndroidSupportedAbis ("armeabi-v7a", "x86", "x86_64");
proj.SetAndroidSupportedAbis ("arm64-v8a", "x86_64");
}
proj.SetDefaultTargetDevice ();
if (Builder.UseDotNet && isRelease) {
Expand Down Expand Up @@ -91,7 +91,7 @@ public void ClassLibraryMainLauncherRuns ([Values (true, false)] bool preloadAss
ProjectName = "MyApp",
};
if (!CommercialBuildAvailable) {
app.SetAndroidSupportedAbis ("armeabi-v7a", "x86", "x86_64");
app.SetAndroidSupportedAbis ("arm64-v8a", "x86_64");
}
app.SetDefaultTargetDevice ();
app.SetProperty ("AndroidEnablePreloadAssemblies", preloadAssemblies.ToString ());
Expand Down Expand Up @@ -192,7 +192,7 @@ public void CustomApplicationRunsWithDebuggerAndBreaks (bool embedAssemblies, st
IsRelease = false,
AndroidFastDeploymentType = fastDevType,
};
proj.SetAndroidSupportedAbis ("armeabi-v7a", "x86", "x86_64");
proj.SetAndroidSupportedAbis ("arm64-v8a", "x86_64");
proj.SetProperty ("EmbedAssembliesIntoApk", embedAssemblies.ToString ());
proj.SetProperty ("AndroidPackageFormat", packageFormat);
proj.SetDefaultTargetDevice ();
Expand Down Expand Up @@ -434,7 +434,7 @@ public Foo ()
app.SetProperty ("AndroidPackageFormat", packageFormat);
app.MainPage = app.MainPage.Replace ("InitializeComponent ();", "InitializeComponent (); new Foo ();");
app.AddReference (lib);
app.SetAndroidSupportedAbis ("armeabi-v7a", "x86", "x86_64");
app.SetAndroidSupportedAbis ("arm64-v8a", "x86", "x86_64");
app.SetProperty (KnownProperties._AndroidAllowDeltaInstall, allowDeltaInstall.ToString ());
app.SetDefaultTargetDevice ();
using (var libBuilder = CreateDllBuilder (Path.Combine (path, lib.ProjectName)))
Expand Down
18 changes: 9 additions & 9 deletions tests/MSBuildDeviceIntegration/Tests/InstallTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public void ReInstallIfUserUninstalled ([Values (false, true)] bool isRelease)
IsRelease = isRelease,
};
if (isRelease) {
proj.SetAndroidSupportedAbis ("armeabi-v7a", "x86", "x86_64");
proj.SetAndroidSupportedAbis ("arm64-v8a", "x86_64");
}
using (var builder = CreateApkBuilder ()) {
Assert.IsTrue (builder.Build (proj));
Expand Down Expand Up @@ -67,7 +67,7 @@ public void InstallAndUnInstall ([Values (false, true)] bool isRelease)
if (isRelease) {
// Set debuggable=true to allow run-as command usage with a release build
proj.AndroidManifest = proj.AndroidManifest.Replace ("<application ", "<application android:debuggable=\"true\" ");
proj.SetAndroidSupportedAbis ("armeabi-v7a", "x86", "x86_64");
proj.SetAndroidSupportedAbis ("arm64-v8a", "x86_64");
}
using (var builder = CreateApkBuilder ()) {
Assert.IsTrue (builder.Build (proj));
Expand Down Expand Up @@ -97,7 +97,7 @@ public void ChangeKeystoreRedeploy ()
var proj = new XamarinAndroidApplicationProject () {
PackageName = "com.xamarin.keytest"
};
proj.SetAndroidSupportedAbis ("armeabi-v7a", "x86", "x86_64");
proj.SetAndroidSupportedAbis ("arm64-v8a", "x86_64");
using (var builder = CreateApkBuilder ()) {
// Use the default debug.keystore XA generates
Assert.IsTrue (builder.Install (proj), "first install should succeed.");
Expand Down Expand Up @@ -128,7 +128,7 @@ public void SwitchConfigurationsShouldRedeploy ()
};
// Set debuggable=true to allow run-as command usage with a release build
proj.AndroidManifest = proj.AndroidManifest.Replace ("<application ", "<application android:debuggable=\"true\" ");
proj.SetAndroidSupportedAbis ("armeabi-v7a", "x86", "x86_64");
proj.SetAndroidSupportedAbis ("arm64-v8a", "x86_64");
proj.SetProperty ("AndroidPackageFormat", "apk");
using (var builder = CreateApkBuilder ()) {
Assert.IsTrue (builder.Build (proj));
Expand Down Expand Up @@ -180,7 +180,7 @@ public void InstallWithoutSharedRuntime ()
} else {
proj.RemoveProperty (proj.ReleaseProperties, "EmbedAssembliesIntoApk");
}
var abis = new [] { "armeabi-v7a", "x86", "x86_64" };
var abis = new [] { "arm64-v8a", "x86_64" };
proj.SetAndroidSupportedAbis (abis);
using (var builder = CreateApkBuilder ()) {
if (RunAdbCommand ("shell pm list packages Mono.Android.DebugRuntime").Trim ().Length != 0)
Expand Down Expand Up @@ -270,7 +270,7 @@ public void ToggleFastDev ()

//Now toggle FastDev to OFF
proj.EmbedAssembliesIntoApk = true;
proj.SetAndroidSupportedAbis ("armeabi-v7a", "x86", "x86_64");
proj.SetAndroidSupportedAbis ("arm64-v8a", "x86_64");

Assert.IsTrue (builder.Install (proj), "Second install should have succeeded.");

Expand Down Expand Up @@ -302,7 +302,7 @@ public void ToggleDebugReleaseWithSigning ([Values ("aab", "apk")] string packag
proj.SetProperty (proj.ReleaseProperties, "AndroidKeyStore", "True");
proj.SetProperty (proj.ReleaseProperties, "AndroidSigningKeyStore", "test.keystore");
proj.SetProperty (proj.ReleaseProperties, "AndroidSigningKeyAlias", "mykey");
proj.SetAndroidSupportedAbis ("armeabi-v7a", "x86", "x86_64");
proj.SetAndroidSupportedAbis ("arm64-v8a", "x86_64");
proj.SetProperty (proj.ReleaseProperties, "AndroidPackageFormat", packageFormat);
proj.SetProperty ("AndroidUseApkSigner", "true");
proj.OtherBuildItems.Add (new BuildItem (BuildActions.None, "test.keystore") {
Expand Down Expand Up @@ -338,7 +338,7 @@ public void LoggingPropsShouldCreateOverrideDirForRelease ()
};
// Set debuggable=true to allow run-as command usage with a release build
proj.AndroidManifest = proj.AndroidManifest.Replace ("<application ", "<application android:debuggable=\"true\" ");
proj.SetAndroidSupportedAbis ("armeabi-v7a", "x86", "x86_64");
proj.SetAndroidSupportedAbis ("arm64-v8a", "x86_64");

string wantedFile;
if (Builder.UseDotNet) {
Expand Down Expand Up @@ -438,7 +438,7 @@ public void TestAndroidStoreKey (bool useApkSigner, bool isRelease, string packa
proj.SetProperty ("AndroidSigningStorePass", password);
proj.SetProperty ("AndroidSigningKeyPass", password);
}
proj.SetAndroidSupportedAbis ("armeabi-v7a", "x86", "x86_64");
proj.SetAndroidSupportedAbis ("arm64-v8a", "x86_64");
proj.SetProperty ("AndroidKeyStore", androidKeyStore);
proj.SetProperty ("AndroidSigningKeyStore", "test.keystore");
proj.SetProperty ("AndroidSigningKeyAlias", "mykey");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ protected override void OnCreate (Bundle bundle)
}
}
}";
proj.SetAndroidSupportedAbis ("armeabi-v7a", "x86", "x86_64");
proj.SetAndroidSupportedAbis ("arm64-v8a", "x86_64");
proj.SetProperty ("EmbedAssembliesIntoApk", embedAssemblies.ToString ());
proj.SetDefaultTargetDevice ();
using (var b = CreateApkBuilder (Path.Combine ("temp", TestName))) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public void SystemApplicationCanInstall ()
WebContent = "https://github.com/aosp-mirror/platform_build/raw/master/target/product/security/platform.x509.pem"
});
proj.AndroidManifest = proj.AndroidManifest.Replace ("<manifest ", "<manifest android:sharedUserId=\"android.uid.system\" ");
proj.SetAndroidSupportedAbis ("armeabi-v7a", "x86", "x86_64");
proj.SetAndroidSupportedAbis ("arm64-v8a", "x86_64");


proj.SetDefaultTargetDevice ();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
</PropertyGroup>

<Import Project="..\..\..\Configuration.props" />

<ItemGroup>
<AndroidAsset Include="..\LinkedAssets\linked_text2.txt">
<Link>Assets\linked_text2.txt</Link>
Expand Down
2 changes: 2 additions & 0 deletions tests/TestRunner.Core/TestRunner.Core.NET.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
</PropertyGroup>

<Import Project="..\..\Configuration.props" />

</Project>
2 changes: 2 additions & 0 deletions tests/TestRunner.NUnit/TestRunner.NUnit.NET.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
</PropertyGroup>

<Import Project="..\..\Configuration.props" />

<ItemGroup>
<ProjectReference Include="..\TestRunner.Core\TestRunner.Core.NET.csproj" />
<ProjectReference Include="..\..\src\Xamarin.Android.NUnitLite\Xamarin.Android.NUnitLite.NET.csproj" />
Expand Down
8 changes: 8 additions & 0 deletions tests/temp-pack/Test.Nuget.Package.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Project Sdk="Xamarin.Legacy.Sdk/0.2.0-alpha4">
<PropertyGroup>
<EnableDefaultItems>False</EnableDefaultItems>
<OutputType>Library</OutputType>
<PackageName>Test.Nuget.Package</PackageName>
<TargetFrameworks>monoandroid13.0</TargetFrameworks>
</PropertyGroup>
</Project>

0 comments on commit 9b74c6e

Please sign in to comment.