Skip to content

Commit

Permalink
[ci] Stop building monodroid in builds from forks (#8444)
Browse files Browse the repository at this point in the history
Removes all usage of provisionator and monodroid build and test steps
when building a PR from a fork.
  • Loading branch information
pjcollins committed Nov 1, 2023
1 parent f1b7113 commit 94670f6
Show file tree
Hide file tree
Showing 22 changed files with 90 additions and 125 deletions.
9 changes: 0 additions & 9 deletions build-tools/automation/azure-pipelines.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@ resources:
endpoint: xamarin

parameters:
- name: provisionatorChannel
type: string
default: latest # Support for launching a build against a Provisionator PR (e.g., pr/[github-account-name]/[pr-number]) as a means to test in-progress Provisionator changes
- name: macTestAgentsUseCleanImages # Test agents we do not need to clean up when finished because they are not reused
default: true

Expand Down Expand Up @@ -83,8 +80,6 @@ variables:
# Stage and Job "display names" are shortened because they are combined to form the name of the corresponding GitHub check.
stages:
- template: yaml-templates/build-macos.yaml
parameters:
provisionatorChannel: ${{ parameters.provisionatorChannel }}

- template: yaml-templates/build-windows.yaml

Expand All @@ -107,7 +102,6 @@ stages:
- template: yaml-templates/setup-test-environment.yaml
parameters:
provisionClassic: false
provisionatorChannel: ${{ parameters.provisionatorChannel }}
installLegacyDotNet: false
restoreNUnitConsole: false
updateMono: false
Expand Down Expand Up @@ -267,8 +261,6 @@ stages:
- template: yaml-templates/setup-ubuntu.yaml

- template: yaml-templates/setup-test-environment.yaml
parameters:
provisionatorChannel: ${{ parameters.provisionatorChannel }}

- task: DownloadPipelineArtifact@2
inputs:
Expand Down Expand Up @@ -347,7 +339,6 @@ stages:
parameters:
xaSourcePath: $(Build.SourcesDirectory)/xamarin-android
provisionClassic: false
provisionatorChannel: ${{ parameters.provisionatorChannel }}
installLegacyDotNet: false
restoreNUnitConsole: false
updateMono: false
Expand Down
2 changes: 0 additions & 2 deletions build-tools/automation/yaml-templates/build-macos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ parameters:
jobName: mac_build_create_installers
jobDisplayName: macOS > Build
nugetArtifactName: $(NuGetArtifactName)
provisionatorChannel: latest
repositoryAlias: self
stageName: mac_build
stageDisplayName: Mac
Expand Down Expand Up @@ -49,7 +48,6 @@ stages:
parameters:
installerArtifactName: ${{ parameters.installerArtifactName }}
nugetArtifactName: ${{ parameters.nugetArtifactName }}
provisionatorChannel: ${{ parameters.provisionatorChannel }}
testAssembliesArtifactName: ${{ parameters.testAssembliesArtifactName }}

- powershell: |
Expand Down
75 changes: 34 additions & 41 deletions build-tools/automation/yaml-templates/commercial-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ parameters:
xaSourcePath: $(System.DefaultWorkingDirectory)/xamarin-android
makeMSBuildArgs: ''
nugetArtifactName: $(NuGetArtifactName)
provisionatorChannel: latest
testAssembliesArtifactName: $(TestAssembliesArtifactName)

steps:
Expand All @@ -19,55 +18,49 @@ steps:
inputs:
forceReinstallCredentialProvider: true

- task: provisionator@2
displayName: Install Xcode
inputs:
github_token: $(GitHub.Token)
provisioning_script: ${{ parameters.xaSourcePath }}/build-tools/provisioning/xcode.csx
provisioning_extra_args: '-v -v -v -v'
env:
PROVISIONATOR_CHANNEL: ${{ parameters.provisionatorChannel }}

- script: make prepare-update-mono CONFIGURATION=$(XA.Build.Configuration) PREPARE_CI=1 PREPARE_AUTOPROVISION=1
workingDirectory: ${{ parameters.xaSourcePath }}
displayName: make prepare-update-mono

# Clone 'monodroid' without submodules
- checkout: monodroid
clean: true
path: s/xamarin-android/external/monodroid

# Tell git to ignore the 'xamarin-android' submodule, which is large and unneeded
- script: git config submodule."external/xamarin-android".update none
workingDirectory: xamarin-android/external/monodroid
displayName: Ignore XA submodule

# Clone 'monodroid' with the rest of the submodules
- checkout: monodroid
submodules: recursive
path: s/xamarin-android/external/monodroid
persistCredentials: true

- script: rm -rf external/monodroid/external/xamarin-android
workingDirectory: ${{ parameters.xaSourcePath }}
displayName: delete legacy xamarin-android submodule

- script: rm -rf external/opentk
workingDirectory: ${{ parameters.xaSourcePath }}
displayName: delete legacy opentk submodule

- script: rm -rf external/sqlite
workingDirectory: ${{ parameters.xaSourcePath }}
displayName: delete legacy sqlite submodule
# Always checkout a second resource to ensure we are using multi-repo checkout behavior
# https://learn.microsoft.com/en-us/azure/devops/pipelines/repos/multi-repo-checkout?view=azure-devops#checkout-path
- checkout: yaml-templates

- ${{ if ne(variables['System.PullRequest.IsFork'], 'True') }}:
- script: >
ls -l /Applications &&
sudo xcode-select --switch /Applications/Xcode_14.2.app &&
xcode-select --print-path
displayName: Use Xcode 14.2
# Clone 'monodroid' without submodules
- checkout: monodroid
clean: true
path: s/xamarin-android/external/monodroid

# Tell git to ignore the 'xamarin-android' submodule, which is large and unneeded
- script: git config submodule."external/xamarin-android".update none
workingDirectory: xamarin-android/external/monodroid
displayName: Ignore XA submodule

# Clone 'monodroid' with the rest of the submodules
- checkout: monodroid
submodules: recursive
path: s/xamarin-android/external/monodroid
persistCredentials: true

- script: rm -rf external/monodroid/external/xamarin-android
workingDirectory: ${{ parameters.xaSourcePath }}
displayName: delete legacy xamarin-android submodule

- script: make prepare-external-git-dependencies PREPARE_CI=1 CONFIGURATION=$(XA.Build.Configuration)
workingDirectory: ${{ parameters.xaSourcePath }}
displayName: make prepare-external-git-dependencies

- task: CodeQL3000Init@0
displayName: CodeQL 3000 Init
condition: and(succeeded(), eq(variables['Codeql.Enabled'], 'true'), eq(variables['Build.SourceBranch'], 'refs/heads/main'))

- script: make prepare-external-git-dependencies PREPARE_CI=1 CONFIGURATION=$(XA.Build.Configuration)
workingDirectory: ${{ parameters.xaSourcePath }}
displayName: make prepare-external-git-dependencies

# Prepare and Build everything
- script: make jenkins CONFIGURATION=$(XA.Build.Configuration) PREPARE_CI=1 PREPARE_AUTOPROVISION=1 MSBUILD_ARGS='${{ parameters.makeMSBuildArgs }}'
workingDirectory: ${{ parameters.xaSourcePath }}
Expand Down
5 changes: 1 addition & 4 deletions build-tools/automation/yaml-templates/run-installer.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
parameters:
provisionExtraArgs: -vv -f
provisionatorChannel: latest

steps:
- task: DownloadPipelineArtifact@2
Expand Down Expand Up @@ -38,6 +37,4 @@ steps:
provisioning_script: $(XA.Provisionator.Args)
provisioning_extra_args: ${{ parameters.provisionExtraArgs }}
# Disabled on Windows on .NET release branches
condition: and(succeeded(), ne(variables['agent.os'], 'Linux'), or(eq(variables.IsRelOrTargetingRel, 'False'), eq(variables['agent.os'], 'Darwin')))
env:
PROVISIONATOR_CHANNEL: ${{ parameters.provisionatorChannel }}
condition: and(succeeded(), ne(variables['System.PullRequest.IsFork'], 'True'), ne(variables['agent.os'], 'Linux'), or(eq(variables.IsRelOrTargetingRel, 'False'), eq(variables['agent.os'], 'Darwin')))
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
parameters:
configuration: $(XA.Build.Configuration)
xaSourcePath: $(System.DefaultWorkingDirectory)
updateVS: false
jdkTestFolder: $(JAVA_HOME_11_X64)
remove_dotnet: false
installTestSlicer: false
Expand All @@ -24,11 +23,6 @@ steps:
clean: true
submodules: recursive

- ${{ if eq(parameters.updateVS, true) }}:
- template: update-vs.yaml
parameters:
xasourcePath: ${{ parameters.xaSourcePath }}

- script: |
echo "##vso[task.setvariable variable=JI_JAVA_HOME]${{ parameters.jdkTestFolder }}"
echo "##vso[task.setvariable variable=DOTNET_TOOL_PATH]${{ parameters.xaSourcePath }}/bin/${{ parameters.configuration }}/dotnet/dotnet"
Expand Down
17 changes: 0 additions & 17 deletions build-tools/automation/yaml-templates/update-vs.yaml

This file was deleted.

3 changes: 0 additions & 3 deletions build-tools/provisioning/vs2019.csx

This file was deleted.

3 changes: 0 additions & 3 deletions build-tools/provisioning/xcode.csx

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public partial class BuildTest : BaseTest
/* debugSymbols */ true ,
/* optimize */ true ,
/* embedassebmlies */ false ,
/* expectedResult */ CommercialBuildAvailable ? "debug" : "release",
/* expectedResult */ TestEnvironment.CommercialBuildAvailable ? "debug" : "release",
},
new object[] {
/* supportedAbi */ "armeabi-v7a",
Expand All @@ -145,7 +145,7 @@ public partial class BuildTest : BaseTest
/* debugSymbols */ false ,
/* optimize */ null ,
/* embedassebmlies */ null ,
/* expectedResult */ CommercialBuildAvailable ? "debug" : "release",
/* expectedResult */ TestEnvironment.CommercialBuildAvailable ? "debug" : "release",
},
};
#pragma warning restore 414
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,12 @@ public void DotNetBuild (string runtimeIdentifiers, bool isRelease, bool aot, bo
Assert.AreEqual (XABuildConfig.AndroidDefaultTargetDotnetApiLevel.ToString(),
uses_sdk.Attribute (ns + "targetSdkVersion").Value);

bool expectEmbeddedAssembies = !(CommercialBuildAvailable && !isRelease);
bool expectEmbeddedAssembies = !(TestEnvironment.CommercialBuildAvailable && !isRelease);
var apkPath = Path.Combine (outputPath, $"{proj.PackageName}-Signed.apk");
FileAssert.Exists (apkPath);
var helper = new ArchiveAssemblyHelper (apkPath, usesAssemblyStore, rids);
helper.AssertContainsEntry ($"assemblies/{proj.ProjectName}.dll", shouldContainEntry: expectEmbeddedAssembies);
helper.AssertContainsEntry ($"assemblies/{proj.ProjectName}.pdb", shouldContainEntry: !CommercialBuildAvailable && !isRelease);
helper.AssertContainsEntry ($"assemblies/{proj.ProjectName}.pdb", shouldContainEntry: !TestEnvironment.CommercialBuildAvailable && !isRelease);
helper.AssertContainsEntry ($"assemblies/Mono.Android.dll", shouldContainEntry: expectEmbeddedAssembies);
helper.AssertContainsEntry ($"assemblies/es/{proj.ProjectName}.resources.dll", shouldContainEntry: expectEmbeddedAssembies);
foreach (var abi in rids.Select (AndroidRidAbiHelper.RuntimeIdentifierToAbi)) {
Expand Down Expand Up @@ -1030,6 +1030,8 @@ public void MicrosoftExtensionsHttp ()
[Test]
public void FastDeploymentDoesNotAddContentProvider ()
{
AssertCommercialBuild ();

var proj = new XamarinAndroidApplicationProject {
EmbedAssembliesIntoApk = false,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -605,11 +605,10 @@ public void DuplicateManagedNames ()
}

[Test]
[Category ("Commercial")]
public void LibraryProjectsShouldSkipGetPrimaryCpuAbi ()
{
if (!CommercialBuildAvailable)
Assert.Ignore ("Not required on Open Source Builds");
AssertCommercialBuild ();

const string target = "_GetPrimaryCpuAbi";
var proj = new XamarinAndroidLibraryProject ();
using (var b = CreateDllBuilder (Path.Combine ("temp", TestName))) {
Expand All @@ -619,10 +618,10 @@ public void LibraryProjectsShouldSkipGetPrimaryCpuAbi ()
}

[Test]
[Category ("Commercial")]
public void LibraryReferenceWithHigherTFVShouldDisplayWarning ([Values (true, false)] bool isRelease)
{
if (!CommercialBuildAvailable || Builder.UseDotNet)

if (!TestEnvironment.CommercialBuildAvailable || Builder.UseDotNet)
Assert.Ignore ("Not applicable to One .NET or single framework OSS builds.");

var libproj = new XamarinAndroidLibraryProject () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,14 @@

namespace Xamarin.Android.Build.Tests
{
[Category ("Node-2"), Category ("Commercial")]
[Category ("Node-2")]
[TestFixture, NonParallelizable]
public class DebuggingTasksTests : BaseTest
{
[OneTimeSetUp]
public void SetUp ()
{
if (!CommercialBuildAvailable)
Assert.Ignore ("DebuggingTasksTests require Xamarin.Android.Build.Debugging.Tasks.");
AssertCommercialBuild ();
}

// https://github.com/xamarin/monodroid/blob/63bbeb076d809c74811a8001d38bf2e9e8672627/tests/msbuild/nunit/Xamarin.Android.Build.Tests/Xamarin.Android.Build.Tests/ResolveXamarinAndroidToolsTests.cs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -694,6 +694,8 @@ public void LinkAssembliesNoShrink ()
[Test]
public void CSProjUserFileChanges ()
{
AssertCommercialBuild ();

var proj = new XamarinAndroidApplicationProject ();
var selectedDevice = "foo";
var csproj_user_file = $"{proj.ProjectName}.csproj.user";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ public void EolFrameworks()
[Test]
public void XA0119 ()
{
AssertCommercialBuild ();

var proj = new XamarinAndroidApplicationProject ();
proj.SetProperty ("_XASupportsFastDev", "True");
proj.SetProperty (proj.DebugProperties, "AndroidLinkMode", "Full");
Expand All @@ -86,6 +88,8 @@ public void XA0119 ()
[Test]
public void XA0119AAB ()
{
AssertCommercialBuild ();

var proj = new XamarinAndroidApplicationProject ();
proj.SetProperty ("_XASupportsFastDev", "True");
proj.SetProperty ("AndroidPackageFormat", "aab");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,14 @@ public class BaseTest

public string Root => Path.GetFullPath (XABuildPaths.TestOutputDirectory);

public static bool CommercialBuildAvailable => TestEnvironment.CommercialBuildAvailable;

/// <summary>
/// Checks if a commercial Xamarin.Android is available
/// * Defaults to Assert.Ignore ()
/// </summary>
public void AssertCommercialBuild (bool fail = false)
{
if (!CommercialBuildAvailable) {
var message = "This test requires a commercial build of Xamarin.Android.";
if (!TestEnvironment.CommercialBuildAvailable) {
var message = $"'{TestName}' requires a commercial build of Xamarin.Android.";
if (fail) {
Assert.Fail (message);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ protected static void RunProjectAndAssert (XamarinAndroidApplicationProject proj
if (Builder.UseDotNet) {
builder.BuildLogFile = logName;
Assert.True (builder.RunTarget (proj, "Run", doNotCleanupOnUpdate: doNotCleanupOnUpdate, parameters: parameters), "Project should have run.");
} else if (CommercialBuildAvailable) {
} else if (TestEnvironment.CommercialBuildAvailable) {
builder.BuildLogFile = logName;
Assert.True (builder.RunTarget (proj, "_Run", doNotCleanupOnUpdate: doNotCleanupOnUpdate, parameters: parameters), "Project should have run.");
} else {
Expand Down
Loading

0 comments on commit 94670f6

Please sign in to comment.