Skip to content

Commit 9f96be4

Browse files
authored
Use new helix sdk/runtime functionality (#31448)
1 parent df128dc commit 9f96be4

File tree

12 files changed

+112
-259
lines changed

12 files changed

+112
-259
lines changed

eng/helix/content/RunTests/Program.cs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,7 @@ static async Task Main(string[] args)
1717
var keepGoing = runner.SetupEnvironment();
1818
if (keepGoing)
1919
{
20-
keepGoing = await runner.InstallDotnetDump();
21-
}
22-
if (keepGoing)
23-
{
24-
keepGoing = await runner.InstallAspNetAppIfNeededAsync();
25-
}
26-
if (keepGoing)
27-
{
28-
keepGoing = runner.InstallAspNetRefIfNeeded();
20+
keepGoing = await runner.InstallDotnetToolsAsync();
2921
}
3022
#if INSTALLPLAYWRIGHT
3123
if (keepGoing)

eng/helix/content/RunTests/TestRunner.cs

Lines changed: 43 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ public bool SetupEnvironment()
4242
var dotnetEFFullPath = Path.Combine(nugetRestore, helixDir, "dotnet-ef.exe");
4343
Console.WriteLine($"Set DotNetEfFullPath: {dotnetEFFullPath}");
4444
EnvironmentVariables.Add("DotNetEfFullPath", dotnetEFFullPath);
45+
var appRuntimePath = $"{Options.DotnetRoot}/shared/Microsoft.AspNetCore.App/{Options.RuntimeVersion}";
46+
Console.WriteLine($"Set ASPNET_RUNTIME_PATH: {appRuntimePath}");
47+
EnvironmentVariables.Add("ASPNET_RUNTIME_PATH", appRuntimePath);
4548

4649
#if INSTALLPLAYWRIGHT
4750
// Playwright will download and look for browsers to this directory
@@ -66,6 +69,8 @@ public bool SetupEnvironment()
6669

6770
DisplayContents(Path.Combine(Options.DotnetRoot, "host", "fxr"));
6871
DisplayContents(Path.Combine(Options.DotnetRoot, "shared", "Microsoft.NETCore.App"));
72+
DisplayContents(Path.Combine(Options.DotnetRoot, "shared", "Microsoft.AspNetCore.App"));
73+
DisplayContents(Path.Combine(Options.DotnetRoot, "packs", "Microsoft.AspNetCore.App.Ref"));
6974

7075
return true;
7176
}
@@ -116,129 +121,57 @@ public async Task<bool> InstallPlaywrightAsync()
116121
}
117122
#endif
118123

