Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
99 changes: 68 additions & 31 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,23 +72,11 @@
if: matrix.os == 'windows-latest'
uses: microsoft/setup-msbuild@v3

# No NuGet or Playwright cache: PR-scoped entries can't be shared between PRs, and at
# ~2.4 GB each they pushed the repository past its cache quota, so every run missed and
# then spent up to 3 minutes saving an entry that was evicted within the hour.
- name: Setup .NET
uses: actions/setup-dotnet@v6.0.0
with:
cache: true
cache-dependency-path: Directory.Packages.props

- name: Cache Playwright Browsers
uses: actions/cache@v6
continue-on-error: true
with:
path: |
~/.cache/ms-playwright
~/Library/Caches/ms-playwright
~/AppData/Local/ms-playwright
key: playwright-${{ runner.os }}-${{ hashFiles('**/package-lock.json', '**/package.json', '**/Directory.Packages.props') }}
restore-keys: |
playwright-${{ runner.os }}-

- name: Enable Long Paths on Windows
if: matrix.os == 'windows-latest'
Expand Down Expand Up @@ -136,17 +124,6 @@
"-p:InformationalVersion=${{ steps.gitversion.outputs.informationalVersion }}"
"-p:PackageVersion=${{ steps.gitversion.outputs.fullSemVer }}"

- name: Publish AOT
shell: bash
run: >-
dotnet publish tests/TUnit.TestProject/TUnit.TestProject.csproj -c Release
--use-current-runtime -p:Aot=true -o TESTPROJECT_AOT --framework net10.0
"-p:Version=${{ steps.gitversion.outputs.semVer }}"
"-p:AssemblyVersion=${{ steps.gitversion.outputs.assemblySemVer }}"
"-p:FileVersion=${{ steps.gitversion.outputs.assemblySemFileVer }}"
"-p:InformationalVersion=${{ steps.gitversion.outputs.informationalVersion }}"
"-p:PackageVersion=${{ steps.gitversion.outputs.fullSemVer }}"

- name: Expose GitHub Actions Runtime
uses: actions/github-script@v9
with:
Expand All @@ -169,11 +146,6 @@
nuget-apikey: ${{ steps.login.outputs.NUGET_API_KEY }}
publish-packages: ${{ (github.event.inputs.publish-packages || false) && matrix.os == 'ubuntu-latest' }}

- name: Compile documentation snippets
if: matrix.os == 'ubuntu-latest'
shell: pwsh
run: ./scripts/Verify-DocSnippets.ps1 -PackagesPath . -Version $env:PackageVersion

- name: Upload Diagnostic Logs
uses: actions/upload-artifact@v7.0.2
if: always()
Expand Down Expand Up @@ -207,3 +179,68 @@
with:
name: 'NuGetPackages-${{matrix.os}}'
path: '**/*.*nupkg'

# Native AOT publishes of the mock test projects, one runner per framework. Run inside the
# Ubuntu pipeline they took ~12 minutes serially and held up packaging behind them.
mock-aot:
name: mock AOT (${{ matrix.framework }})
strategy:
matrix:
framework: [net8.0, net9.0, net10.0]
fail-fast: false
runs-on: ubuntu-latest
env:
DISABLE_GITHUB_REPORTER: 'true'

steps:
- uses: actions/checkout@v7.0.1
Comment thread
thomhurst marked this conversation as resolved.
Resolved

- name: Setup .NET
uses: actions/setup-dotnet@v6.0.0

# TUnit.Mocks.Aot.Tests sets TreatWarningsAsErrors, so any trim/AOT warning ILC reports
# for everyday mock usage fails its publish (#7027).
- name: Publish
shell: bash
run: |
for project in TUnit.Mocks.Tests TUnit.Mocks.Aot.Tests; do
dotnet publish "tests/$project/$project.csproj" -c Release --use-current-runtime \
-p:Aot=true --framework ${{ matrix.framework }} -o "aot/$project"
done

- name: Run
shell: bash
run: |
for project in TUnit.Mocks.Tests TUnit.Mocks.Aot.Tests; do
"aot/$project/$project"
done

# Compiles the C# fences in the documentation against freshly packed packages, alongside the
# test matrix rather than after the Ubuntu pipeline.
doc-snippets:
Comment thread
github-advanced-security[bot] marked this conversation as resolved.
Fixed
runs-on: ubuntu-latest
env:
DocsVersion: 1.0.0-docs

steps:
- uses: actions/checkout@v7.0.1

- name: Setup .NET
uses: actions/setup-dotnet@v6.0.0

