Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Helix project and supporting targets #4847

Merged
merged 2 commits into from
Jul 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions eng/Helix.CrossTarget.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<Project>
<Target Name="CollectHelixWorkItems"
Outputs="@(HelixWorkItem)">
<ItemGroup>
<_TargetFrameworks Remove="@(_TargetFrameworks)" />
<_TargetFrameworks Include="$(TargetFrameworks)" />
</ItemGroup>
<MSBuild Projects="$(MSBuildProjectFullPath)"
Targets="CollectHelixWorkItems"
Properties="TargetFramework=%(_TargetFrameworks.Identity)"
RemoveProperties="TargetFrameworks">
<Output TaskParameter="TargetOutputs"
ItemName="HelixWorkItem" />
</MSBuild>
</Target>
</Project>
14 changes: 14 additions & 0 deletions eng/Helix.SingleTarget.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<Project>
<ItemGroup>
<!-- Set TEST_DOTNET_ROOT to same as DOTNET_ROOT (which is provided by the dotnet cli correlation payload) -->
<HelixWorkItemPreCommand Include="export TEST_DOTNET_ROOT=${DOTNET_ROOT}"
Condition="'$(IsHelixPosixShell)' == 'true'" />
<HelixWorkItemPreCommand Include="SET TEST_DOTNET_ROOT=%DOTNET_ROOT%"
Condition="'$(IsHelixPosixShell)' != 'true'" />
</ItemGroup>

<!-- TODO: Add Helix work item PreCommands to install Node and Azurite -->

<Target Name="CollectHelixWorkItems"
Outputs="@(HelixWorkItem)" />
</Project>
6 changes: 6 additions & 0 deletions eng/Helix.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<Project>
<PropertyGroup>
<IsHelixPosixShell>true</IsHelixPosixShell>
<IsHelixPosixShell Condition="$(HelixTargetQueue.Contains('windows'))">false</IsHelixPosixShell>
</PropertyGroup>
</Project>
8 changes: 8 additions & 0 deletions eng/Helix.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Project>
<!--
MSBuild uses the IsCrossTargetingBuild property (which checks
that TargetFrameworks is non-empty and that TargetFramework is empty).
-->
<Import Project="$(MSBuildThisFileDirectory)Helix.CrossTarget.targets" Condition="'$(IsCrossTargetingBuild)' == 'true'" />
<Import Project="$(MSBuildThisFileDirectory)Helix.SingleTarget.targets" Condition="'$(IsCrossTargetingBuild)' != 'true'" />
</Project>
164 changes: 164 additions & 0 deletions eng/helix/Helix.proj
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
<Project Sdk="Microsoft.DotNet.Helix.Sdk"
DefaultTargets="Test">

<PropertyGroup>
<HelixConfiguration>$(Configuration)</HelixConfiguration>
<HelixArchitecture>$(BuildArch)</HelixArchitecture>
<UseOpenQueues>true</UseOpenQueues>
<UseOpenQueues Condition="'$(HelixAccessToken)' != ''">false</UseOpenQueues>
<!-- Ensure dotnet correlation payloads match the tested RID -->
<DotNetCliRuntime>$(PackageRid)</DotNetCliRuntime>
</PropertyGroup>

<PropertyGroup Condition="'$(UseOpenQueues)' == 'true'">
<QueueSuffix>.open</QueueSuffix>
<!-- Open queues require a creator to be set. -->
<Creator Condition=" '$(USERNAME)' != '' ">$(USERNAME)</Creator>
jander-msft marked this conversation as resolved.
Show resolved Hide resolved
<Creator Condition=" '$(USER)' != '' ">$(USER)</Creator>
</PropertyGroup>

<PropertyGroup Condition="'$(SYSTEM_COLLECTIONURI)' == 'https://dev.azure.com/dnceng/'">
<HelixSourcePrefix Condition="'$(BUILD_REASON)' == 'Manual'">pr</HelixSourcePrefix>
<HelixSourcePrefix Condition="'$(BUILD_REASON)' == 'PullRequest'">pr</HelixSourcePrefix>
<HelixSourcePrefix Condition="'$(HelixSourcePrefix)' == ''">official</HelixSourcePrefix>
</PropertyGroup>