119-
public async Task<bool> InstallAspNetAppIfNeededAsync()
124+
public async Task<bool> InstallDotnetToolsAsync()
120125
{
121126
try
122127
{
123-
if (File.Exists(Options.AspNetRuntime))
124-
{
125-
var appRuntimePath = $"{Options.DotnetRoot}/shared/Microsoft.AspNetCore.App/{Options.RuntimeVersion}";
126-
Console.WriteLine($"Creating directory: {appRuntimePath}");
127-
Directory.CreateDirectory(appRuntimePath);
128-
Console.WriteLine($"Set ASPNET_RUNTIME_PATH: {appRuntimePath}");
129-
EnvironmentVariables.Add("ASPNET_RUNTIME_PATH", appRuntimePath);
130-
Console.WriteLine($"Found AspNetRuntime: {Options.AspNetRuntime}, extracting *.txt,json,dll,xml to {appRuntimePath}");
131-
using (var archive = ZipFile.OpenRead(Options.AspNetRuntime))
132-
{
133-
foreach (var entry in archive.Entries)
134-
{
135-
// These are the only extensions that end up in the shared fx directory
136-
if (entry.Name.EndsWith(".txt", StringComparison.OrdinalIgnoreCase) ||
137-
entry.Name.EndsWith(".json", StringComparison.OrdinalIgnoreCase) ||
138-
entry.Name.EndsWith(".dll", StringComparison.OrdinalIgnoreCase) ||
139-
entry.Name.EndsWith(".xml", StringComparison.OrdinalIgnoreCase))
140-
{
141-
entry.ExtractToFile(Path.Combine(appRuntimePath, entry.Name), overwrite: true);
142-
}
143-
}
144-
}
145-
146-
DisplayContents(appRuntimePath);
147-
148-
Console.WriteLine($"Adding current directory to nuget sources: {Options.HELIX_WORKITEM_ROOT}");
149-
150-
await ProcessUtil.RunAsync($"{Options.DotnetRoot}/dotnet",
151-
$"nuget add source {Options.HELIX_WORKITEM_ROOT} --configfile NuGet.config",
152-
environmentVariables: EnvironmentVariables,
153-
outputDataReceived: Console.WriteLine,
154-
errorDataReceived: Console.Error.WriteLine,
155-
throwOnError: false,
156-
cancellationToken: new CancellationTokenSource(TimeSpan.FromMinutes(2)).Token);
157-
158-
// Write nuget sources to console, useful for debugging purposes
159-
await ProcessUtil.RunAsync($"{Options.DotnetRoot}/dotnet",
160-
"nuget list source",
161-
environmentVariables: EnvironmentVariables,
162-
outputDataReceived: Console.WriteLine,
163-
errorDataReceived: Console.Error.WriteLine,
164-
throwOnError: false,
165-
cancellationToken: new CancellationTokenSource(TimeSpan.FromMinutes(2)).Token);
166-
167-
await ProcessUtil.RunAsync($"{Options.DotnetRoot}/dotnet",
168-
$"tool install dotnet-ef --version {Options.EfVersion} --tool-path {Options.HELIX_WORKITEM_ROOT}",
169-
environmentVariables: EnvironmentVariables,
170-
outputDataReceived: Console.WriteLine,
171-
errorDataReceived: Console.Error.WriteLine,
172-
throwOnError: false,
173-
cancellationToken: new CancellationTokenSource(TimeSpan.FromMinutes(2)).Token);
128+
Console.WriteLine($"Adding current directory to nuget sources: {Options.HELIX_WORKITEM_ROOT}");
174129

175-
await ProcessUtil.RunAsync($"{Options.DotnetRoot}/dotnet",
176-
$"tool install dotnet-serve --tool-path {Options.HELIX_WORKITEM_ROOT}",
177-
environmentVariables: EnvironmentVariables,
178-
outputDataReceived: Console.WriteLine,
179-
errorDataReceived: Console.Error.WriteLine,
180-
throwOnError: false,
181-
cancellationToken: new CancellationTokenSource(TimeSpan.FromMinutes(2)).Token);
182-
183-
// ';' is the path separator on Windows, and ':' on Unix
184-
Options.Path += OperatingSystem.IsWindows() ? ";" : ":";
185-
Options.Path += $"{Environment.GetEnvironmentVariable("DOTNET_CLI_HOME")}/.dotnet/tools";
186-
EnvironmentVariables["PATH"] = Options.Path;
187-
}
188-
else
189-
{
190-
Console.WriteLine($"No AspNetRuntime found: {Options.AspNetRuntime}, skipping...");
191-
}
192-
return true;
193-
}
194-
catch (Exception e)
195-
{
196-
Console.WriteLine($"Exception in InstallAspNetAppIfNeeded: {e.ToString()}");
197-
return false;
198-
}
199-
}
130+
await ProcessUtil.RunAsync($"{Options.DotnetRoot}/dotnet",
131+
$"nuget add source {Options.HELIX_WORKITEM_ROOT} --configfile NuGet.config",
132+
environmentVariables: EnvironmentVariables,
133+
outputDataReceived: Console.WriteLine,
134+
errorDataReceived: Console.Error.WriteLine,
135+
throwOnError: false,
136+
cancellationToken: new CancellationTokenSource(TimeSpan.FromMinutes(2)).Token);
200137

