Skip to content
Open
Show file tree
Hide file tree
Changes from 3 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
6 changes: 5 additions & 1 deletion .github/actions/setup-dotnet/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ inputs:
description: 'Whether to run dotnet build after restore'
required: false
default: 'true'
configuration:
description: 'What configuration to run (e.g., Release or Debug)'
required: false
default: 'Release'
runs:
using: 'composite'
steps:
Expand All @@ -31,4 +35,4 @@ runs:
- name: Build with dotnet
if: inputs.build == 'true'
shell: bash
run: dotnet build -p:ContinuousIntegrationBuild=True --configuration Release --no-restore
run: dotnet build -p:ContinuousIntegrationBuild=True --configuration ${{ inputs.configuration }} --no-restore
20 changes: 13 additions & 7 deletions .github/workflows/Build-Test-And-Deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:

- name: Run .NET Tests
id: run-dotnet-tests
run: dotnet test --no-build --configuration Release --blame-hang-timeout 15m --blame-hang-dump-type full -l trx --results-directory ./TestResults
run: dotnet test --no-build --configuration Release --blame-hang-timeout 15m --blame-hang-dump-type full -l trx --results-directory ./TestResults --filter TestType!=Integration
env:
POCKETLOGGER_LOG_PATH: ${{ github.workspace }}/artifacts/logs/pocketlogger.log

Expand Down Expand Up @@ -93,7 +93,7 @@ jobs:

- name: Run .NET Tests
id: run-dotnet-tests
run: dotnet test --no-build --configuration Release --blame-hang-timeout 15m --blame-hang-dump-type full -l trx --results-directory ./TestResults
run: dotnet test --no-build --configuration Release --blame-hang-timeout 15m --blame-hang-dump-type full -l trx --results-directory ./TestResults --filter TestType!=Integration
env:
POCKETLOGGER_LOG_PATH: ${{ github.workspace }}/artifacts/logs/pocketlogger.log

Expand All @@ -106,11 +106,12 @@ jobs:
artifact-name: 'windows-test-playlists'

integration-tests:
# Integration tests use Playwright and are gated behind RunIntegrationTests=true.
# IntegrationTestFactAttribute explicitly skips these tests on Linux, so a
# Windows runner is required to actually execute them.
runs-on: windows-latest
strategy:
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
browser: [chromium, firefox, webkit]

runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v6

Expand All @@ -119,10 +120,15 @@ jobs:

- name: Set up .NET environment
uses: ./.github/actions/setup-dotnet
with:
configuration: Debug

- name: Ensure browsers are installed
run: pwsh bin/Debug/net10.0/playwright.ps1 install --with-deps

- name: Run .NET Integration Tests
id: run-dotnet-integration-tests
run: dotnet test --no-build --configuration Release --blame-hang-timeout 15m --blame-hang-dump-type full -l trx --results-directory ./TestResults
run: dotnet test --no-build --configuration Debug --blame-hang-timeout 15m --blame-hang-dump-type full -l trx --results-directory ./TestResults --filter TestType=Integration -- Playwright.BrowserName=${{ matrix.browser }}
env:
RunIntegrationTests: true
POCKETLOGGER_LOG_PATH: ${{ github.workspace }}/artifacts/logs/pocketlogger.log
Expand Down
1 change: 1 addition & 0 deletions src/Microsoft.TryDotNet.IntegrationTests/EditorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
namespace Microsoft.TryDotNet.IntegrationTests;

[LogToPocketLogger(FileNameEnvironmentVariable = "POCKETLOGGER_LOG_PATH")]
[Trait("TestType", "Integration")]
public class EditorTests : PlaywrightTestBase
{
public EditorTests(IntegratedServicesFixture services, ITestOutputHelper output) : base(services, output)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,33 +1,30 @@
// Copyright (c) .NET Foundation and contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using System;
using System.Runtime.InteropServices;

using Xunit;

namespace Microsoft.TryDotNet.IntegrationTests
{
internal class IntegrationTestFactAttribute : FactAttribute
{
private const string EnvironmentVariableName = "RunIntegrationTests";

public IntegrationTestFactAttribute(string? skipReason = null)
{
var variableValue = Environment.GetEnvironmentVariable(EnvironmentVariableName) ?? "false";
switch (variableValue.ToLowerInvariant())
{
case "1":
case "true":
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
Skip = string.IsNullOrWhiteSpace(skipReason) ? "Ignored on Linux" : skipReason;
}
break;
default:
Skip = $"Skipping integration tests because environment variable '{EnvironmentVariableName}' was not 'true' or '1'.";
break;
}
}
}
}
// Copyright (c) .NET Foundation and contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using System;
using System.Runtime.InteropServices;

using Xunit;