<PropertyGroup>
<HelixSourcePrefix Condition="'$(HelixSourcePrefix)' == ''">pr</HelixSourcePrefix>
<HelixSource>$(HelixSourcePrefix)/dotnet/dotnet-monitor</HelixSource>
<HelixSource Condition="'$(BUILD_SOURCEBRANCH)' != ''">$(HelixSource)/$(BUILD_SOURCEBRANCH)</HelixSource>
<HelixType>test/binaries/</HelixType>
</PropertyGroup>

<ItemDefinitionGroup>
<HelixAvailableTargetQueue>
<AdditionalProperties>Platform=$(HelixArchitecture)</AdditionalProperties>
</HelixAvailableTargetQueue>
</ItemDefinitionGroup>

<!-- List of all available Helix machines: https://helix.dot.net/ -->

<!-- Windows queues -->
<ItemGroup Condition="$([MSBuild]::IsOSPlatform(Windows))">
<!-- win-arm64 -->
<HelixAvailableTargetQueue Include="windows.11.arm64$(QueueSuffix)"
Condition="'$(HelixArchitecture)' == 'arm64'">
<TestRunName>Windows 11 $(HelixArchitecture) $(HelixConfiguration)</TestRunName>
</HelixAvailableTargetQueue>
<!-- win-x64 -->
<HelixAvailableTargetQueue Include="windows.10.amd64.client$(QueueSuffix)"
Condition="'$(HelixArchitecture)' == 'x64'">
<TestRunName>Windows 10 $(HelixArchitecture) $(HelixConfiguration)</TestRunName>
</HelixAvailableTargetQueue>
<!-- win-x86 -->
<!-- Windows x64 clients can run dotnet x86 natively -->
<HelixAvailableTargetQueue Include="windows.10.amd64.client$(QueueSuffix)"
Condition="'$(HelixArchitecture)' == 'x86'">
<TestRunName>Windows 10 $(HelixArchitecture) $(HelixConfiguration)</TestRunName>
</HelixAvailableTargetQueue>
</ItemGroup>

<!-- Linux gnu libc queues -->
<ItemGroup Condition="$([MSBuild]::IsOSPlatform(Linux)) and !$(PackageRid.Contains(musl))">
<!-- linux-arm64 -->
<HelixAvailableTargetQueue Include="ubuntu.1804.armarch$(QueueSuffix)@mcr.microsoft.com/dotnet-buildtools/prereqs:debian-11-helix-arm64v8"
Condition="'$(HelixArchitecture)' == 'arm64'">
<TestRunName>Debian 11 $(HelixArchitecture) $(HelixConfiguration)</TestRunName>
</HelixAvailableTargetQueue>
<HelixAvailableTargetQueue Include="ubuntu.1804.armarch$(QueueSuffix)@mcr.microsoft.com/dotnet-buildtools/prereqs:ubuntu-18.04-helix-arm64v8"
jander-msft marked this conversation as resolved.
Show resolved Hide resolved
Condition="'$(HelixArchitecture)' == 'arm64'">
<TestRunName>Ubuntu 18.04 $(HelixArchitecture) $(HelixConfiguration)</TestRunName>
</HelixAvailableTargetQueue>
<!-- linux-x64 -->
<HelixAvailableTargetQueue Include="ubuntu.1804.amd64$(QueueSuffix)@mcr.microsoft.com/dotnet-buildtools/prereqs:debian-11-helix-amd64"
Condition="'$(HelixArchitecture)' == 'x64'">
<TestRunName>Debian 11 $(HelixArchitecture) $(HelixConfiguration)</TestRunName>
</HelixAvailableTargetQueue>
<HelixAvailableTargetQueue Include="ubuntu.1804.amd64$(QueueSuffix)@mcr.microsoft.com/dotnet-buildtools/prereqs:cbl-mariner-2.0-helix-amd64"
Condition="'$(HelixArchitecture)' == 'x64'">
<TestRunName>Mariner 2.0 $(HelixArchitecture) $(HelixConfiguration)</TestRunName>
</HelixAvailableTargetQueue>
<HelixAvailableTargetQueue Include="ubuntu.1804.amd64$(QueueSuffix)@mcr.microsoft.com/dotnet-buildtools/prereqs:ubuntu-18.04-helix-amd64"
Condition="'$(HelixArchitecture)' == 'x64'">
<TestRunName>Ubuntu 18.04 $(HelixArchitecture) $(HelixConfiguration)</TestRunName>
</HelixAvailableTargetQueue>
</ItemGroup>

