diff --git a/build-tools/automation/azure-pipelines.yaml b/build-tools/automation/azure-pipelines.yaml index f92ca7c1050..40aac661fce 100644 --- a/build-tools/automation/azure-pipelines.yaml +++ b/build-tools/automation/azure-pipelines.yaml @@ -120,11 +120,7 @@ stages: installLegacyDotNet: false restoreNUnitConsole: false updateMono: false - - - template: yaml-templates/run-xaprepare.yaml - parameters: - displayName: install emulator - arguments: --s=EmulatorTestDependencies --android-sdk-platforms="$(DefaultTestSdkPlatforms)" + xaprepareScenario: EmulatorTestDependencies - task: DownloadPipelineArtifact@2 inputs: diff --git a/build-tools/automation/yaml-templates/setup-test-environment.yaml b/build-tools/automation/yaml-templates/setup-test-environment.yaml index c3d6559a93e..234a225945a 100644 --- a/build-tools/automation/yaml-templates/setup-test-environment.yaml +++ b/build-tools/automation/yaml-templates/setup-test-environment.yaml @@ -12,6 +12,7 @@ parameters: androidSdkPlatforms: $(DefaultTestSdkPlatforms) repositoryAlias: 'self' commit: '' + xaprepareScenario: AndroidTestDependencies # Use 'EmulatorTestDependencies' for agents that need the emulator installed steps: @@ -69,7 +70,7 @@ steps: - template: run-xaprepare.yaml parameters: - arguments: --s=AndroidTestDependencies --android-sdk-platforms="${{ parameters.androidSdkPlatforms }}" + arguments: --s=${{ parameters.xaprepareScenario }} --android-sdk-platforms="${{ parameters.androidSdkPlatforms }}" xaSourcePath: ${{ parameters.xaSourcePath }} - ${{ if eq(parameters.restoreNUnitConsole, true) }}: diff --git a/build-tools/automation/yaml-templates/stage-msbuild-emulator-tests.yaml b/build-tools/automation/yaml-templates/stage-msbuild-emulator-tests.yaml index a45bda8d962..322174f2de2 100644 --- a/build-tools/automation/yaml-templates/stage-msbuild-emulator-tests.yaml +++ b/build-tools/automation/yaml-templates/stage-msbuild-emulator-tests.yaml @@ -39,11 +39,7 @@ stages: xaSourcePath: ${{ parameters.xaSourcePath }} repositoryAlias: ${{ parameters.repositoryAlias }} commit: ${{ parameters.commit }} - - - template: run-xaprepare.yaml - parameters: - displayName: install emulator - arguments: --s=EmulatorTestDependencies --android-sdk-platforms="$(DefaultTestSdkPlatforms)" + xaprepareScenario: EmulatorTestDependencies - task: DownloadPipelineArtifact@2 inputs: @@ -96,17 +92,13 @@ stages: xaSourcePath: ${{ parameters.xaSourcePath }} repositoryAlias: ${{ parameters.repositoryAlias }} commit: ${{ parameters.commit }} + xaprepareScenario: EmulatorTestDependencies - template: run-xaprepare.yaml parameters: displayName: install required brew tools and prepare java.interop arguments: --s=Required --auto-provision=yes --auto-provision-uses-sudo=yes - - template: run-xaprepare.yaml - parameters: - displayName: install emulator - arguments: --s=EmulatorTestDependencies --android-sdk-platforms="$(androidSdkPlatforms)" - - script: echo "##vso[task.setvariable variable=Java8SdkDirectory]$JAVA_HOME_8_X64" displayName: set Java8SdkDirectory diff --git a/build-tools/xaprepare/xaprepare/Scenarios/Scenario_AndroidTestDependencies.cs b/build-tools/xaprepare/xaprepare/Scenarios/Scenario_AndroidTestDependencies.cs index 9f745f1510c..28e0c1ba8eb 100644 --- a/build-tools/xaprepare/xaprepare/Scenarios/Scenario_AndroidTestDependencies.cs +++ b/build-tools/xaprepare/xaprepare/Scenarios/Scenario_AndroidTestDependencies.cs @@ -5,16 +5,22 @@ namespace Xamarin.Android.Prepare [Scenario (isDefault: false)] partial class Scenario_AndroidTestDependencies : ScenarioNoStandardEndSteps { + protected virtual AndroidToolchainComponentType AndroidSdkNdkType => AndroidToolchainComponentType.CoreDependency; + public Scenario_AndroidTestDependencies () : base ("AndroidTestDependencies", "Install Android SDK, OpenJDK and .NET preview test dependencies.") {} + protected Scenario_AndroidTestDependencies (string name, string description) + : base (name, description) + {} + protected override void AddSteps (Context context) { Steps.Add (new Step_InstallDotNetPreview ()); Steps.Add (new Step_InstallAdoptOpenJDK8 ()); Steps.Add (new Step_InstallMicrosoftOpenJDK11 ()); - Steps.Add (new Step_Android_SDK_NDK (AndroidToolchainComponentType.CoreDependency)); + Steps.Add (new Step_Android_SDK_NDK (AndroidSdkNdkType)); // disable installation of missing programs... context.SetCondition (KnownConditions.AllowProgramInstallation, false); diff --git a/build-tools/xaprepare/xaprepare/Scenarios/Scenario_EmulatorTestDependencies.cs b/build-tools/xaprepare/xaprepare/Scenarios/Scenario_EmulatorTestDependencies.cs index 006325ce2c7..4710b58ee2b 100644 --- a/build-tools/xaprepare/xaprepare/Scenarios/Scenario_EmulatorTestDependencies.cs +++ b/build-tools/xaprepare/xaprepare/Scenarios/Scenario_EmulatorTestDependencies.cs @@ -3,21 +3,12 @@ namespace Xamarin.Android.Prepare { [Scenario (isDefault: false)] - partial class Scenario_EmulatorTestDependencies : ScenarioNoStandardEndSteps + partial class Scenario_EmulatorTestDependencies : Scenario_AndroidTestDependencies { + protected override AndroidToolchainComponentType AndroidSdkNdkType => AndroidToolchainComponentType.CoreDependency | AndroidToolchainComponentType.EmulatorDependency; + public Scenario_EmulatorTestDependencies () - : base ("EmulatorTestDependencies", "Install Android SDK emulator dependencies.") + : base ("EmulatorTestDependencies", "Install Android SDK (with emulator), OpenJDK, and .NET preview test dependencies.") {} - - protected override void AddSteps (Context context) - { - Steps.Add (new Step_Android_SDK_NDK (AndroidToolchainComponentType.EmulatorDependency)); - - // disable installation of missing programs... - context.SetCondition (KnownConditions.AllowProgramInstallation, false); - - // ...but do not signal an error when any are missing - context.SetCondition (KnownConditions.IgnoreMissingPrograms, true); - } } }