201-
public bool InstallAspNetRefIfNeeded()
202-
{
203-
try
204-
{
205-
if (File.Exists(Options.AspNetRef))
206-
{
207-
var refPath = $"{Options.DotnetRoot}/packs/Microsoft.AspNetCore.App.Ref/{Options.RuntimeVersion}";
208-
Console.WriteLine($"Found AspNetRef: {Options.AspNetRef}, extracting to {refPath}");
209-
ZipFile.ExtractToDirectory(Options.AspNetRef, refPath);
138+
// Write nuget sources to console, useful for debugging purposes
139+
await ProcessUtil.RunAsync($"{Options.DotnetRoot}/dotnet",
140+
"nuget list source",
141+
environmentVariables: EnvironmentVariables,
142+
outputDataReceived: Console.WriteLine,
143+
errorDataReceived: Console.Error.WriteLine,
144+
throwOnError: false,
145+
cancellationToken: new CancellationTokenSource(TimeSpan.FromMinutes(2)).Token);
210146

211-
DisplayContents(refPath);
212-
}
213-
else
214-
{
215-
Console.WriteLine($"No AspNetRef found: {Options.AspNetRef}, skipping...");
216-
}
217-
return true;
218-
}
219-
catch (Exception e)
220-
{
221-
Console.WriteLine($"Exception in InstallAspNetRefIfNeeded: {e.ToString()}");
222-
return false;
223-
}
224-
}
147+
await ProcessUtil.RunAsync($"{Options.DotnetRoot}/dotnet",
148+
$"tool install dotnet-ef --version {Options.EfVersion} --tool-path {Options.HELIX_WORKITEM_ROOT}",
149+
environmentVariables: EnvironmentVariables,
150+
outputDataReceived: Console.WriteLine,
151+
errorDataReceived: Console.Error.WriteLine,
152+
throwOnError: false,
153+
cancellationToken: new CancellationTokenSource(TimeSpan.FromMinutes(2)).Token);
225154

226-
public async Task<bool> InstallDotnetDump()
227-
{
228-
try
229-
{
230155
await ProcessUtil.RunAsync($"{Options.DotnetRoot}/dotnet",
231-
$"tool install dotnet-dump --tool-path {Options.HELIX_WORKITEM_ROOT} --version 5.0.0-*",
232-
environmentVariables: EnvironmentVariables,
233-
outputDataReceived: Console.WriteLine,
234-
errorDataReceived: Console.Error.WriteLine,
235-
throwOnError: false);
156+
$"tool install dotnet-serve --tool-path {Options.HELIX_WORKITEM_ROOT}",
157+
environmentVariables: EnvironmentVariables,
158+
outputDataReceived: Console.WriteLine,
159+
errorDataReceived: Console.Error.WriteLine,
160+
throwOnError: false,
161+
cancellationToken: new CancellationTokenSource(TimeSpan.FromMinutes(2)).Token);
162+
163+
await ProcessUtil.RunAsync($"{Options.DotnetRoot}/dotnet",
164+
$"tool install dotnet-dump --tool-path {Options.HELIX_WORKITEM_ROOT} --version 5.0.0-*",
165+
environmentVariables: EnvironmentVariables,
166+
outputDataReceived: Console.WriteLine,
167+
errorDataReceived: Console.Error.WriteLine,
168+
throwOnError: false);
236169

237170
return true;
238171
}
239172
catch (Exception e)
240173
{
241-
Console.WriteLine($"Exception in InstallDotnetDump: {e}");
174+
Console.WriteLine($"Exception in InstallDotnetTools: {e}");
242175
return false;
243176
}
244177
}

eng/helix/content/runtests.ps1

Lines changed: 1 addition & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
param(
22
[string]$Target,
3-
[string]$SdkVersion,
4-
[string]$RuntimeVersion,
53
[string]$AspRuntimeVersion,
64
[string]$Queue,
75
[string]$Arch,
86
[string]$Quarantined,
97
[string]$EF,
108
[string]$HelixTimeout,
11-
[string]$InstallPlaywright,
12-
[string]$FeedCred
9+
[string]$InstallPlaywright
1310
)
1411

1512
$env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE = 1
@@ -21,67 +18,6 @@ $env:PLAYWRIGHT_DRIVER_PATH = "$currentDirectory\.playwright\win-x64\native\play
2118

2219
$envPath = "$env:PATH;$env:HELIX_CORRELATION_PAYLOAD\node\bin"
2320

