Skip to content
Merged
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
15 changes: 14 additions & 1 deletion .github/actions/execute-pipeline/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ inputs:
description: Categories to run
required: false
default: ''
ignore-categories:
description: Categories to skip
required: false
default: ''
admin-token:
description: 'Admin token'
required: true
Expand All @@ -30,9 +34,18 @@ runs:
steps:
- name: Run Pipeline
shell: bash
run: dotnet run -c Release --no-build --categories ${{ inputs.categories }}
run: |
read -ra categories <<< "$PIPELINE_CATEGORIES"
read -ra ignore_categories <<< "$PIPELINE_IGNORE_CATEGORIES"
args=(--categories "${categories[@]}")
if [ ${#ignore_categories[@]} -gt 0 ]; then
args+=(--ignore-categories "${ignore_categories[@]}")
fi
dotnet run -c Release --no-build "${args[@]}"
working-directory: "tools/TUnit.Pipeline"
env:
PIPELINE_CATEGORIES: ${{ inputs.categories }}
PIPELINE_IGNORE_CATEGORIES: ${{ inputs.ignore-categories }}
ADMIN_TOKEN: ${{ inputs.admin-token }}
GITHUB_TOKEN: ${{ github.token }}
DOTNET_ENVIRONMENT: ${{ inputs.environment }}
Expand Down
93 changes: 93 additions & 0 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,9 @@ jobs:
environment: ${{ github.ref == 'refs/heads/main' && 'Production' || 'Development' }}
nuget-apikey: ${{ steps.login.outputs.NUGET_API_KEY }}
publish-packages: ${{ (github.event.inputs.publish-packages || false) && matrix.os == 'ubuntu-latest' }}
# Windows tests the packages in the nuget-package-tests-windows job instead: with every
# .NET Framework TFM they competed with the engine tests for this runner's CPUs.
ignore-categories: ${{ matrix.os == 'windows-latest' && 'NuGetPackageTests' || '' }}

- name: Upload Diagnostic Logs
uses: actions/upload-artifact@v7.0.2
Expand Down Expand Up @@ -224,6 +227,96 @@ jobs:
exit 1
fi

# Tests the packed packages on Windows, including every .NET Framework TFM, on a runner of its
# own. Linux and macOS still test them inside the matrix pipeline.
nuget-package-tests-windows:
runs-on: windows-latest
permissions:
contents: read

steps:
- uses: actions/checkout@v7.0.1
with:
fetch-depth: 0
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
# Versioning reads the fetched history only; nothing in this job pushes.
persist-credentials: false

- name: Setup Dev Drive
uses: samypr100/setup-dev-drive@v4
with:
drive-size: 10GB
trusted-dev-drive: true
env-mapping: |
NUGET_PACKAGES,{{ DEV_DRIVE }}/.nuget/packages
TEMP,{{ DEV_DRIVE }}/tmp
TMP,{{ DEV_DRIVE }}/tmp

- name: Setup .NET Framework
uses: microsoft/setup-msbuild@v3

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

- name: Enable Long Paths
run: |
New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem" -Name "LongPathsEnabled" -Value 1 -PropertyType DWORD -Force
shell: pwsh

- name: Install GitVersion
uses: gittools/actions/gitversion/setup@v4
with:
versionSpec: '6.7.x'

- name: Determine Version
id: gitversion
uses: gittools/actions/gitversion/execute@v4

# See the matching step in the modularpipeline job (issue #5622).
- name: Export version env vars
shell: bash
run: |
{
echo "Version=${{ steps.gitversion.outputs.semVer }}"
echo "AssemblyVersion=${{ steps.gitversion.outputs.assemblySemVer }}"
echo "FileVersion=${{ steps.gitversion.outputs.assemblySemFileVer }}"
echo "InformationalVersion=${{ steps.gitversion.outputs.informationalVersion }}"
echo "PackageVersion=${{ steps.gitversion.outputs.fullSemVer }}"
} >> "$GITHUB_ENV"

# Only what packing needs: every library project (packing reads the Roslyn variants from
# their own bin folders) and the pipeline itself.
- name: Build
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
if [ "$(jq '.solution.projects | length' libraries.slnf)" -eq 0 ]; then
echo "::error::No library projects found in TUnit.CI.slnx; update the filter in this step."
exit 1
fi
dotnet build libraries.slnf -c Release
dotnet build tools/TUnit.Pipeline/TUnit.Pipeline.csproj -c Release

- name: Run Pipeline
uses: ./.github/actions/execute-pipeline
with:
categories: Packaging NuGetPackageTests
admin-token: ${{ github.token }}
Comment thread
thomhurst marked this conversation as resolved.
Resolved

- name: Upload Diagnostic Logs
uses: actions/upload-artifact@v7.0.2
if: always()
with:
name: TestingPlatformDiagnosticLogs-nuget-package-tests-windows
path: '**/log_*.diag'

- name: Upload Hang Dumps
uses: actions/upload-artifact@v7.0.2
if: always()
with:
name: HangDump-nuget-package-tests-windows
path: '**/hangdump*'

# Compiles the C# fences in the documentation against freshly packed packages, alongside the
# test matrix rather than after the Ubuntu pipeline.
doc-snippets:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using ModularPipelines.Context;
using ModularPipelines.Attributes;
using ModularPipelines.Context;
using ModularPipelines.DotNet.Extensions;
using ModularPipelines.DotNet.Options;
using ModularPipelines.FileSystem;
Expand All @@ -7,6 +8,7 @@

namespace TUnit.Pipeline.Modules;

[ModuleCategory(PipelineCategories.Packaging)]
public class AddLocalNuGetRepositoryModule : Module<Folder>
{
protected override async Task<Folder?> ExecuteAsync(IModuleContext context, CancellationToken cancellationToken)
Expand Down
1 change: 1 addition & 0 deletions tools/TUnit.Pipeline/Modules/CopyToLocalNuGetModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using File = ModularPipelines.FileSystem.File;

namespace TUnit.Pipeline.Modules;
[ModuleCategory(PipelineCategories.Packaging)]
[DependsOn<PackTUnitFilesModule>]
[DependsOn<AddLocalNuGetRepositoryModule>]
public class CopyToLocalNuGetModule : Module<List<File>>
Expand Down
2 changes: 2 additions & 0 deletions tools/TUnit.Pipeline/Modules/GenerateVersionModule.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
using Microsoft.Extensions.Logging;
using ModularPipelines.Attributes;
using ModularPipelines.Context;
using ModularPipelines.Git.Extensions;
using ModularPipelines.Git.Models;
using ModularPipelines.Modules;

namespace TUnit.Pipeline.Modules;

[ModuleCategory(PipelineCategories.Packaging)]
public class GenerateVersionModule : Module<GitVersionInformation>
{
protected override async Task<GitVersionInformation?> ExecuteAsync(IModuleContext context, CancellationToken cancellationToken)
Expand Down
4 changes: 3 additions & 1 deletion tools/TUnit.Pipeline/Modules/GetPackageProjectsModule.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
using ModularPipelines.Context;
using ModularPipelines.Attributes;
using ModularPipelines.Context;
using ModularPipelines.Modules;
using File = ModularPipelines.FileSystem.File;

namespace TUnit.Pipeline.Modules;

[ModuleCategory(PipelineCategories.Packaging)]
public class GetPackageProjectsModule : Module<List<File>>
{
protected override async Task<List<File>?> ExecuteAsync(IModuleContext context, CancellationToken cancellationToken)
Expand Down
1 change: 1 addition & 0 deletions tools/TUnit.Pipeline/Modules/PackTUnitFilesModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ namespace TUnit.Pipeline.Modules;
// Version props come from $GITHUB_ENV (see .github/workflows/dotnet.yml) so recompiles
// also stamp the correct AssemblyVersion. See issue #5622. The AOT publishes build into
// their own artifacts trees, so they no longer touch those folders.
[ModuleCategory(PipelineCategories.Packaging)]
[DependsOn<GetPackageProjectsModule>]
[DependsOn<GenerateVersionModule>]
public class PackTUnitFilesModule : Module<List<PackedProject>>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

namespace TUnit.Pipeline.Modules;

[ModuleCategory(PipelineCategories.NuGetPackageTests)]
[DependsOn<TestNugetPackageModule>]
[DependsOn<GenerateVersionModule>]
[DependsOn<CopyToLocalNuGetModule>]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

namespace TUnit.Pipeline.Modules;

[ModuleCategory(PipelineCategories.NuGetPackageTests)]
[DependsOn<GenerateVersionModule>]
[DependsOn<CopyToLocalNuGetModule>]
public class TestAspNetCoreNugetPackageModule : TestBaseModule
Expand Down
3 changes: 3 additions & 0 deletions tools/TUnit.Pipeline/Modules/TestNugetPackageModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,21 @@

namespace TUnit.Pipeline.Modules;

[ModuleCategory(PipelineCategories.NuGetPackageTests)]
[NotInParallel("NugetTester")]
public class TestNugetPackageModule : AbstractTestNugetPackageModule
{
public override string ProjectName => "TUnit.NugetTester.csproj";
}

[ModuleCategory(PipelineCategories.NuGetPackageTests)]
[NotInParallel("NugetTester")]
public class TestFSharpNugetPackageModule : AbstractTestNugetPackageModule
{
public override string ProjectName => "TUnit.NugetTester.FSharp.fsproj";
}

[ModuleCategory(PipelineCategories.NuGetPackageTests)]
[NotInParallel("NugetTester")]
public class TestVBNugetPackageModule : AbstractTestNugetPackageModule
{
Expand Down
1 change: 1 addition & 0 deletions tools/TUnit.Pipeline/Modules/TestTemplatePackageModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

namespace TUnit.Pipeline.Modules;

[ModuleCategory(PipelineCategories.NuGetPackageTests)]
[DependsOn<CopyToLocalNuGetModule>]
[DependsOn<GenerateVersionModule>]
public class TestTemplatePackageModule : Module<CommandResult>
Expand Down
13 changes: 13 additions & 0 deletions tools/TUnit.Pipeline/PipelineCategories.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
namespace TUnit.Pipeline;

/// <summary>
/// Module categories, selected with --categories or skipped with --ignore-categories.
/// </summary>
public static class PipelineCategories
{
/// <summary>Versions, packs and stages the NuGet packages.</summary>
public const string Packaging = "Packaging";

/// <summary>Consumes the packed packages. Windows runs these in their own job (see dotnet.yml).</summary>
public const string NuGetPackageTests = "NuGetPackageTests";
}
20 changes: 19 additions & 1 deletion tools/TUnit.Pipeline/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,29 @@
DefaultValueFactory = _ => []
};

var ignoreCategoryOption = new Option<string[]>(
name: "--ignore-categories")
{
Arity = ArgumentArity.ZeroOrMore,
AllowMultipleArgumentsPerToken = true,
Description = "Categories to skip. Cannot be combined with --categories.",
DefaultValueFactory = _ => []
};

var rootCommand = new RootCommand("The pipeline for building, testing and packaging TUnit");
rootCommand.Add(categoryOption);
rootCommand.Add(ignoreCategoryOption);
rootCommand.Validators.Add(result =>
{
if (result.GetValue(categoryOption) is { Length: > 0 } && result.GetValue(ignoreCategoryOption) is { Length: > 0 })
{
result.AddError("--ignore-categories cannot be combined with --categories.");
}
});
rootCommand.SetAction(async parseResult =>
{
var categories = parseResult.GetValue(categoryOption)!;
var ignoreCategories = parseResult.GetValue(ignoreCategoryOption)!;

var builder = Pipeline.CreateBuilder();
builder.Configuration.AddEnvironmentVariables();
Expand All @@ -33,7 +51,7 @@
}
else
{
builder.IgnoreCategories("ReadMe");
builder.IgnoreCategories(["ReadMe", ..ignoreCategories]);
}

await builder.Build().RunAsync();
Expand Down
Loading