From a086173a53ea8750fb31878c58a8e4d45d316c82 Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Thu, 23 Jul 2020 13:07:33 -0700 Subject: [PATCH] Revert "Try using helix sdk support directly again (#23585)" This reverts commit 059fe39ae094a5d7076ad3583ef4bd70fa6aed0c. --- eng/helix/content/InstallDotNet.ps1 | 13 ++++++-- eng/helix/content/RunTests/RunTestsOptions.cs | 7 ++++ eng/helix/content/runtests.cmd | 33 +++++++++---------- eng/helix/content/runtests.sh | 26 +++++++++++---- eng/helix/helix.proj | 5 ++- eng/targets/Helix.targets | 4 +-- 6 files changed, 56 insertions(+), 32 deletions(-) diff --git a/eng/helix/content/InstallDotNet.ps1 b/eng/helix/content/InstallDotNet.ps1 index 080a14bd7d51..7e8786643355 100644 --- a/eng/helix/content/InstallDotNet.ps1 +++ b/eng/helix/content/InstallDotNet.ps1 @@ -1,10 +1,12 @@ <# .SYNOPSIS - Installs dotnet runtime using https://dot.net/v1/dotnet-install.ps1 + Installs dotnet sdk and runtime using https://dot.net/v1/dotnet-install.ps1 .DESCRIPTION - Installs dotnet runtime using https://dot.net/v1/dotnet-install.ps1 + Installs dotnet sdk and runtime using https://dot.net/v1/dotnet-install.ps1 .PARAMETER arch The architecture to install. +.PARAMETER sdkVersion + The sdk version to install .PARAMETER runtimeVersion The runtime version to install .PARAMETER installDir @@ -14,6 +16,9 @@ param( [Parameter(Mandatory = $true)] $arch, + [Parameter(Mandatory = $true)] + $sdkVersion, + [Parameter(Mandatory = $true)] $runtimeVersion, @@ -23,6 +28,8 @@ param( & $PSScriptRoot\Download.ps1 "https://dot.net/v1/dotnet-install.ps1" $PSScriptRoot\dotnet-install.ps1 Write-Host "Download of dotnet-install.ps1 complete..." +Write-Host "Installing SDK...& $PSScriptRoot\dotnet-install.ps1 -Architecture $arch -Version $sdkVersion -InstallDir $installDir" +Invoke-Expression "& $PSScriptRoot\dotnet-install.ps1 -Architecture $arch -Version $sdkVersion -InstallDir $installDir" Write-Host "Installing Runtime...& $PSScriptRoot\dotnet-install.ps1 -Architecture $arch -Runtime dotnet -Version $runtimeVersion -InstallDir $installDir" Invoke-Expression "& $PSScriptRoot\dotnet-install.ps1 -Architecture $arch -Runtime dotnet -Version $runtimeVersion -InstallDir $installDir" -Write-Host "InstallDotNet.ps1 complete..." +Write-Host "InstallDotNet.ps1 complete..." \ No newline at end of file diff --git a/eng/helix/content/RunTests/RunTestsOptions.cs b/eng/helix/content/RunTests/RunTestsOptions.cs index e62adef6d501..9e076c970137 100644 --- a/eng/helix/content/RunTests/RunTestsOptions.cs +++ b/eng/helix/content/RunTests/RunTestsOptions.cs @@ -21,6 +21,11 @@ public static RunTestsOptions Parse(string[] args) description: "The test dll to run") { Argument = new Argument(), Required = true }, + new Option( + aliases: new string[] { "--sdk" }, + description: "The version of the sdk being used") + { Argument = new Argument(), Required = true }, + new Option( aliases: new string[] { "--runtime" }, description: "The version of the runtime being used") @@ -65,6 +70,7 @@ public static RunTestsOptions Parse(string[] args) var parseResult = command.Parse(args); var options = new RunTestsOptions(); options.Target = parseResult.ValueForOption("--target"); + options.SdkVersion = parseResult.ValueForOption("--sdk"); options.RuntimeVersion = parseResult.ValueForOption("--runtime"); options.HelixQueue = parseResult.ValueForOption("--queue"); options.Architecture = parseResult.ValueForOption("--arch"); @@ -80,6 +86,7 @@ public static RunTestsOptions Parse(string[] args) } public string Target { get; set;} + public string SdkVersion { get; set;} public string RuntimeVersion { get; set;} public string AspNetRuntime { get; set;} public string AspNetRef { get; set;} diff --git a/eng/helix/content/runtests.cmd b/eng/helix/content/runtests.cmd index 4b3c4dfea6d6..c1b27b1c890c 100644 --- a/eng/helix/content/runtests.cmd +++ b/eng/helix/content/runtests.cmd @@ -4,36 +4,35 @@ setlocal enabledelayedexpansion REM Use '$' as a variable name prefix to avoid MSBuild variable collisions with these variables set $target=%1 -set $runtimeVersion=%2 -set $queue=%3 -set $arch=%4 -set $quarantined=%5 -set $ef=%6 -set $aspnetruntime=%7 -set $aspnetref=%8 -set $helixTimeout=%9 +set $sdkVersion=%2 +set $runtimeVersion=%3 +set $queue=%4 +set $arch=%5 +set $quarantined=%6 +set $ef=%7 +set $aspnetruntime=%8 +set $aspnetref=%9 REM Batch only supports up to 9 arguments using the %# syntax, need to shift to get more +shift +set $helixTimeout=%9 -set DOTNET_ROOT=%HELIX_CORRELATION_PAYLOAD%\dotnet -set DOTNET_HOME=%DOTNET_ROOT% +set DOTNET_HOME=%HELIX_CORRELATION_PAYLOAD%\sdk +set DOTNET_ROOT=%DOTNET_HOME%\%$arch% set DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1 set DOTNET_MULTILEVEL_LOOKUP=0 set DOTNET_CLI_HOME=%HELIX_CORRELATION_PAYLOAD%\home set PATH=%DOTNET_ROOT%;!PATH!;%HELIX_CORRELATION_PAYLOAD%\node\bin echo Set path to: %PATH% -echo "Invoking InstallDotNet.ps1 %$arch% %$runtimeVersion% %DOTNET_ROOT%" -powershell.exe -NoProfile -ExecutionPolicy unrestricted -file InstallDotNet.ps1 %$arch% %$runtimeVersion% %DOTNET_ROOT% - -dotnet --list-sdks -dotnet --list-runtimes +echo "Invoking InstallDotNet.ps1 %$arch% %$sdkVersion% %$runtimeVersion% %DOTNET_ROOT%" +powershell.exe -NoProfile -ExecutionPolicy unrestricted -file InstallDotNet.ps1 %$arch% %$sdkVersion% %$runtimeVersion% %DOTNET_ROOT% set exit_code=0 echo "Restore: dotnet restore RunTests\RunTests.csproj --source https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet5/nuget/v3/index.json --source https://api.nuget.org/v3/index.json --ignore-failed-sources..." dotnet restore RunTests\RunTests.csproj --source https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet5/nuget/v3/index.json --source https://api.nuget.org/v3/index.json --ignore-failed-sources -echo "Running tests: dotnet run --project RunTests\RunTests.csproj -- --target %$target% --runtime %$runtimeVersion% --queue %$queue% --arch %$arch% --quarantined %$quarantined% --ef %$ef% --aspnetruntime %$aspnetruntime% --aspnetref %$aspnetref% --helixTimeout %$helixTimeout%..." -dotnet run --project RunTests\RunTests.csproj -- --target %$target% --runtime %$runtimeVersion% --queue %$queue% --arch %$arch% --quarantined %$quarantined% --ef %$ef% --aspnetruntime %$aspnetruntime% --aspnetref %$aspnetref% --helixTimeout %$helixTimeout% +echo "Running tests: dotnet run --project RunTests\RunTests.csproj -- --target %$target% --sdk %$sdkVersion% --runtime %$runtimeVersion% --queue %$queue% --arch %$arch% --quarantined %$quarantined% --ef %$ef% --aspnetruntime %$aspnetruntime% --aspnetref %$aspnetref% --helixTimeout %$helixTimeout%..." +dotnet run --project RunTests\RunTests.csproj -- --target %$target% --sdk %$sdkVersion% --runtime %$runtimeVersion% --queue %$queue% --arch %$arch% --quarantined %$quarantined% --ef %$ef% --aspnetruntime %$aspnetruntime% --aspnetref %$aspnetref% --helixTimeout %$helixTimeout% if errorlevel neq 0 ( set exit_code=%errorlevel% ) diff --git a/eng/helix/content/runtests.sh b/eng/helix/content/runtests.sh index 583514535f1a..a1bf93270604 100644 --- a/eng/helix/content/runtests.sh +++ b/eng/helix/content/runtests.sh @@ -1,6 +1,7 @@ #!/usr/bin/env bash -dotnet_runtime_version="$2" +dotnet_sdk_version="$2" +dotnet_runtime_version="$3" RESET="\033[0m" RED="\033[0;31m" @@ -10,7 +11,7 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" # Ensures every invocation of dotnet apps uses the same dotnet.exe # Add $random to path to ensure tests don't expect dotnet to be in a particular path -export DOTNET_ROOT="$HELIX_CORRELATION_PAYLOAD/dotnet" +export DOTNET_ROOT="$DIR/.dotnet$RANDOM" # Ensure dotnet comes first on PATH export PATH="$DOTNET_ROOT:$PATH:$DIR/node/bin" @@ -46,6 +47,20 @@ fi # Call "sync" between "chmod" and execution to prevent "text file busy" error in Docker (aufs) chmod +x "dotnet-install.sh"; sync +./dotnet-install.sh --version $dotnet_sdk_version --install-dir "$DOTNET_ROOT" +if [ $? -ne 0 ]; then + sdk_retries=3 + while [ $sdk_retries -gt 0 ]; do + ./dotnet-install.sh --version $dotnet_sdk_version --install-dir "$DOTNET_ROOT" + if [ $? -ne 0 ]; then + let sdk_retries=sdk_retries-1 + echo -e "${YELLOW}Failed to install .NET Core SDK $version. Retries left: $sdk_retries.${RESET}" + else + sdk_retries=0 + fi + done +fi + ./dotnet-install.sh --runtime dotnet --version $dotnet_runtime_version --install-dir "$DOTNET_ROOT" if [ $? -ne 0 ]; then runtime_retries=3 @@ -70,14 +85,11 @@ fi # dontet-install.sh seems to affect the Linux filesystem and causes test flakiness unless we sync the filesystem before running tests sync -$DOTNET_ROOT/dotnet --list-sdks -$DOTNET_ROOT/dotnet --list-runtimes - exit_code=0 echo "Restore: $DOTNET_ROOT/dotnet restore RunTests/RunTests.csproj --source https://api.nuget.org/v3/index.json --ignore-failed-sources..." $DOTNET_ROOT/dotnet restore RunTests/RunTests.csproj --source https://api.nuget.org/v3/index.json --ignore-failed-sources -echo "Running tests: $DOTNET_ROOT/dotnet run --project RunTests/RunTests.csproj -- --target $1 --runtime $2 --queue $3 --arch $4 --quarantined $5 --ef $6 --aspnetruntime $7 --aspnetref $8 --helixTimeout $9..." -$DOTNET_ROOT/dotnet run --project RunTests/RunTests.csproj -- --target $1 --runtime $2 --queue $3 --arch $4 --quarantined $5 --ef $6 --aspnetruntime $7 --aspnetref $8 --helixTimeout $9 +echo "Running tests: $DOTNET_ROOT/dotnet run --project RunTests/RunTests.csproj -- --target $1 --sdk $2 --runtime $3 --queue $4 --arch $5 --quarantined $6 --ef $7 --aspnetruntime $8 --aspnetref $9 --helixTimeout ${10}..." +$DOTNET_ROOT/dotnet run --project RunTests/RunTests.csproj -- --target $1 --sdk $2 --runtime $3 --queue $4 --arch $5 --quarantined $6 --ef $7 --aspnetruntime $8 --aspnetref $9 --helixTimeout ${10} exit_code=$? echo "Finished tests...exit_code=$exit_code" diff --git a/eng/helix/helix.proj b/eng/helix/helix.proj index 3a179a8866b7..250b2fb9b2c8 100644 --- a/eng/helix/helix.proj +++ b/eng/helix/helix.proj @@ -1,4 +1,5 @@ + bin\ $(BaseOutputPath)$(Configuration)\ diff --git a/eng/targets/Helix.targets b/eng/targets/Helix.targets index ad7b35da23b8..0743963a02a9 100644 --- a/eng/targets/Helix.targets +++ b/eng/targets/Helix.targets @@ -117,8 +117,8 @@ Usage: dotnet msbuild /t:Helix src/MyTestProject.csproj $(TargetFileName) @(HelixPreCommand) @(HelixPostCommand) - call runtests.cmd $(TargetFileName) $(MicrosoftNETCoreAppRuntimeVersion) $(_HelixFriendlyNameTargetQueue) $(TargetArchitecture) $(RunQuarantinedTests) $(DotnetEfPackageVersion) Microsoft.AspNetCore.App.Runtime.win-x64.$(AppRuntimeVersion).nupkg Microsoft.AspNetCore.App.Ref.$(AppRuntimeVersion).nupkg $(HelixTimeout) - ./runtests.sh $(TargetFileName) $(MicrosoftNETCoreAppRuntimeVersion) $(_HelixFriendlyNameTargetQueue) $(TargetArchitecture) $(RunQuarantinedTests) $(DotnetEfPackageVersion) Microsoft.AspNetCore.App.Runtime.win-x64.$(AppRuntimeVersion).nupkg Microsoft.AspNetCore.App.Ref.$(AppRuntimeVersion).nupkg $(HelixTimeout) + call runtests.cmd $(TargetFileName) $(NETCoreSdkVersion) $(MicrosoftNETCoreAppRuntimeVersion) $(_HelixFriendlyNameTargetQueue) $(TargetArchitecture) $(RunQuarantinedTests) $(DotnetEfPackageVersion) Microsoft.AspNetCore.App.Runtime.win-x64.$(AppRuntimeVersion).nupkg Microsoft.AspNetCore.App.Ref.$(AppRuntimeVersion).nupkg $(HelixTimeout) + ./runtests.sh $(TargetFileName) $(NETCoreSdkVersion) $(MicrosoftNETCoreAppRuntimeVersion) $(_HelixFriendlyNameTargetQueue) $(TargetArchitecture) $(RunQuarantinedTests) $(DotnetEfPackageVersion) Microsoft.AspNetCore.App.Runtime.win-x64.$(AppRuntimeVersion).nupkg Microsoft.AspNetCore.App.Ref.$(AppRuntimeVersion).nupkg $(HelixTimeout) $(HelixCommand) $(HelixTimeout)