Skip to content

Commit a104f9d

Browse files
authored
helix + pw + linux/osx (#30676)
1 parent 8b4d24e commit a104f9d

File tree

14 files changed

+95
-31
lines changed

14 files changed

+95
-31
lines changed

eng/Versions.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@
242242
<NewtonsoftJsonBsonVersion>1.0.2</NewtonsoftJsonBsonVersion>
243243
<NewtonsoftJsonVersion>12.0.2</NewtonsoftJsonVersion>
244244
<NSwagApiDescriptionClientVersion>13.0.4</NSwagApiDescriptionClientVersion>
245-
<PlaywrightSharpVersion>0.180.0</PlaywrightSharpVersion>
245+
<PlaywrightSharpVersion>0.191.1</PlaywrightSharpVersion>
246246
<PollyExtensionsHttpVersion>3.0.0</PollyExtensionsHttpVersion>
247247
<PollyVersion>7.1.0</PollyVersion>
248248
<SeleniumSupportVersion>4.0.0-beta1</SeleniumSupportVersion>

eng/helix/content/RunTests/Program.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ static async Task Main(string[] args)
3232
{
3333
keepGoing = await runner.InstallPlaywrightAsync();
3434
}
35+
#else
36+
Console.WriteLine("Playwright install skipped.");
3537
#endif
3638

3739
runner.DisplayContents();

eng/helix/content/RunTests/RunTests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@
88

99
<ItemGroup>
1010
<PackageReference Include="System.CommandLine" Version="2.0.0-beta1.20158.1" />
11-
<PackageReference Condition=" '$(InstallPlaywright)' == 'true' " Include="PlaywrightSharp" Version="0.180.0" />
11+
<PackageReference Condition=" '$(InstallPlaywright)' == 'true' " Include="PlaywrightSharp" Version="0.191.1" />
1212
</ItemGroup>
1313
</Project>

eng/helix/content/RunTests/TestRunner.cs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,16 @@ public bool SetupEnvironment()
4545

4646
#if INSTALLPLAYWRIGHT
4747
// Playwright will download and look for browsers to this directory
48-
var playwrightBrowsers = Path.Combine(helixDir, "ms-playwright");
48+
var playwrightBrowsers = Environment.GetEnvironmentVariable("PLAYWRIGHT_BROWSERS_PATH");
4949
Console.WriteLine($"Setting PLAYWRIGHT_BROWSERS_PATH: {playwrightBrowsers}");
5050
EnvironmentVariables.Add("PLAYWRIGHT_BROWSERS_PATH", playwrightBrowsers);
51+
var playrightDriver = Environment.GetEnvironmentVariable("PLAYWRIGHT_DRIVER_PATH");
52+
Console.WriteLine($"Setting PLAYWRIGHT_DRIVER_PATH: {playrightDriver}");
53+
EnvironmentVariables.Add("PLAYWRIGHT_DRIVER_PATH", playrightDriver);
54+
#else
55+
Console.WriteLine($"Skipping setting PLAYWRIGHT_BROWSERS_PATH");
5156
#endif
52-
57+
5358
Console.WriteLine($"Creating nuget restore directory: {nugetRestore}");
5459
Directory.CreateDirectory(nugetRestore);
5560

@@ -95,8 +100,9 @@ public async Task<bool> InstallPlaywrightAsync()
95100
{
96101
try
97102
{
98-
Console.WriteLine($"Installing Playwright to {EnvironmentVariables["PLAYWRIGHT_BROWSERS_PATH"]}");
99-
await Playwright.InstallAsync(EnvironmentVariables["PLAYWRIGHT_BROWSERS_PATH"]);
103+
Console.WriteLine($"Installing Playwright to Browsers: {Environment.GetEnvironmentVariable("PLAYWRIGHT_BROWSERS_PATH")} Driver: {Environment.GetEnvironmentVariable("PLAYWRIGHT_DRIVER_PATH")}");
104+
await Playwright.InstallAsync(Environment.GetEnvironmentVariable("PLAYWRIGHT_BROWSERS_PATH"), Environment.GetEnvironmentVariable("PLAYWRIGHT_DRIVER_PATH"));
105+
DisplayContents(Environment.GetEnvironmentVariable("PLAYWRIGHT_BROWSERS_PATH"));
100106
return true;
101107
}
102108
catch (Exception e)
@@ -106,7 +112,7 @@ public async Task<bool> InstallPlaywrightAsync()
106112
}
107113
}
108114
#endif
109-
115+
110116
public async Task<bool> InstallAspNetAppIfNeededAsync()
111117
{
112118
try
@@ -170,7 +176,7 @@ await ProcessUtil.RunAsync($"{Options.DotnetRoot}/dotnet",
170176
errorDataReceived: Console.Error.WriteLine,
171177
throwOnError: false,
172178
cancellationToken: new CancellationTokenSource(TimeSpan.FromMinutes(2)).Token);
173-
179+
174180
// ';' is the path separator on Windows, and ':' on Unix
175181
Options.Path += OperatingSystem.IsWindows() ? ";" : ":";
176182
Options.Path += $"{Environment.GetEnvironmentVariable("DOTNET_CLI_HOME")}/.dotnet/tools";
@@ -341,9 +347,7 @@ public void UploadResults()
341347
// Combine the directory name + log name for the copied log file name to avoid overwriting duplicate test names in different test projects
342348
var logName = $"{Path.GetFileName(Path.GetDirectoryName(file))}_{Path.GetFileName(file)}";
343349
Console.WriteLine($"Copying: {file} to {Path.Combine(HELIX_WORKITEM_UPLOAD_ROOT, logName)}");
344-
// Need to copy to HELIX_WORKITEM_UPLOAD_ROOT and HELIX_WORKITEM_UPLOAD_ROOT/../ in order for Azure Devops attachments to link properly and for Helix to store the logs
345350
File.Copy(file, Path.Combine(HELIX_WORKITEM_UPLOAD_ROOT, logName));
346-
File.Copy(file, Path.Combine(HELIX_WORKITEM_UPLOAD_ROOT, "..", logName));
347351
}
348352
}
349353
else
@@ -357,9 +361,7 @@ public void UploadResults()
357361
{
358362
var fileName = Path.GetFileName(file);
359363
Console.WriteLine($"Copying: {file} to {Path.Combine(HELIX_WORKITEM_UPLOAD_ROOT, fileName)}");
360-
// Need to copy to HELIX_WORKITEM_UPLOAD_ROOT and HELIX_WORKITEM_UPLOAD_ROOT/../ in order for Azure Devops attachments to link properly and for Helix to store the logs
361364
File.Copy(file, Path.Combine(HELIX_WORKITEM_UPLOAD_ROOT, fileName));
362-
File.Copy(file, Path.Combine(HELIX_WORKITEM_UPLOAD_ROOT, "..", fileName));
363365
}
364366
}
365367
else