24-
function InvokeInstallDotnet([string]$command) {
25-
Write-Host "InstallDotNet $command"
26-
27-
$timeoutSeconds = 180
28-
$proc = Start-Process -filePath powershell.exe -ArgumentList "-noLogo -NoProfile -ExecutionPolicy unrestricted -command `"$command`"" -NoNewWindow -PassThru
29-
30-
$proc | Wait-Process -Timeout $timeoutSeconds
31-
$exitCode = $proc.ExitCode
32-
33-
if ($exitCode -eq 0) {
34-
Write-Host "InstallDotNet $command completed successfully"
35-
return $true
36-
}
37-
elseif ([string]::IsNullOrWhiteSpace($exitCode)) {
38-
Write-Warning "InstallDotNet $command timed out after $timeoutSeconds seconds"
39-
}
40-
else {
41-
Write-Warning "InstallDotNet $command failed with exit code $exitCode"
42-
}
43-
44-
$proc | Stop-Process -Force
45-
46-
return $false
47-
}
48-
49-
function InstallDotnetSDKAndRuntime([string]$Feed, [string]$FeedCredParam) {
50-
foreach ($i in 1..5) {
51-
$random = Get-Random -Maximum 1024
52-
$env:DOTNET_HOME = Join-Path $currentDirectory "sdk$random"
53-
$env:DOTNET_ROOT = Join-Path $env:DOTNET_HOME $Arch
54-
$env:DOTNET_CLI_HOME = Join-Path $currentDirectory "home$random"
55-
$env:PATH = "$env:DOTNET_ROOT;$envPath"
56-
57-
Write-Host "Set PATH to: $env:PATH"
58-
59-
$success = InvokeInstallDotnet ". eng\common\tools.ps1; InstallDotNet $env:DOTNET_ROOT $SdkVersion $Arch `'`' `$true `'$Feed`' `'$FeedCredParam`' `$true"
60-
if (!$success) {
61-
Write-Host "Retrying..."
62-
continue
63-
}
64-
65-
$success = InvokeInstallDotnet ". eng\common\tools.ps1; InstallDotNet $env:DOTNET_ROOT $RuntimeVersion $Arch dotnet `$true `'$Feed`' `'$FeedCredParam`' `$true"
66-
67-
if (!$success) {
68-
Write-Host "Retrying..."
69-
continue
70-
}
71-
72-
return
73-
}
74-
75-
Write-Error "InstallDotNet $command exceeded retry limit"
76-
exit 1
77-
}
78-
79-
if ([string]::IsNullOrEmpty($FeedCred)) {
80-
InstallDotnetSDKAndRuntime
81-
} else {
82-
InstallDotnetSDKAndRuntime "https://dotnetclimsrc.blob.core.windows.net/dotnet" $FeedCred
83-
}
84-
8521
Write-Host "Restore: dotnet restore RunTests\RunTests.csproj --ignore-failed-sources"
8622
dotnet restore RunTests\RunTests.csproj --ignore-failed-sources
8723

eng/helix/content/runtests.sh

Lines changed: 8 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,20 @@
11
#!/usr/bin/env bash
22

3-
dotnet_sdk_version="$2"
4-
dotnet_runtime_version="$3"
5-
helixQueue="$5"
6-
installPlaywright="${10}"
3+
helixQueue="$3"
4+
installPlaywright="$8"
75

86
RESET="\033[0m"
97
RED="\033[0;31m"
108
YELLOW="\033[0;33m"
119
MAGENTA="\033[0;95m"
1210
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
1311

14-
# Ensures every invocation of dotnet apps uses the same dotnet.exe
15-
# Add $random to path to ensure tests don't expect dotnet to be in a particular path
16-
export DOTNET_ROOT="$DIR/.dotnet$RANDOM"
17-
18-
# Ensure dotnet comes first on PATH
19-
export PATH="$DOTNET_ROOT:$PATH:$DIR/node/bin"
20-
2112
# Prevent fallback to global .NET locations. This ensures our tests use the shared frameworks we specify and don't rollforward to something else that might be installed on the machine
2213
export DOTNET_MULTILEVEL_LOOKUP=0
23-
24-
# Avoid contaminating userprofiles
25-
# Add $random to path to ensure tests don't expect home to be in a particular path
26-
export DOTNET_CLI_HOME="$DIR/.home$RANDOM"
27-
2814
export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
2915

16+
export PATH="$PATH:$DIR/node/bin"
17+
3018
# Set playwright stuff
3119
export PLAYWRIGHT_BROWSERS_PATH="$DIR/ms-playwright"
3220
if [[ "$helixQueue" == *"OSX"* ]]; then
@@ -74,39 +62,6 @@ RED="\033[0;31m"
7462
YELLOW="\033[0;33m"
7563
MAGENTA="\033[0;95m"
7664