namespace Microsoft.TryDotNet.IntegrationTests
{
internal class IntegrationTestFactAttribute : FactAttribute
{
private const string EnvironmentVariableName = "RunIntegrationTests";

public IntegrationTestFactAttribute(string? skipReason = null)
{
var variableValue = Environment.GetEnvironmentVariable(EnvironmentVariableName) ?? "false";
switch (variableValue.ToLowerInvariant())
{
case "1":
case "true":
// Run tests
break;
default:
Skip = $"Skipping integration tests because environment variable '{EnvironmentVariableName}' was not 'true' or '1'.";
break;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
<DebugType>embedded</DebugType>
</PropertyGroup>

<ItemGroup>
<Using Include="Xunit" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Assent" />
<PackageReference Include="AwesomeAssertions" />
Expand Down Expand Up @@ -71,6 +75,5 @@ public static class BuildProperties
<Target Name="PublishTool" BeforeTargets="CoreCompile" Condition="'$(DisableArcade)' != '1'">
<Exec Command="dotnet publish -o $(PublishLocation)" WorkingDirectory="$(MSBuildThisFileDirectory)..\Microsoft.TryDotNet" />
</Target>

</Project>

14 changes: 11 additions & 3 deletions src/Microsoft.TryDotNet.IntegrationTests/PlaywrightSession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@

public IBrowser Browser { get; }

public static async Task<PlaywrightSession> StartAsync()
public static async Task<PlaywrightSession> StartAsync(string browserName = null)

Check warning on line 23 in src/Microsoft.TryDotNet.IntegrationTests/PlaywrightSession.cs

View workflow job for this annotation

GitHub Actions / copilot-setup-steps

Cannot convert null literal to non-nullable reference type.

Check warning on line 23 in src/Microsoft.TryDotNet.IntegrationTests/PlaywrightSession.cs

View workflow job for this annotation

GitHub Actions / copilot-setup-steps

Cannot convert null literal to non-nullable reference type.

Check warning on line 23 in src/Microsoft.TryDotNet.IntegrationTests/PlaywrightSession.cs

View workflow job for this annotation

GitHub Actions / build-and-test

Cannot convert null literal to non-nullable reference type.

Check warning on line 23 in src/Microsoft.TryDotNet.IntegrationTests/PlaywrightSession.cs

View workflow job for this annotation

GitHub Actions / build-and-test

Cannot convert null literal to non-nullable reference type.

Check warning on line 23 in src/Microsoft.TryDotNet.IntegrationTests/PlaywrightSession.cs

View workflow job for this annotation

GitHub Actions / build-and-test-windows

Cannot convert null literal to non-nullable reference type.

Check warning on line 23 in src/Microsoft.TryDotNet.IntegrationTests/PlaywrightSession.cs

View workflow job for this annotation

GitHub Actions / build-and-test-windows

Cannot convert null literal to non-nullable reference type.

Check warning on line 23 in src/Microsoft.TryDotNet.IntegrationTests/PlaywrightSession.cs

View workflow job for this annotation

GitHub Actions / integration-tests (macos-latest, firefox)

Cannot convert null literal to non-nullable reference type.

Check warning on line 23 in src/Microsoft.TryDotNet.IntegrationTests/PlaywrightSession.cs

View workflow job for this annotation

GitHub Actions / integration-tests (macos-latest, firefox)

Cannot convert null literal to non-nullable reference type.
{
var exitCode = Playwright.Program.Main(["install", "chromium"]);
var exitCode = Playwright.Program.Main(["install"]);
if (exitCode is not 0)
{
throw new Exception($"Playwright exited with code {exitCode}");
Expand All @@ -37,7 +37,15 @@
browserTypeLaunchOptions.Headless = false;
}

var browser = await session.Chromium.LaunchAsync(browserTypeLaunchOptions).Timeout(TimeSpan.FromMinutes(5), "Timeout launching browser");
var selectedBrowser = (browserName ?? Environment.GetEnvironmentVariable("Playwright.BrowserName") ?? "chromium").ToLowerInvariant();

IBrowser browser = selectedBrowser switch
{
"chromium" => await session.Chromium.LaunchAsync(browserTypeLaunchOptions).Timeout(TimeSpan.FromMinutes(5), "Timeout launching browser"),
"firefox" => await session.Firefox.LaunchAsync(browserTypeLaunchOptions).Timeout(TimeSpan.FromMinutes(5), "Timeout launching browser"),
"webkit" => await session.Webkit.LaunchAsync(browserTypeLaunchOptions).Timeout(TimeSpan.FromMinutes(5), "Timeout launching browser"),
_ => throw new ArgumentException($"Unknown browser '{selectedBrowser}'. Valid values: chromium, firefox, webkit.")
};

return new PlaywrightSession(session, browser);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
namespace Microsoft.TryDotNet.IntegrationTests;

[LogToPocketLogger(FileNameEnvironmentVariable = "POCKETLOGGER_LOG_PATH")]
[Trait("TestType", "Integration")]
public class TryDotNetJsIntegrationTests : PlaywrightTestBase
{
public TryDotNetJsIntegrationTests(IntegratedServicesFixture services, ITestOutputHelper output) : base(services, output)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
namespace Microsoft.TryDotNet.IntegrationTests;

[LogToPocketLogger(FileNameEnvironmentVariable = "POCKETLOGGER_LOG_PATH")]
[Trait("TestType", "Integration")]
public class WasmRunnerTests : PlaywrightTestBase
{
public WasmRunnerTests(IntegratedServicesFixture services, ITestOutputHelper output) : base(services, output)
Expand Down
Loading