<!-- Linux musl libc queues -->
<ItemGroup Condition="$([MSBuild]::IsOSPlatform(Linux)) and $(PackageRid.Contains(musl))">
<!-- linux-musl-arm64 -->
<HelixAvailableTargetQueue Include="ubuntu.1804.armarch$(QueueSuffix)@mcr.microsoft.com/dotnet-buildtools/prereqs:alpine-3.15-helix-arm64v8"
Condition="'$(HelixArchitecture)' == 'arm64'">
<TestRunName>Alpine 3.15 $(HelixArchitecture) $(HelixConfiguration)</TestRunName>
</HelixAvailableTargetQueue>
<!-- linux-musl-x64 -->
<HelixAvailableTargetQueue Include="ubuntu.1804.amd64$(QueueSuffix)@mcr.microsoft.com/dotnet-buildtools/prereqs:alpine-3.15-helix-amd64"
Condition="'$(HelixArchitecture)' == 'x64'">
<TestRunName>Alpine 3.15 $(HelixArchitecture) $(HelixConfiguration)</TestRunName>
</HelixAvailableTargetQueue>
</ItemGroup>

<!-- OSX queues -->
<ItemGroup Condition="$([MSBuild]::IsOSPlatform(OSX))">
<!-- osx-arm64 -->
<HelixAvailableTargetQueue Include="osx.13.arm64$(QueueSuffix)"
Condition="'$(HelixArchitecture)' == 'arm64'">
<TestRunName>OSX 13 $(HelixArchitecture) $(HelixConfiguration)</TestRunName>
</HelixAvailableTargetQueue>
<!-- osx-x64 -->
<HelixAvailableTargetQueue Include="osx.13.amd64$(QueueSuffix)"
Condition="'$(HelixArchitecture)' == 'x64'">
<TestRunName>OSX 13 $(HelixArchitecture) $(HelixConfiguration)</TestRunName>
</HelixAvailableTargetQueue>
</ItemGroup>

<ItemGroup>
<HelixTargetQueue Include="@(HelixAvailableTargetQueue)">
<AdditionalProperties>%(AdditionalProperties);Configuration=$(HelixConfiguration)</AdditionalProperties>
</HelixTargetQueue>
</ItemGroup>

<!-- Correlation Payload: SDK (to use "dotnet test") -->
<PropertyGroup>
<IncludeDotNetCli>true</IncludeDotNetCli>
<DotNetCliPackageType>sdk</DotNetCliPackageType>
<DotNetCliVersion>$(MicrosoftDotnetSdkInternalVersion)</DotNetCliVersion>
</PropertyGroup>

<!-- Correlation Payload: AspNetCore (these packages also contain corresponding NetCoreApp version) -->
<ItemGroup>
<AdditionalDotNetPackage Include="$(MicrosoftAspNetCoreApp60Version)">
<PackageType>aspnetcore-runtime</PackageType>
</AdditionalDotNetPackage>
<AdditionalDotNetPackage Include="$(MicrosoftAspNetCoreApp70Version)">
<PackageType>aspnetcore-runtime</PackageType>
</AdditionalDotNetPackage>
<AdditionalDotNetPackage Include="$(MicrosoftAspNetCoreApp80Version)">
<PackageType>aspnetcore-runtime</PackageType>
</AdditionalDotNetPackage>
</ItemGroup>

<!-- Correlation Payload: Common Helix payload -->
<ItemGroup>
<HelixCorrelationPayload Include="$(RepoRoot)eng\helix\payload" />
</ItemGroup>