77-
. eng/common/tools.sh
78-
79-
if [[ -z "${11:-}" ]]; then
80-
echo "InstallDotNet $DOTNET_ROOT $dotnet_sdk_version '' '' true"
81-
InstallDotNet $DOTNET_ROOT $dotnet_sdk_version "" "" true || {
82-
exit_code=$?
83-
Write-PipelineTelemetryError -Category 'InitializeToolset' -Message "dotnet-install.sh failed (exit code '$exit_code')." >&2
84-
ExitWithExitCode $exit_code
85-
}
86-
echo
87-
88-
echo "InstallDotNet $DOTNET_ROOT $dotnet_runtime_version '' dotnet true"
89-
InstallDotNet $DOTNET_ROOT $dotnet_runtime_version "" dotnet true || {
90-
exit_code=$?
91-
Write-PipelineTelemetryError -Category 'InitializeToolset' -Message "dotnet-install.sh failed (exit code '$exit_code')." >&2
92-
ExitWithExitCode $exit_code
93-
}
94-
else
95-
echo "InstallDotNet $DOTNET_ROOT $dotnet_sdk_version '' '' true https://dotnetclimsrc.blob.core.windows.net/dotnet ..."
96-
InstallDotNet $DOTNET_ROOT $dotnet_sdk_version "" "" true https://dotnetclimsrc.blob.core.windows.net/dotnet ${11} || {
97-
exit_code=$?
98-
Write-PipelineTelemetryError -Category 'InitializeToolset' -Message "dotnet-install.sh failed (exit code '$exit_code')." >&2
99-
ExitWithExitCode $exit_code
100-
}
101-
echo
102-
103-
echo "InstallDotNet $DOTNET_ROOT $dotnet_runtime_version '' dotnet true https://dotnetclimsrc.blob.core.windows.net/dotnet ..."
104-
InstallDotNet $DOTNET_ROOT $dotnet_runtime_version "" dotnet true https://dotnetclimsrc.blob.core.windows.net/dotnet ${11} || {
105-
exit_code=$?
106-
Write-PipelineTelemetryError -Category 'InitializeToolset' -Message "dotnet-install.sh failed (exit code '$exit_code')." >&2
107-
ExitWithExitCode $exit_code
108-
}
109-
fi
11065
echo
11166

11267
if [ -e /proc/self/coredump_filter ]; then
@@ -121,15 +76,12 @@ sync
12176

12277
exit_code=0
12378

124-
echo "Restore: $DOTNET_ROOT/dotnet restore RunTests/RunTests.csproj --ignore-failed-sources"
125-
$DOTNET_ROOT/dotnet restore RunTests/RunTests.csproj --ignore-failed-sources
79+
echo "Restore: dotnet restore RunTests/RunTests.csproj --ignore-failed-sources"
80+
dotnet restore RunTests/RunTests.csproj --ignore-failed-sources
12681

127-
echo "Running tests: $DOTNET_ROOT/dotnet run --no-restore --project RunTests/RunTests.csproj -- --target $1 --runtime $4 --queue $helixQueue --arch $6 --quarantined $7 --ef $8 --helixTimeout $9"
128-
$DOTNET_ROOT/dotnet run --no-restore --project RunTests/RunTests.csproj -- --target $1 --runtime $4 --queue $helixQueue --arch $6 --quarantined $7 --ef $8 --helixTimeout $9
82+
echo "Running tests: dotnet run --no-restore --project RunTests/RunTests.csproj -- --target $1 --runtime $2 --queue $helixQueue --arch $4 --quarantined $5 --ef $6 --helixTimeout $7"
83+
dotnet run --no-restore --project RunTests/RunTests.csproj -- --target $1 --runtime $2 --queue $helixQueue --arch $4 --quarantined $5 --ef $6 --helixTimeout $7
12984
exit_code=$?
13085
echo "Finished tests...exit_code=$exit_code"
13186

132-
# dotnet-install.sh leaves the temporary SDK archive on the helix machine which slowly fills the disk, we'll be nice and clean it until the script fixes the issue
133-
rm -r -f ${TMPDIR:-/tmp}/dotnet.*
134-
13587
exit $exit_code

0 commit comments

Comments
 (0)