Skip to content

Commit

Permalink
[mono][tests] Parallel AOT compilation of runtime tests on iOS platfo…
Browse files Browse the repository at this point in the history
…rms (#86089)

The Helix payload is generated using the runtime pipeline. Then, the libraries pipeline is utilized to AOT compile and execute the tests on Helix. The build-runtime-tests-and-send-to-helix.yml is updated with the compileOnHelix parameter, which if set, uses the libraries/helix.yml template instead of the runtime send-to-helix-step.yml template. The runtime and libraries pipelines are updated to support AOT compilation of runtime tests on Helix.
  • Loading branch information
kotlarmilos authored Jul 21, 2023
1 parent f016dc4 commit 7531c50
Show file tree
Hide file tree
Showing 12 changed files with 225 additions and 205 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ parameters:
enableMicrobuild: ''
gatherAssetManifests: false
shouldContinueOnError: false
compileOnHelix: false
interpreter: false

steps:
- template: /eng/pipelines/common/templates/runtimes/build-runtime-tests.yml
Expand Down Expand Up @@ -72,49 +74,64 @@ steps:
env:
__MonoToolPrefix: aarch64-linux-gnu-

# Send tests to Helix
- template: /eng/pipelines/common/templates/runtimes/send-to-helix-step.yml
parameters:
displayName: Send tests to Helix
buildConfig: $(buildConfigUpper)
archType: ${{ parameters.archType }}
osGroup: ${{ parameters.osGroup }}
osSubgroup: ${{ parameters.osSubgroup}}
coreClrRepoRoot: $(Build.SourcesDirectory)/src/coreclr
shouldContinueOnError: ${{ parameters.shouldContinueOnError }}
runtimeFlavor: ${{ parameters.runtimeFlavor }}
runtimeVariant: ${{ parameters.runtimeVariant }}
# Checks the value of the compileOnHelix parameter
# and if set invokes libraries pipeline for AOT on Helix
- ${{ if eq(parameters.compileOnHelix, 'true') }}:
- template: /eng/pipelines/libraries/helix.yml
parameters:
osGroup: ${{ parameters.osGroup }}
runtimeFlavor: ${{ parameters.runtimeFlavor }}
archType: ${{ parameters.archType }}
targetRid: ${{ parameters.targetRid }}
buildConfig: ${{ parameters.buildConfig }}
interpreter: ${{ parameters.interpreter }}
testRunNamePrefixSuffix: ${{ parameters.testRunNamePrefixSuffix }}
extraHelixArguments: ${{ parameters.extraHelixArguments }}
helixQueues: ${{ parameters.helixQueues }}
creator: ${{ parameters.creator }}
- ${{ else }}:
- template: /eng/pipelines/common/templates/runtimes/send-to-helix-step.yml
parameters:
displayName: Send tests to Helix
buildConfig: $(buildConfigUpper)
archType: ${{ parameters.archType }}
osGroup: ${{ parameters.osGroup }}
osSubgroup: ${{ parameters.osSubgroup}}
coreClrRepoRoot: $(Build.SourcesDirectory)/src/coreclr
shouldContinueOnError: ${{ parameters.shouldContinueOnError }}
runtimeFlavor: ${{ parameters.runtimeFlavor }}
runtimeVariant: ${{ parameters.runtimeVariant }}

${{ if eq(variables['System.TeamProject'], 'public') }}:
creator: $(Build.DefinitionName)
${{ if eq(variables['System.TeamProject'], 'public') }}:
creator: $(Build.DefinitionName)

helixBuild: $(Build.BuildNumber)
helixSource: $(_HelixSource)
helixBuild: $(Build.BuildNumber)
helixSource: $(_HelixSource)

${{ if ne(parameters.readyToRun, true) }}:
helixType: 'test/functional/cli/'
${{ if ne(parameters.readyToRun, true) }}:
helixType: 'test/functional/cli/'

helixQueues: ${{ parameters.helixQueues }}
helixQueues: ${{ parameters.helixQueues }}

# This tests whether an array is empty
${{ if eq(join('', parameters.helixQueues), '') }}:
condition: false
# This tests whether an array is empty
${{ if eq(join('', parameters.helixQueues), '') }}:
condition: false

publishTestResults: true
publishTestResults: true

timeoutPerTestInMinutes: $(timeoutPerTestInMinutes)
timeoutPerTestCollectionInMinutes: $(timeoutPerTestCollectionInMinutes)
timeoutPerTestInMinutes: $(timeoutPerTestInMinutes)
timeoutPerTestCollectionInMinutes: $(timeoutPerTestCollectionInMinutes)

runCrossGen2: ${{ eq(parameters.readyToRun, true) }}
compositeBuildMode: ${{ parameters.compositeBuildMode }}
runInUnloadableContext: ${{ parameters.runInUnloadableContext }}
nativeAotTest: ${{ parameters.nativeAotTest }}
runCrossGen2: ${{ eq(parameters.readyToRun, true) }}
compositeBuildMode: ${{ parameters.compositeBuildMode }}
runInUnloadableContext: ${{ parameters.runInUnloadableContext }}
nativeAotTest: ${{ parameters.nativeAotTest }}

${{ if eq(variables['System.TeamProject'], 'internal') }}:
# Access token variable for internal project from the
# DotNet-HelixApi-Access variable group
helixAccessToken: $(HelixApiAccessToken)
${{ if eq(variables['System.TeamProject'], 'internal') }}:
# Access token variable for internal project from the
# DotNet-HelixApi-Access variable group
helixAccessToken: $(HelixApiAccessToken)

helixProjectArguments: '$(Build.SourcesDirectory)/src/tests/Common/helixpublishwitharcade.proj'
helixProjectArguments: '$(Build.SourcesDirectory)/src/tests/Common/helixpublishwitharcade.proj'

scenarios: ${{ parameters.scenarios }}
scenarios: ${{ parameters.scenarios }}
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ jobs:
extraHelixArguments: /p:NeedsToBuildAppsOnHelix=true

#
# Build the whole product using Mono for iOS/tvOS and run runtime tests with iOS/tvOS devices
# iOS/tvOS devices
# Build the whole product using Mono and run runtime tests
#
- template: /eng/pipelines/common/platform-matrix.yml
parameters:
Expand Down Expand Up @@ -82,9 +83,11 @@ jobs:
extraStepsTemplate: /eng/pipelines/common/templates/runtimes/build-runtime-tests-and-send-to-helix.yml
extraStepsParameters:
creator: dotnet-bot
# FIXME: Currently, tracing/eventpipe tests are only enabled on iOS platforms. It should be expanded to include all runtime tests. Tracking issue: https://github.com/dotnet/runtime/issues/84254
testBuildArgs: tree tracing/eventpipe
compileOnHelix: true
interpreter: true
testBuildArgs: /p:ArchiveTests=true /p:DevTeamProvisioning=- /p:RunAOTCompilation=true /p:MonoForceInterpreter=true /p:BuildTestsOnHelix=true
testRunNamePrefixSuffix: Mono_$(_BuildConfig)
extraHelixArguments: /p:NeedsToBuildAppsOnHelix=true

#
# Build the whole product using NativeAOT for iOS/tvOS and run runtime tests with iOS/tvOS devices
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,11 @@ jobs:
extraStepsTemplate: /eng/pipelines/common/templates/runtimes/build-runtime-tests-and-send-to-helix.yml
extraStepsParameters:
creator: dotnet-bot
# FIXME: Currently, tracing/eventpipe tests are only enabled on iOS platforms. It should be expanded to include all runtime tests. Tracking issue: https://github.com/dotnet/runtime/issues/84254
testBuildArgs: tree tracing/eventpipe
compileOnHelix: true
interpreter: true
testBuildArgs: /p:ArchiveTests=true /p:DevTeamProvisioning=- /p:RunAOTCompilation=true /p:MonoForceInterpreter=true /p:BuildTestsOnHelix=true
testRunNamePrefixSuffix: Mono_$(_BuildConfig)
extraHelixArguments: /p:NeedsToBuildAppsOnHelix=true

#
# Build the whole product using Native AOT for iOSSimulator/tvOSSimulator and run runtime tests with iOS/tvOS simulators
Expand Down
28 changes: 19 additions & 9 deletions eng/testing/tests.ioslike.targets
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@
<_AOTBuildCommand>$(_AOTBuildCommand) </_AOTBuildCommand>

<_ResetSimulatorSwitch Condition="'$(TargetOS)' == 'iossimulator' or '$(TargetOS)' == 'tvossimulator'">--reset-simulator</_ResetSimulatorSwitch>
<_SignalAppEndSwitch Condition="'$(TargetOS)' == 'ios' or '$(TargetOS)' == 'tvos'">--signal-app-end</_SignalAppEndSwitch>
<_SignalAppEndSwitch>--signal-app-end</_SignalAppEndSwitch>
<_AppleSignCommand Condition="'$(TargetOS)' == 'ios' or '$(TargetOS)' == 'tvos'">sign &quot;$app&quot;</_AppleSignCommand>

<_AfterBuildCommands>
mv $XHARNESS_OUT/AOTBuild.binlog &quot;$HELIX_WORKITEM_UPLOAD_ROOT&quot;
sign &quot;$app&quot;
$(_AppleSignCommand)
xharness apple test --app &quot;$app&quot; --output-directory &quot;$output_directory&quot; --target &quot;$target&quot; --timeout &quot;$timeout&quot; --xcode &quot;$xcode_path&quot; -v --launch-timeout &quot;$launch_timeout&quot; $(_ResetSimulatorSwitch) $(_SignalAppEndSwitch) -- </_AfterBuildCommands>

<RunScriptCommand>$(_AOTBuildCommand) $(_AfterBuildCommands)</RunScriptCommand>
Expand Down Expand Up @@ -61,14 +62,21 @@
</PropertyGroup>

<ItemGroup>
<BundleFiles Condition="'%(AppleAssembliesToBundle._IsNative)' != 'true'"
Include="@(AppleAssembliesToBundle)" TargetDir="publish\%(AppleAssembliesToBundle.RecursiveDir)" />
<BundleFiles Include="@(AppleNativeFilesToBundle)" TargetDir="publish\%(AppleNativeFilesToBundle.RecursiveDir)" />
<BundleFiles Include="$(RuntimeConfigFilePath)" TargetDir="publish" />
<!--
Checks if the directory name "AppleAssembliesToBundle" is equal to the "AssemblyName",
if they match, consider it as the root directory and copy the files there,
otherwise, copy the files to a subdirectory.
-->
<BundleFiles Condition="'%(AppleAssembliesToBundle._IsNative)' != 'true' and ($([System.IO.Path]::GetFileName($([System.IO.Path]::GetDirectoryName('%(AppleAssembliesToBundle.Identity)')))) == '$(AssemblyName)' or '$(IsRuntimeTests)' != 'true')"
Include="@(AppleAssembliesToBundle)" TargetDir="publish" />
<BundleFiles Condition="'%(AppleAssembliesToBundle._IsNative)' != 'true' and $([System.IO.Path]::GetFileName($([System.IO.Path]::GetDirectoryName('%(AppleAssembliesToBundle.Identity)')))) != '$(AssemblyName)' and '$(IsRuntimeTests)' == 'true'"
Include="@(AppleAssembliesToBundle)" TargetDir="publish\$([System.IO.Path]::GetFileName($([System.IO.Path]::GetDirectoryName('%(AppleAssembliesToBundle.Identity)'))))" />

<BundleFiles Include="@(AppleNativeFilesToBundle)" TargetDir="publish" />

<BundleFiles Include="$(MonoProjectRoot)\msbuild\apple\data\*" TargetDir="publish" />
<BundleFiles Include="$(MonoProjectRoot)\msbuild\apple\data\*" TargetDir="publish" />
<ExtraFiles Condition="'%(AppleAssembliesToBundle._IsNative)' == 'true'"
Include="@(AppleAssembliesToBundle)" TargetDir="extraFiles\%(AppleAssembliesToBundle.RecursiveDir)" />
Include="@(AppleAssembliesToBundle)" TargetDir="extraFiles" />
</ItemGroup>

<ItemGroup Condition="'$(DebuggerSupport)' == 'true'">
Expand Down Expand Up @@ -103,6 +111,8 @@
<_ApplePropertyNames Include="HybridGlobalization" />
<_ApplePropertyNames Include="AssemblyName" />
<_ApplePropertyNames Include="MonoEnableLLVM" />
<_ApplePropertyNames Include="UseRuntimeComponents" />
<_ApplePropertyNames Include="IsRuntimeTests" />

<_ApplePropertiesToPass
Include="$(%(_ApplePropertyNames.Identity))"
Expand Down Expand Up @@ -137,7 +147,7 @@

<PropertyGroup>
<Optimized Condition="'$(Configuration)' == 'Release'">true</Optimized>
<MainLibraryFileName Condition="'$(MainLibraryFileName)' == ''">AppleTestRunner.dll</MainLibraryFileName>
<MainLibraryFileName Condition="'$(MainLibraryFileName)' == '' and '$(IsRuntimeTests)' != 'true'">AppleTestRunner.dll</MainLibraryFileName>

<AppleBuildDir>$(PublishDir)</AppleBuildDir>
<AppleBundleDir>$(BundleDir)</AppleBundleDir>
Expand Down
5 changes: 3 additions & 2 deletions eng/testing/tests.mobile.targets
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
<RunScriptOutputPath>$([MSBuild]::NormalizePath('$(BundleDir)', '$(RunScriptOutputName)'))</RunScriptOutputPath>

<PublishingTestsRun>true</PublishingTestsRun>
<PublishTestAsSelfContainedDependsOn>Publish</PublishTestAsSelfContainedDependsOn>
<PublishTestAsSelfContainedDependsOn Condition="'$(PublishTestAsSelfContainedDependsOn)' == ''">Publish</PublishTestAsSelfContainedDependsOn>
<PublishTestAsSelfContainedAfterTargets Condition="'$(PublishTestAsSelfContainedAfterTargets)' == ''">Build</PublishTestAsSelfContainedAfterTargets>

<SkipWorkloadsTestingTargetsImport Condition="'$(SkipWorkloadsTestingTargetsImport)' == ''">true</SkipWorkloadsTestingTargetsImport>
</PropertyGroup>
Expand Down Expand Up @@ -155,7 +156,7 @@

<Target Name="PublishTestAsSelfContained"
Condition="'$(IsCrossTargetingBuild)' != 'true'"
AfterTargets="Build"
AfterTargets="$(PublishTestAsSelfContainedAfterTargets)"
DependsOnTargets="$(PublishTestAsSelfContainedDependsOn);$(BundleTestAppTargets);ArchiveTests" />

<Target Name="PrepareForTestUsingWorkloads"
Expand Down
4 changes: 4 additions & 0 deletions eng/testing/tests.targets
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@
<RunScriptCommands Include="@(PostRunScriptCommands)" />
</ItemGroup>

<PropertyGroup Condition="'$(RunScriptOutputDirectory)' != ''">
<RunScriptOutputPath>$([MSBuild]::NormalizePath('$(RunScriptOutputDirectory)', '$(RunScriptOutputName)'))</RunScriptOutputPath>
</PropertyGroup>

<GenerateRunScript RunCommands="@(RunScriptCommands)"
SetCommands="@(SetScriptCommands)"
TemplatePath="$(RunScriptInputPath)"
Expand Down
2 changes: 1 addition & 1 deletion src/mono/msbuild/apple/build/AppleBuild.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
<!-- iOS/tvOS device + arm64 simulators need to AOT -->
<PropertyGroup Condition="'$(TargetOS)' == 'ios' or '$(TargetOS)' == 'tvos' or (('$(TargetOS)' == 'iossimulator' or '$(TargetOS)' == 'tvossimulator') And '$(TargetArchitecture)' == 'arm64')">
<RunAOTCompilation Condition="'$(RunAOTCompilation)' == ''">true</RunAOTCompilation>
<iOSLikeDedup Condition="'$(iOSLikeDedup)' == ''">true</iOSLikeDedup>
</PropertyGroup>

<!-- iOS/tvOS arm64 simulators do not support JIT, so force interpreter fallback, devices should FullAOT -->
Expand All @@ -11,6 +10,7 @@
</PropertyGroup>

<PropertyGroup>
<iOSLikeDedup Condition="'$(iOSLikeDedup)' == '' and '$(RunAOTCompilation)' == 'true' and '$(MonoForceInterpreter)' != 'true'">true</iOSLikeDedup>
<RuntimeIdentifier>$(TargetOS)-$(TargetArchitecture.ToLowerInvariant())</RuntimeIdentifier>
<UseMonoRuntime>true</UseMonoRuntime>
<UseMonoJustInterp Condition="'$(RunAOTCompilation)' == 'true' and '$(MonoForceInterpreter)' == 'true'">true</UseMonoJustInterp>
Expand Down
4 changes: 4 additions & 0 deletions src/mono/msbuild/apple/build/AppleBuild.targets
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,10 @@

<ItemGroup>
<_AotExcludeAssemblies Include="*System.Runtime.WindowsRuntime.dll" />
<_AssembliesToBundleInternal>
<_InternalForceInterpret Condition="'$(MonoForceInterpreter)' == 'true' and '%(FileName)%(Extension)' != 'System.Private.CoreLib.dll'">true</_InternalForceInterpret>
<_IsNative>false</_IsNative>
</_AssembliesToBundleInternal>

<_AotInputAssemblies Include="@(_AssembliesToBundleInternal)"
Condition="'%(_AssembliesToBundleInternal._InternalForceInterpret)' != 'true'">
Expand Down
7 changes: 6 additions & 1 deletion src/mono/msbuild/apple/data/ProxyProjectForAOTOnHelix.proj
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,15 @@
<AppleBuildDir>$(OriginalPublishDir)</AppleBuildDir>
<AppleBundleDir>$(TestRootDir)AppBundle\</AppleBundleDir>

<MainLibraryFileName>$(OriginalPublishDir)AppleTestRunner.dll</MainLibraryFileName>
<MainLibraryFileName Condition="'$(MainLibraryFileName)' == '' and '$(IsRuntimeTests)' != 'true'">$(OriginalPublishDir)AppleTestRunner.dll</MainLibraryFileName>
<Optimized Condition="'$(Configuration)' != 'Debug'">true</Optimized>
</PropertyGroup>

<PropertyGroup Condition="'$(UseRuntimeComponents)' == 'true'">
<RuntimeComponents>diagnostics_tracing;marshal-ilgen</RuntimeComponents>
<DiagnosticPorts>127.0.0.1:9000,nosuspend,listen</DiagnosticPorts>
</PropertyGroup>

<ItemGroup>
<!-- Figure out if we can support JustInterp mode -->
<AppleAssembliesToBundle Include="$(OriginalPublishDir)**\*.dll" Exclude="$(OriginalPublishDir)\**\*.resources.dll" />
Expand Down
25 changes: 24 additions & 1 deletion src/tests/Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,29 @@
<Import Project="$(MSBuildThisFileDirectory)/Common/disableversioncheck.targets"
Condition="'$(DisableVersionCheckImported)' != 'true'" />

<PropertyGroup Condition="'$(TargetsAppleMobile)' == 'true' and '$(RuntimeFlavor)' == 'mono'">
<OSPlatformConfig>$(TargetOS).AnyCPU.$(Configuration)</OSPlatformConfig>
<TestArchiveRoot>$(ArtifactsDir)helix/</TestArchiveRoot>
<TestArchiveTestsRoot>$(TestArchiveRoot)tests/</TestArchiveTestsRoot>
<TestArchiveTestsDir>$(TestArchiveTestsRoot)$(OSPlatformConfig)/</TestArchiveTestsDir>
<TestArchiveRuntimeRoot>$(TestArchiveRoot)runtime/</TestArchiveRuntimeRoot>

<PublishTestAsSelfContainedDependsOn>BuildMonoiOSApp</PublishTestAsSelfContainedDependsOn>
<PublishTestAsSelfContainedAfterTargets>BuildMonoiOSApp</PublishTestAsSelfContainedAfterTargets>
<BundleTestAppleAppDependsOn>GenerateRunScript</BundleTestAppleAppDependsOn>

<IsRuntimeTests>true</IsRuntimeTests>
</PropertyGroup>

<Import Project="$(RepositoryEngineeringDir)testing\tests.targets"
Condition="'$(TargetsAppleMobile)' == 'true' and '$(RuntimeFlavor)' == 'mono'" />

<Target Name="_SetRunScriptOutputDirectory" Condition="'$(TargetsAppleMobile)' == 'true' and '$(RuntimeFlavor)' == 'mono' and '$(IsRuntimeTests)' == 'true'" BeforeTargets="GenerateRunScript">
<PropertyGroup>
<RunScriptOutputDirectory>$(ArtifactsDir)/tests/coreclr/obj/$(TargetOS).$(Platform).$(Configuration)/Managed/build/iOSApps/$(TestProjectName)/AppBundle</RunScriptOutputDirectory>
</PropertyGroup>
</Target>

<!-- Default priority building values. -->
<PropertyGroup>
<DisableProjectBuild Condition="'$(IsMergedTestRunnerAssembly)' == 'true' and $(BuildAsStandalone)">true</DisableProjectBuild>
Expand Down Expand Up @@ -201,7 +224,7 @@

<!-- There are currently no native project binaries on wasm or Android -->
<Error Text="The native project files are missing in $(NativeProjectOutputFolder) please run build from the root of the repo at least once"
Condition="'@(NativeProjectBinaries)' == '' And '$(TargetOS)' != 'browser' And '$(TargetOS)' != 'android' And '$(TargetOS)' != 'ios' And '$(TargetOS)' != 'iossimulator'"/>
Condition="'@(NativeProjectBinaries)' == '' And '$(TargetOS)' != 'browser' And '$(TargetsMobile)' != 'true'"/>

<Copy
SourceFiles="@(NativeProjectBinaries)"
Expand Down
Loading

0 comments on commit 7531c50

Please sign in to comment.