Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
46 changes: 29 additions & 17 deletions .github/workflows/Build-Test-And-Deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,17 @@ 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

- name: Convert TRX to Playlist
if: ${{ steps.run-dotnet-tests.outcome == 'failure' || failure() }}
uses: BenjaminMichaelis/trx-to-vsplaylist@v3
with:
trx-file-path: './TestResults/*.trx'
test-outcomes: 'Failed'
artifact-name: 'linux-test-playlists'
trx-file-path: "./TestResults/*.trx"
test-outcomes: "Failed"
artifact-name: "linux-test-playlists"

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
Expand Down Expand Up @@ -93,24 +93,33 @@ 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

- name: Convert TRX to Playlist
if: ${{ steps.run-dotnet-tests.outcome == 'failure' || failure() }}
uses: BenjaminMichaelis/trx-to-vsplaylist@v3
with:
trx-file-path: './TestResults/*.trx'
test-outcomes: 'Failed'
artifact-name: 'windows-test-playlists'
trx-file-path: "./TestResults/*.trx"
test-outcomes: "Failed"
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:
fail-fast: false
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
browser: [chromium, firefox, webkit]
exclude:
- os: windows-latest
browser: webkit
- os: ubuntu-latest
browser: webkit
- os: macos-latest
browser: firefox

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

Expand All @@ -119,22 +128,25 @@ jobs:

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

- 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
TRYDOTNET_PREBUILDS_PATH: ${{ github.workspace }}/artifacts/trydotnet-prebuilds
Playwright_BrowserName: ${{ matrix.browser }}

- name: Convert TRX to Playlist
if: ${{ steps.run-dotnet-integration-tests.outcome == 'failure' || failure() }}
uses: BenjaminMichaelis/trx-to-vsplaylist@v3
with:
trx-file-path: './TestResults/*.trx'
test-outcomes: 'Failed'
artifact-name: 'integration-test-playlists'
trx-file-path: "./TestResults/*.trx"
test-outcomes: "Failed"
artifact-name: "integration-test-playlists"

deploy-development:
if: github.event_name != 'pull_request_target' && github.event_name != 'pull_request'
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,6 +1,7 @@
// 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.Threading;
using System.Threading.Tasks;
using Microsoft.DotNet.Interactive.CSharpProject.Build;
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>

27 changes: 24 additions & 3 deletions src/Microsoft.TryDotNet.IntegrationTests/PlaywrightSession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,24 @@ public PlaywrightSession(IPlaywright playwright, IBrowser browser)

public IBrowser Browser { get; }

public static async Task<PlaywrightSession> StartAsync()
public static async Task<PlaywrightSession> StartAsync(string? browserName = null)
{
var exitCode = Playwright.Program.Main(["install", "chromium"]);

string? selectedBrowser = browserName
?? Environment.GetEnvironmentVariable("Playwright.BrowserName")
?? Environment.GetEnvironmentVariable("Playwright_BrowserName");

int exitCode;
if (!string.IsNullOrWhiteSpace(selectedBrowser))
{
selectedBrowser = selectedBrowser.ToLowerInvariant();
exitCode = Playwright.Program.Main(["install", selectedBrowser]);
}
else
{
exitCode = Playwright.Program.Main(["install"]);
selectedBrowser = "chromium";
}
if (exitCode is not 0)
{
throw new Exception($"Playwright exited with code {exitCode}");
Expand All @@ -37,7 +52,13 @@ public static async Task<PlaywrightSession> StartAsync()
browserTypeLaunchOptions.Headless = false;
}

var browser = await session.Chromium.LaunchAsync(browserTypeLaunchOptions).Timeout(TimeSpan.FromMinutes(5), "Timeout launching browser");
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