From 45d2c24d4cd01a2bcb738e50514dc86d727c96cf Mon Sep 17 00:00:00 2001
From: Matt Mitchell <mmitche@microsoft.com>
Date: Tue, 17 Aug 2021 10:19:22 -0700
Subject: [PATCH] Fixes for internal runtime usage in build and PRs (#35133)

* Fixes for internal runtime usage in build and PRs
- Don't conditionalize queue adds based on use of open queues.
  In eng/targets/Helix.targets, these are replaced with the non-open versions automatically
- Don't use default error detection for the repo tasks build in source build, as this may
  pick up the error messages from the first attempts to install an internal runtime from a public location (it later succeeds using the private location.)

* Revert _UseOpenHelixQueues != 'true' for VS2019 Preview queues.

* Avoid running non-preview queues on internal daily test

* Sort

* Add some more comments

* Update eng/targets/Helix.Common.props

Co-authored-by: Doug Bunting <6431421+dougbu@users.noreply.github.com>

* Update eng/SourceBuild.props

Co-authored-by: Doug Bunting <6431421+dougbu@users.noreply.github.com>

* Update eng/targets/Helix.Common.props

Co-authored-by: Doug Bunting <6431421+dougbu@users.noreply.github.com>

Co-authored-by: Doug Bunting <6431421+dougbu@users.noreply.github.com>
---
 eng/SourceBuild.props          | 14 +++++++++++++-
 eng/targets/Helix.Common.props | 32 +++++++++++++++++++++++---------
 2 files changed, 36 insertions(+), 10 deletions(-)

diff --git a/eng/SourceBuild.props b/eng/SourceBuild.props
index 5c714e42c4e..f81ea7e5fed 100644
--- a/eng/SourceBuild.props
+++ b/eng/SourceBuild.props
@@ -46,8 +46,20 @@
           Condition="'$(ArcadeInnerBuildFromSource)' == 'true'"
           BeforeTargets="Execute">
 
+    <!-- If the alternative runtime location and key are present, pass those through -->
+    <PropertyGroup>
+      <_AdditionalRepoTaskBuildArgs />
+      <_AdditionalRepoTaskBuildArgs Condition="'$(DotNetRuntimeSourceFeed)' != ''" >$(_AdditionalRepoTaskBuildArgs) --runtimesourcefeed $(DotNetRuntimeSourceFeed)</_AdditionalRepoTaskBuildArgs>
+      <_AdditionalRepoTaskBuildArgs Condition="'$(DotNetRuntimeSourceFeedKey)' != ''" >$(_AdditionalRepoTaskBuildArgs) --runtimesourcefeedkey $(DotNetRuntimeSourceFeedKey)</_AdditionalRepoTaskBuildArgs>
+    </PropertyGroup>
+
+    <!-- Call the build.sh script to build the repo tasks. Set IgnoreStandardErrorWarningFormat
+         to true. This avoids fatal errors, because in internal builds there are usually a few failed installation
+         attempts as the install script walks through potential locations for a runtime.
+         The overall build script will return a proper exit code, but we don't want to pick up the printed error messages. -->
     <Exec
-      Command="./eng/build.sh --only-build-repo-tasks -bl"
+      Command="./eng/build.sh --only-build-repo-tasks -bl $(_AdditionalRepoTaskBuildArgs)"
+      IgnoreStandardErrorWarningFormat="true"
       WorkingDirectory="$(InnerSourceBuildRepoRoot)"
       EnvironmentVariables="@(InnerBuildEnv)" />
   </Target>
diff --git a/eng/targets/Helix.Common.props b/eng/targets/Helix.Common.props
index eaccf9785f8..c49184704b9 100644
--- a/eng/targets/Helix.Common.props
+++ b/eng/targets/Helix.Common.props
@@ -10,41 +10,55 @@
     <HelixAvailablePlatform Include="Windows" />
   </ItemGroup>
 
-  <!-- PR(ci.yaml) required queues -->
-  <ItemGroup Condition="'$(IsRequiredCheck)' == 'true' AND '$(TargetArchitecture)' == 'x64' AND '$(_UseHelixOpenQueues)' == 'true'">
+  <!-- x64 PR(ci.yaml) required queues for internal and public cases -->
+  <ItemGroup Condition="'$(IsRequiredCheck)' == 'true' AND '$(TargetArchitecture)' == 'x64' AND '$(IsHelixDaily)' != 'true'">
     <HelixAvailableTargetQueue Include="Ubuntu.1804.Amd64.Open" Platform="Linux" />
     <HelixAvailableTargetQueue Include="Windows.10.Amd64.Server20H2.Open" Platform="Windows" />
     <HelixAvailableTargetQueue Include="OSX.1014.Amd64.Open" Platform="OSX" />
   </ItemGroup>
   
-  <!-- Quarantined test queues -->
+  <!-- x64 Quarantined-only (quarantined-pr.yml and quarantined-tests.yml) test queues -->
   <ItemGroup Condition="'$(IsRequiredCheck)' == 'true' AND '$(TargetArchitecture)' == 'x64' AND '$(_UseHelixOpenQueues)' == 'true' AND '$(RunQuarantinedTests)' == 'true'">
-    <HelixAvailableTargetQueue Include="(Fedora.34.Amd64.Open)ubuntu.1604.amd64.open@mcr.microsoft.com/dotnet-buildtools/prereqs:fedora-34-helix-20210728124700-4f64125" Platform="Linux" />
+    <HelixAvailableTargetQueue Include="(Fedora.34.Amd64.Open)ubuntu.1804.amd64.open@mcr.microsoft.com/dotnet-buildtools/prereqs:fedora-34-helix-20210728124700-4f64125" Platform="Linux" />
   </ItemGroup>
 
-  <!-- queues for helix-matrix.yml pipeline -->
+  <!-- x64 Queues for public helix-matrix.yml and quarantine pipelines, except in windows-only cases -->
   <ItemGroup Condition="'$(TargetArchitecture)' == 'x64' AND '$(IsHelixDaily)' == 'true' AND '$(_UseHelixOpenQueues)' == 'true' AND '$(IsWindowsOnlyTest)' != 'true'">
-    <HelixAvailableTargetQueue Include="Ubuntu.2004.Amd64.Open" Platform="Linux" />
-    <HelixAvailableTargetQueue Include="OSX.1100.Amd64.Open" Platform="OSX" />
+    <!-- Linux -->
     <HelixAvailableTargetQueue Include="Debian.9.Amd64.Open" Platform="Linux" />
     <HelixAvailableTargetQueue Include="Redhat.7.Amd64.Open" Platform="Linux" />
-    <HelixAvailableTargetQueue Include="(Fedora.34.Amd64.Open)ubuntu.1604.amd64.open@mcr.microsoft.com/dotnet-buildtools/prereqs:fedora-34-helix-20210728124700-4f64125" Platform="Linux" />
+    <HelixAvailableTargetQueue Include="Ubuntu.2004.Amd64.Open" Platform="Linux" />
+    <HelixAvailableTargetQueue Include="Ubuntu.1804.Amd64.Open" Platform="Linux" />
+
+    <!-- Mac -->
+    <HelixAvailableTargetQueue Include="OSX.1014.Amd64.Open" Platform="OSX" />
+    <HelixAvailableTargetQueue Include="OSX.1100.Amd64.Open" Platform="OSX" />
+
+    <!-- Containers -->
+    <HelixAvailableTargetQueue Include="(Fedora.34.Amd64.Open)ubuntu.1804.amd64.open@mcr.microsoft.com/dotnet-buildtools/prereqs:fedora-34-helix-20210728124700-4f64125" Platform="Linux" />
     <HelixAvailableTargetQueue Include="(Alpine.312.Amd64.Open)Ubuntu.1804.Amd64.Open@mcr.microsoft.com/dotnet-buildtools/prereqs:alpine-3.12-helix-20200908125345-56c6673" Platform="Linux" />
     <HelixAvailableTargetQueue Include="(Mariner)Ubuntu.1804.Amd64.Open@mcr.microsoft.com/dotnet-buildtools/prereqs:cbl-mariner-1.0-helix-20210528192219-92bf620" Platform="Linux" />    
   </ItemGroup>
+
+  <!-- x64 Queues for public helix-matrix.yml and quarantine pipelines, Windows cases-->
   <ItemGroup Condition="'$(TargetArchitecture)' == 'x64' AND '$(IsHelixDaily)' == 'true' AND '$(_UseHelixOpenQueues)' == 'true'">
+    <HelixAvailableTargetQueue Include="Windows.10.Amd64.Server20H2.Open" Platform="Windows" />
     <!-- TODO Re-enable Win-7 queue when dotnet restore are fixed. https://github.com/dotnet/aspnetcore/issues/32683 -->
     <!-- <HelixAvailableTargetQueue Include="Windows.7.Amd64.Open" Platform="Windows" /> -->
     <HelixAvailableTargetQueue Include="Windows.81.Amd64.Open" Platform="Windows" />
   </ItemGroup>
+
+  <!-- x64 Queues for internal helix-matrix.yml and quarantine pipelines -->
+  <!-- The preview queue is only available internally, and should only be run on a daily basis -->
   <ItemGroup Condition="'$(TargetArchitecture)' == 'x64' AND '$(IsHelixDaily)' == 'true' AND '$(_UseHelixOpenQueues)' != 'true'">
     <HelixAvailableTargetQueue Include="Windows.10.Amd64.ClientPre.VS2019.Pre" Platform="Windows" />
   </ItemGroup>
 
-  <!-- arm64 queues for helix-matrix.yml pipeline -->
+  <!-- arm64 queues for helix-matrix.yml and quarantine pipeline -->
   <ItemGroup Condition="'$(TargetArchitecture)' == 'arm64' AND '$(IsHelixDaily)' == 'true' AND '$(_UseHelixOpenQueues)' == 'true' AND '$(IsWindowsOnlyTest)' != 'true'">
     <HelixAvailableTargetQueue Include="(Debian.9.Arm64.Open)Ubuntu.1804.Armarch.Open@mcr.microsoft.com/dotnet-buildtools/prereqs:debian-9-helix-arm64v8-a12566d-20190807161036" Platform="Linux" />
   </ItemGroup>
+
   <!-- IIS Express isn't supported on arm64 and most of the IsWindowsOnlyTests depend on it's setup scripts. -->
   <ItemGroup Condition="'$(TargetArchitecture)' == 'arm64' AND '$(IsHelixDaily)' == 'true' AND '$(_UseHelixOpenQueues)' == 'true' AND '$(IsWindowsOnlyTest)' != 'true'">
     <HelixAvailableTargetQueue Include="Windows.10.Arm64v8.Open" Platform="Windows" />
-- 
GitLab