<!-- Correlation Payload: Built binaries -->
<ItemGroup>
<HelixCorrelationPayload Include="$(ArtifactsBinDir)" />
</ItemGroup>

<!-- Collect HelixWorkItems from each project that participates in testing. -->
<Target Name="CollectHelixWorkItems"
BeforeTargets="BeforeTest">
<ItemGroup>
<ProjectWithHelixWorkItems Include="$(RepoRoot)src\Tests\**\*.*proj" />
</ItemGroup>
<MSBuild Projects="@(ProjectWithHelixWorkItems)"
Targets="CollectHelixWorkItems"
SkipNonexistentTargets="true">
<Output TaskParameter="TargetOutputs"
ItemName="HelixWorkItem" />
</MSBuild>
</Target>
</Project>
34 changes: 34 additions & 0 deletions eng/helix/payload/dotnettest.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
@echo off
setlocal

set testAssembly=%1
set configuration=%2
set targetFramework=%3
set architecture=%~4
set timeoutMinutes=%~5

set filterArgs=
if not "%~6" == "" (
set filterArgs=--filter ^"%~6^"
)

set exit_code=0

echo "Start tests..."

dotnet.exe test ^
"%HELIX_CORRELATION_PAYLOAD%\%testAssembly%\%configuration%\%targetFramework%\%testAssembly%.dll" ^
jander-msft marked this conversation as resolved.
Show resolved Hide resolved
--logger:"console;verbosity=normal" ^
--logger:"trx;LogFileName=%testAssembly%_%targetFramework%_%architecture%.trx" ^
--logger:"html;LogFileName=%testAssembly%_%targetFramework%_%architecture%.html" ^
--ResultsDirectory:%HELIX_WORKITEM_UPLOAD_ROOT% ^
--blame "CollectHangDump;TestTimeout=%timeoutMinutes%m" ^
%filterArgs%

if not errorlevel 0 (
set exit_code=%errorlevel%
)

echo "Finished tests; exit code: %exit_code%"

exit /b %exit_code%
31 changes: 31 additions & 0 deletions eng/helix/payload/dotnettest.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/usr/bin/env bash

testAssembly="$1"
configuration="$2"
targetFramework="$3"
architecture="$4"
timeoutMinutes="$5"

filterArgs=""
if [[ ! -z "$6" ]]; then
filterArgs="--filter \"$6\""
fi

exit_code=0

echo "Start tests..."

dotnet test \
"$HELIX_CORRELATION_PAYLOAD/$testAssembly/$configuration/$targetFramework/$testAssembly.dll" \
--logger:"console;verbosity=normal" \
--logger:"trx;LogFileName=${testAssembly}_${targetFramework}_${architecture}.trx" \
--logger:"html;LogFileName=${testAssembly}_${targetFramework}_${architecture}.html" \
--ResultsDirectory:$HELIX_WORKITEM_UPLOAD_ROOT \
--blame "CollectHangDump;TestTimeout=${timeoutMinutes}m" \
$filterArgs

exit_code=$?

echo "Finished tests; exit code: $exit_code"

exit $exit_code
7 changes: 5 additions & 2 deletions src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,15 @@
</PropertyGroup>

<PropertyGroup Condition="'$(ContinuousIntegrationBuild)' == 'true'">
<TestRunnerAdditionalArguments>--blame "CollectHangDump;TestTimeout=15m"</TestRunnerAdditionalArguments>
<TestRunnerTestTimeoutMinutes>15</TestRunnerTestTimeoutMinutes>
<TestRunnerAdditionalArguments>--blame "CollectHangDump;TestTimeout=$(TestRunnerTestTimeoutMinutes)m"</TestRunnerAdditionalArguments>
</PropertyGroup>