eng/helix/content/runtests.ps1

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,11 @@ param(
1414

1515
$env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE = 1
1616
$env:DOTNET_MULTILEVEL_LOOKUP = 0
17-
$env:PLAYWRIGHT_BROWSERS_PATH = "$currentDirectory\ms-playwright"
1817
$env:InstallPlaywright = "$InstallPlaywright"
19-
2018
$currentDirectory = Get-Location
19+
$env:PLAYWRIGHT_BROWSERS_PATH = "$currentDirectory\ms-playwright"
20+
$env:PLAYWRIGHT_DRIVER_PATH = "$currentDirectory\.playwright\win-x64\native\playwright.cmd"
21+
2122
$envPath = "$env:PATH;$env:HELIX_CORRELATION_PAYLOAD\node\bin"
2223

2324
function InvokeInstallDotnet([string]$command) {

eng/helix/content/runtests.sh

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
dotnet_sdk_version="$2"
44
dotnet_runtime_version="$3"
5+
helixQueue="$5"
6+
installPlaywright="${10}"
57

68
RESET="\033[0m"
79
RED="\033[0;31m"
@@ -25,8 +27,47 @@ export DOTNET_CLI_HOME="$DIR/.home$RANDOM"
2527

2628
export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
2729

28-
# Set playwright browser path
30+
# Set playwright stuff
2931
export PLAYWRIGHT_BROWSERS_PATH="$DIR/ms-playwright"
32+
if [[ "$helixQueue" == *"OSX"* ]]; then
33+
export PLAYWRIGHT_DRIVER_PATH="$DIR/.playwright/osx/native/playwright.sh"
34+
PLAYWRIGHT_NODE_PATH=$DIR/.playwright/osx/native/node
35+
else
36+
export PLAYWRIGHT_DRIVER_PATH="$DIR/.playwright/unix/native/playwright.sh"
37+
PLAYWRIGHT_NODE_PATH=$DIR/.playwright/unix/native/node
38+
fi
39+
export InstallPlaywright="$installPlaywright"
40+
if [ -f "$PLAYWRIGHT_DRIVER_PATH" ]; then
41+
if [[ "$helixQueue" != *"OSX"* ]]; then
42+
echo "Installing Playwright requirements..."
43+
sudo apt-get install -y libdbus-glib-1-2
44+
sudo apt-get install -y libbrotli1
45+
sudo apt-get install -y libegl1
46+
sudo apt-get install -y libnotify4
47+
sudo apt-get install -y libvpx5
48+
sudo apt-get install -y libopus0
49+
sudo apt-get install -y libwoff1
50+
sudo apt-get install -y libgstreamer-plugins-base1.0-0
51+
sudo apt-get install -y libgstreamer1.0-0
52+
sudo apt-get install -y libgstreamer-gl1.0-0
53+
sudo apt-get install -y libgstreamer-plugins-bad1.0-0
54+
sudo apt-get install -y libopenjp2-7
55+
sudo apt-get install -y libwebpdemux2
56+
sudo apt-get install -y libwebp6
57+
sudo apt-get install -y libenchant1c2a
58+
sudo apt-get install -y libsecret-1-0
59+
sudo apt-get install -y libhyphen0
60+
sudo apt-get install -y libgles2
61+
sudo apt-get install -y gstreamer1.0-libav
62+
sudo apt-get install -y libxkbcommon0
63+
sudo apt-get install -y libgtk-3-0
64+
sudo apt-get install -y libharfbuzz-icu0
65+
fi
66+
echo "chmod +x $PLAYWRIGHT_DRIVER_PATH"
67+
chmod +x $PLAYWRIGHT_DRIVER_PATH
68+
echo "chmod +x $PLAYWRIGHT_NODE_PATH"
69+
chmod +x $PLAYWRIGHT_NODE_PATH
70+
fi
3071

3172
RESET="\033[0m"
3273
RED="\033[0;31m"
@@ -83,8 +124,8 @@ exit_code=0
83124
echo "Restore: $DOTNET_ROOT/dotnet restore RunTests/RunTests.csproj --ignore-failed-sources"
84125
$DOTNET_ROOT/dotnet restore RunTests/RunTests.csproj --ignore-failed-sources
85126

86-
echo "Running tests: $DOTNET_ROOT/dotnet run --no-restore --project RunTests/RunTests.csproj -- --target $1 --runtime $4 --queue $5 --arch $6 --quarantined $7 --ef $8 --helixTimeout $9"
87-
$DOTNET_ROOT/dotnet run --no-restore --project RunTests/RunTests.csproj -- --target $1 --runtime $4 --queue $5 --arch $6 --quarantined $7 --ef $8 --helixTimeout $9
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
88129
exit_code=$?
89130
echo "Finished tests...exit_code=$exit_code"
90131

eng/targets/Helix.Common.props

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@
1212

1313
<!-- PR(ci.yaml) required queues -->
1414
<ItemGroup Condition="'$(IsRequiredCheck)' == 'true' AND '$(TargetArchitecture)' == 'x64' AND '$(_UseHelixOpenQueues)' == 'true'">
15-
<HelixAvailableTargetQueue Include="Ubuntu.1604.Amd64.Open" Platform="Linux" />
15+
<HelixAvailableTargetQueue Include="Ubuntu.1804.Amd64.Open" Platform="Linux" />
1616
<HelixAvailableTargetQueue Include="Windows.10.Amd64.Server20H2.Open" Platform="Windows" />
1717
<HelixAvailableTargetQueue Include="OSX.1014.Amd64.Open" Platform="Linux" />
1818
</ItemGroup>
1919

2020
<!-- queues for helix-matrix.yml pipeline -->
2121
<ItemGroup Condition="'$(TargetArchitecture)' == 'x64' AND '$(IsHelixDaily)' == 'true' AND '$(_UseHelixOpenQueues)' == 'true' AND '$(IsWindowsOnlyTest)' != 'true'">
22-
<HelixAvailableTargetQueue Include="Ubuntu.1804.Amd64.Open" Platform="Linux" />
22+
<HelixAvailableTargetQueue Include="Ubuntu.1604.Amd64.Open" Platform="Linux" />
2323
<HelixAvailableTargetQueue Include="Ubuntu.2004.Amd64.Open" Platform="Linux" />
2424
<HelixAvailableTargetQueue Include="OSX.1100.Amd64.Open" Platform="Linux" />
2525
<HelixAvailableTargetQueue Include="Debian.9.Amd64.Open" Platform="Linux" />

eng/targets/Helix.targets

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
<HelixPreCommand Include="call RunPowershell.cmd mssql\InstallSqlServerLocalDB.ps1 || exit /b 1" />
99
</ItemGroup>
1010

11-
<PropertyGroup Condition="'$(TestDependsOnPlaywright)' == 'true' AND '$(IsWindowsHelixQueue)' == 'true'">
12-
<SkipHelixQueues>Windows.7.Amd64.Open;Windows.81.Amd64.Open</SkipHelixQueues>
11+
<PropertyGroup Condition="'$(TestDependsOnPlaywright)' == 'true'">
12+
<SkipHelixQueues>Windows.7.Amd64.Open;Windows.81.Amd64.Open;Redhat.7.Amd64.Open;Redhat.7.Amd64;Debian.9.Amd64.Open;Debian.9.Amd64.Open;Ubuntu.2004.Amd64.Open;Ubuntu.2004.Amd64;Ubuntu.1604.Amd64.Open;Ubuntu.1604.Amd64;Alpine.312.Amd64.Open;(Alpine.312.Amd64.Open)[email protected]/dotnet-buildtools/prereqs:alpine-3.12-helix-20200908125345-56c6673;(Fedora.33.Amd64.Open)[email protected]/dotnet-buildtools/prereqs:fedora-33-helix-20210120000908-a9df267</SkipHelixQueues>
1313
</PropertyGroup>
1414

1515
<ItemGroup Condition="'$(TestDependsOnPlaywright)' == 'true' AND '$(IsWindowsHelixQueue)' == 'true'">

src/ProjectTemplates/BlazorTemplates.Tests/BlazorServerTemplateTest.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ await Fixture.BrowserManager.GetBrowserInstance(browserKind, BrowserContextInfo)
108108
[Theory]
109109
[MemberData(nameof(BlazorServerTemplateWorks_IndividualAuthData))]
110110
[QuarantinedTest("https://github.com/dotnet/aspnetcore/issues/30807")]
111+
[SkipOnHelix("https://github.com/dotnet/aspnetcore/issues/30825", Queues = "All.OSX")]
111112
public async Task BlazorServerTemplateWorks_IndividualAuth(BrowserKind browserKind, bool useLocalDB)
112113
{
113114
// Additional arguments are needed. See: https://github.com/dotnet/aspnetcore/issues/24278

src/ProjectTemplates/BlazorTemplates.Tests/BlazorTemplates.Tests.csproj

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
<RunTemplateTests Condition="'$(RunTemplateTests)' == ''">true</RunTemplateTests>
88
<SkipTests Condition="'$(RunTemplateTests)' != 'true'">true</SkipTests>
9-
<IsWindowsOnlyTest>true</IsWindowsOnlyTest>
109
<SkipHelixArm>true</SkipHelixArm>
1110
<BaseOutputPath />
1211
<OutputPath />
@@ -45,6 +44,8 @@
4544
<Reference Include="Microsoft.Extensions.Configuration" />
4645
<Reference Include="Microsoft.Extensions.Configuration.Json" />
4746
<Reference Include="Anglesharp" />
47+
<Reference Include="PlaywrightSharp" Condition="'$(TargetOsName)' != 'linux-musl'" />
48+
<Reference Include="PlaywrightSharp" ExcludeAssets="build" Condition="'$(TargetOsName)' == 'linux-musl'" />
4849
<ProjectReference Include="$(RepoRoot)src\Framework\App.Runtime\src\Microsoft.AspNetCore.App.Runtime.csproj">
4950
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
5051
<SkipGetTargetFrameworkProperties>true</SkipGetTargetFrameworkProperties>
@@ -57,4 +58,13 @@
5758

5859
<!-- Shared testing infrastructure for running E2E template tests -->
5960
<Import Project="..\TestInfrastructure\PrepareForTest.targets" />
61+
62+
<Target Name="PublishAssets" AfterTargets="Publish">
63+
<ItemGroup>
64+
<_PublishFiles Include="$(OutputPath).playwright\**\*.*" />
65+
</ItemGroup>
66+
<Copy SourceFiles="@(_PublishFiles)" DestinationFolder="$(PublishDir)\.playwright\%(_PublishFiles.RecursiveDir)\" />
67+
</Target>
68+
69+
6070
</Project>

src/ProjectTemplates/BlazorTemplates.Tests/BlazorWasmTemplateTest.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,7 @@ public Task BlazorWasmHostedTemplate_IndividualAuth_Works_WithLocalDB(BrowserKin
293293
[Theory]
294294
[InlineData(BrowserKind.Chromium)]
295295
[QuarantinedTest("https://github.com/dotnet/aspnetcore/issues/30820")]
296+
[SkipOnHelix("https://github.com/dotnet/aspnetcore/issues/30825", Queues = "All.OSX")]
296297
public Task BlazorWasmHostedTemplate_IndividualAuth_Works_WithOutLocalDB(BrowserKind browserKind)
297298
{
298299
return BlazorWasmHostedTemplate_IndividualAuth_Works(browserKind, false);

src/ProjectTemplates/BlazorTemplates.Tests/playwrightSettings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
},
2929
"Firefox": {
3030
"BrowserKind": "Firefox",
31-
"IsEnabled": true
31+
"IsEnabled": false
3232
},
3333
"Webkit": {
3434
"BrowserKind": "Webkit",

src/Shared/BrowserTesting/src/BrowserManager.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
using System;
55
using System.Collections.Generic;
6+
using System.IO;
67
using System.Linq;
78
using System.Threading;
89
using System.Threading.Tasks;
@@ -46,7 +47,15 @@ private async Task InitializeAsync()
4647

4748
async Task InitializeCore()
4849
{
49-
Playwright = await PlaywrightSharp.Playwright.CreateAsync(_loggerFactory/*, debug: "pw:api"*/);
50+
var driverPath = Environment.GetEnvironmentVariable("PLAYWRIGHT_DRIVER_PATH");
51+
if (!string.IsNullOrEmpty(driverPath))
52+
{
53+
Playwright = await PlaywrightSharp.Playwright.CreateAsync(_loggerFactory, driverExecutablePath: driverPath, debug: "pw:api");
54+
}
55+
else
56+
{
57+
Playwright = await PlaywrightSharp.Playwright.CreateAsync(_loggerFactory, debug: "pw:api");
58+
}
5059
foreach (var (browserName, options) in _browserManagerConfiguration.BrowserOptions)
5160
{
5261
if (!_launchBrowsers.ContainsKey(browserName))

src/Shared/BrowserTesting/src/ContextInformation.cs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,21 +52,18 @@ private void CleanupPage(object sender, EventArgs e)
5252

5353
internal BrowserContextOptions ConfigureUniqueHarPath(BrowserContextOptions browserContextOptions)
5454
{
55+
var uploadDir = Environment.GetEnvironmentVariable("HELIX_WORKITEM_UPLOAD_ROOT");
5556
if (browserContextOptions?.RecordHar?.Path != null)
5657
{
5758
var identifier = Guid.NewGuid().ToString("N");
58-
var harDirectory = Environment.GetEnvironmentVariable("HELIX_WORKITEM_UPLOAD_ROOT");
59-
if (string.IsNullOrEmpty(harDirectory))
60-
{
61-
harDirectory = browserContextOptions.RecordHar.Path;
62-
}
63-
browserContextOptions.RecordHar.Path = Path.Combine(harDirectory, $"{identifier}.har");
59+
browserContextOptions.RecordHar.Path = Path.Combine(
60+
string.IsNullOrEmpty(uploadDir) ? browserContextOptions.RecordHar.Path : uploadDir,
61+
$"{identifier}.har");
6462
_harPath = browserContextOptions.RecordHar.Path;
6563
}
6664

6765
if (browserContextOptions?.RecordVideo?.Dir != null)
6866
{
69-
var uploadDir = Environment.GetEnvironmentVariable("HELIX_WORKITEM_UPLOAD_ROOT");
7067
if (!string.IsNullOrEmpty(uploadDir))
7168
{
7269
browserContextOptions.RecordVideo.Dir = uploadDir;

0 commit comments

Comments
 (0)