# Packing reads the Roslyn analyzer/generator variants from their own bin folders, so build
# every library project, not just the packed ones.
- name: Build libraries
shell: bash
run: |
grep -oE 'src/[^"]+\.(cs|fs|vb)proj' TUnit.CI.slnx | grep -v '/content/' \
| jq -R . | jq -s '{solution: {path: "TUnit.CI.slnx", projects: .}}' > libraries.slnf
dotnet build libraries.slnf -c Release "-p:Version=$DocsVersion"

- name: Pack
shell: bash
run: dotnet pack libraries.slnf -c Release --no-build "-p:Version=$DocsVersion" -o artifacts/doc-packages

- name: Compile documentation snippets
shell: pwsh
run: ./scripts/Verify-DocSnippets.ps1 -PackagesPath artifacts/doc-packages -Version $env:DocsVersion
Comment thread
github-advanced-security[bot] marked this conversation as resolved.
Fixed
5 changes: 3 additions & 2 deletions tools/TUnit.Pipeline/Modules/PackTUnitFilesModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@

namespace TUnit.Pipeline.Modules;

// Must run after any module that may recompile packable projects (TUnit.Mocks et al).
// Must run after any module that may recompile packable projects (the AOT publish rebuilds its
// TUnit.* references).
// This module uses NoBuild=true and packs whatever bin/Release/{tfm}/*.dll is on disk, so
// a racing recompile without version props would ship strong-name-mismatched packages.
// Version props come from $GITHUB_ENV (see .github/workflows/dotnet.yml) so recompiles
// also stamp the correct AssemblyVersion. See issue #5622.
[DependsOn<GetPackageProjectsModule>]
[DependsOn<GenerateVersionModule>]
[DependsOn<PublishMockTestsAOTModule>]
[DependsOn<PublishTestProjectAOTModule>]
public class PackTUnitFilesModule : Module<List<PackedProject>>
{
// Packages in beta ship with a "-beta" suffix appended to their version. The suffix is
Expand Down
79 changes: 0 additions & 79 deletions tools/TUnit.Pipeline/Modules/PublishMockTestsAOTModule.cs

This file was deleted.

45 changes: 45 additions & 0 deletions tools/TUnit.Pipeline/Modules/PublishTestProjectAOTModule.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
using ModularPipelines.Context;
using ModularPipelines.DotNet.Extensions;
using ModularPipelines.DotNet.Options;
using ModularPipelines.Extensions;
using ModularPipelines.Git.Extensions;
using ModularPipelines.Models;
using ModularPipelines.Modules;
using ModularPipelines.Options;

namespace TUnit.Pipeline.Modules;

// Publishes the TESTPROJECT_AOT app that the engine tests' AOT mode runs. As a module it overlaps
// the first test modules instead of delaying the whole pipeline. Version props come from
// $GITHUB_ENV (see .github/workflows/dotnet.yml), so any recompile it triggers stamps the correct
// AssemblyVersion; PackTUnitFilesModule still waits for it (issue #5622).
public class PublishTestProjectAOTModule : Module<CommandResult>
{
protected override async Task<CommandResult?> ExecuteAsync(IModuleContext context, CancellationToken cancellationToken)
{
var rootDir = context.Git().RootDirectory.AssertExists();
var project = rootDir.FindFile(x => x.Name == "TUnit.TestProject.csproj").AssertExists();

return await context.DotNet().Publish(new DotNetPublishOptions
{
ProjectSolution = project.Path,
Runtime = RuntimeIdentifiers.Current,
Configuration = "Release",
Output = Path.Combine(rootDir.Path, "TESTPROJECT_AOT"),
Properties =
[
new KeyValue("Aot", "true"),
],
Framework = "net10.0",
}, new CommandExecutionOptions
{
LogSettings = new CommandLoggingOptions
{
ShowCommandArguments = true,
ShowStandardError = true,
ShowExecutionTime = true,
ShowExitCode = true
}
}, cancellationToken);
}
}
1 change: 1 addition & 0 deletions tools/TUnit.Pipeline/Modules/RunEngineTestsModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ namespace TUnit.Pipeline.Modules;
[DependsOn<RunPublicAPITestsModule>]
[DependsOn<RunSourceGeneratorTestsModule>]
[DependsOn<RunAssertionsCodeFixersTestsModule>]
[DependsOn<PublishTestProjectAOTModule>]
public class RunEngineTestsModule : Module<CommandResult>
{
protected override async Task<CommandResult?> ExecuteAsync(IModuleContext context, CancellationToken cancellationToken)
Expand Down
47 changes: 0 additions & 47 deletions tools/TUnit.Pipeline/Modules/RunMockTestsAOTModule.cs

This file was deleted.

Loading