<!-- Filter tests based on specified TestGroup -->
<PropertyGroup Condition="'$(TestGroup)' == 'PR'">
<!-- Only run tests for .NET 8 -->
<TestRunnerAdditionalArguments>$(TestRunnerAdditionalArguments) --filter "TargetFrameworkMoniker=Net80"</TestRunnerAdditionalArguments>
<TestRunnerFilterArguments>TargetFrameworkMoniker=Net80</TestRunnerFilterArguments>
<TestRunnerAdditionalArguments>$(TestRunnerAdditionalArguments) --filter "$(TestRunnerFilterArguments)"</TestRunnerAdditionalArguments>
</PropertyGroup>

<ItemGroup>
Expand Down Expand Up @@ -62,5 +64,6 @@
</ItemGroup>

<Import Project="$(RepositoryEngineeringDir)Analyzers.props" />
<Import Project="$(RepositoryEngineeringDir)Helix.props" />
<Import Project="$(RepositoryEngineeringDir)native\naming.props" />
</Project>
2 changes: 2 additions & 0 deletions src/Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
<Project>
<Import Project="Sdk.targets" Sdk="Microsoft.DotNet.Arcade.Sdk" />

<Import Project="$(RepositoryEngineeringDir)Helix.targets" />

<!-- Work around https://github.com/dotnet/sourcelink/issues/572
Remove once we build using an SDK that contains https://github.com/dotnet/sdk/pull/10613 -->
<PropertyGroup>
Expand Down
1 change: 1 addition & 0 deletions src/Tests/Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@
<Target Name="IntegrationTest" DependsOnTargets="$(_GetTestsToRunTarget);RunTests" Condition="'$(IsIntegrationTestProject)' == 'true'" />

<Import Project="$(MSBuildThisFileDirectory)CrossTargeting.targets" Condition="'$(IsCrossTargetingBuild)' == 'true'" />
<Import Project="$(MSBuildThisFileDirectory)Helix.targets" Condition="'$(IsTestProject)' == 'true'" />
</Project>
19 changes: 19 additions & 0 deletions src/Tests/Helix.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<Project>
<PropertyGroup Condition="'$(TargetFramework)' != ''">
<HelixDotnetTestArgs>$(TargetName) $(Configuration) $(TargetFramework) $(Platform) $(TestRunnerTestTimeoutMinutes) $(TestRunnerFilterArguments)</HelixDotnetTestArgs>
<HelixDotnetTestCommand Condition="'$(IsHelixPosixShell)' != 'true'">call %HELIX_CORRELATION_PAYLOAD%\dotnettest.cmd $(HelixDotnetTestArgs)</HelixDotnetTestCommand>

Check warning on line 4 in src/Tests/Helix.targets

View workflow job for this annotation

GitHub Actions / Spellcheck

Unknown word (Posix)
jander-msft marked this conversation as resolved.
Show resolved Hide resolved
<HelixDotnetTestCommand Condition="'$(IsHelixPosixShell)' == 'true'">$HELIX_CORRELATION_PAYLOAD/dotnettest.sh $(HelixDotnetTestArgs)</HelixDotnetTestCommand>

Check warning on line 5 in src/Tests/Helix.targets

View workflow job for this annotation

GitHub Actions / Spellcheck

Unknown word (Posix)
<!-- Add an arbitrary of time to the test timeout so that the work item has extra time to run pre and post commands. -->
<HelixTimeoutMinutes>$([MSBuild]::Add($(TestRunnerTestTimeoutMinutes), 10))</HelixTimeoutMinutes>
</PropertyGroup>

<ItemGroup Condition="'$(TargetFramework)' != ''">
<!-- Helix work item that calls "dotnet test" for the test assembly. -->
<HelixWorkItem Include="$(MSBuildProjectName)-$(TargetFramework)-$(Platform)">
<PreCommands Condition="'$(HelixTargetQueue)' != ''">@(HelixWorkItemPreCommand)</PreCommands>
<Command Condition="'$(HelixTargetQueue)' != ''">$(HelixDotnetTestCommand)</Command>
<PostCommands Condition="'$(HelixTargetQueue)' != ''">@(HelixWorkItemPostCommand)</PostCommands>
<Timeout>00:$(HelixTimeoutMinutes):00</Timeout>
</HelixWorkItem>
</ItemGroup>
</Project>