Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 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
11 changes: 0 additions & 11 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@ jobs:
runs-on: ${{ matrix.os }}
timeout-minutes: 60

env:
# HACK Running on Windows instead of Linux due to https://github.com/stryker-mutator/stryker-net/issues/2741
RUN_MUTATION_TESTS: ${{ matrix.os_name == 'windows' && !startsWith(github.ref, 'refs/tags/') && 'true' || 'false' }}

outputs:
dotnet-sdk-version: ${{ steps.setup-dotnet.outputs.dotnet-version }}
dotnet-sign-version: ${{ steps.get-dotnet-tools-versions.outputs.dotnet-sign-version }}
Expand Down Expand Up @@ -94,13 +90,6 @@ jobs:
flags: ${{ matrix.os_name }}
token: ${{ secrets.CODECOV_TOKEN }}

- name: Upload Mutation Report
if: always() && env.RUN_MUTATION_TESTS == 'true'
uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0
with:
name: mutation-report
path: ./artifacts/mutation-report

- name: Publish NuGet packages
uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0
with:
Expand Down
63 changes: 63 additions & 0 deletions .github/workflows/mutation-tests-core.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: mutation-tests-core

on:
push:
branches: [ main, release/* ]
tags: [ '*' ]
pull_request:
branches: [ main, release/* ]
workflow_dispatch:

env:
DOTNET_CLI_TELEMETRY_OPTOUT: true
DOTNET_GENERATE_ASPNET_CERTIFICATE: false
DOTNET_NOLOGO: true
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
DOTNET_SYSTEM_CONSOLE_ALLOW_ANSI_COLOR_REDIRECTION: 1
NUGET_XMLDOC_MODE: skip
TERM: xterm

permissions:
contents: read

jobs:
build:
name: Run Mutation Test
runs-on: windows-latest
timeout-minutes: 60

steps:

- name: Checkout code
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
with:
fetch-depth: 0

- name: Setup .NET SDKs
uses: actions/setup-dotnet@6bd8b7f7774af54e05809fcc5431931b3eb1ddee # v4.0.1
with:
dotnet-version: |
6.0.x
- name: Setup .NET SDK
uses: actions/setup-dotnet@6bd8b7f7774af54e05809fcc5431931b3eb1ddee # v4.0.1
id: setup-dotnet

- name: Setup NuGet cache
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj', '**/*.props') }}
restore-keys: ${{ runner.os }}-nuget-

- name: Build and Run Mutation Tests
id: build
shell: pwsh
run: ./build.ps1 -Target MutationCore

- name: Upload Mutation Report
if: always()
uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0
with:
name: mutation-report-core
path: ./artifacts/mutation-report
63 changes: 63 additions & 0 deletions .github/workflows/mutation-tests-legacy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: mutation-tests-legacy

on:
push:
branches: [ main, release/* ]
tags: [ '*' ]
pull_request:
branches: [ main, release/* ]
workflow_dispatch:

env:
DOTNET_CLI_TELEMETRY_OPTOUT: true
DOTNET_GENERATE_ASPNET_CERTIFICATE: false
DOTNET_NOLOGO: true
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
DOTNET_SYSTEM_CONSOLE_ALLOW_ANSI_COLOR_REDIRECTION: 1
NUGET_XMLDOC_MODE: skip
TERM: xterm

permissions:
contents: read

jobs:
build:
name: Run Mutation Test
runs-on: windows-latest
timeout-minutes: 60

steps:

- name: Checkout code
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
with:
fetch-depth: 0

- name: Setup .NET SDKs
uses: actions/setup-dotnet@6bd8b7f7774af54e05809fcc5431931b3eb1ddee # v4.0.1
with:
dotnet-version: |
6.0.x

- name: Setup .NET SDK
uses: actions/setup-dotnet@6bd8b7f7774af54e05809fcc5431931b3eb1ddee # v4.0.1
id: setup-dotnet

- name: Setup NuGet cache
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj', '**/*.props') }}
restore-keys: ${{ runner.os }}-nuget-

- name: Build and Run Mutation Tests
id: build
shell: pwsh
run: ./build.ps1 -Target MutationLegacy

- name: Upload Mutation Report
if: always()
uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0
with:
name: mutation-report-legacy
path: ./artifacts/mutation-report
99 changes: 54 additions & 45 deletions build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -159,56 +159,29 @@ Task("__RunTests")
}
});

Task("__RunMutationTests")
Task("__RunCoreMutationTests")
.Does((context) =>
{
var runMutationTests = EnvironmentVariable("RUN_MUTATION_TESTS") switch
{
"false" => false,
_ => true
};

if (!runMutationTests)
{
return;
}

var oldDirectory = context.Environment.WorkingDirectory;
context.Environment.WorkingDirectory = MakeAbsolute(Directory("test"));

TestProject(File("../src/Polly.Core/Polly.Core.csproj"), File("./Polly.Core.Tests/Polly.Core.Tests.csproj"), "Polly.Core.csproj");
TestProject(File("../src/Polly.RateLimiting/Polly.RateLimiting.csproj"), File("./Polly.RateLimiting.Tests/Polly.RateLimiting.Tests.csproj"), "Polly.RateLimiting.csproj");
TestProject(File("../src/Polly.Extensions/Polly.Extensions.csproj"), File("./Polly.Extensions.Tests/Polly.Extensions.Tests.csproj"), "Polly.Extensions.csproj");
TestProject(File("../src/Polly.Testing/Polly.Testing.csproj"), File("./Polly.Testing.Tests/Polly.Testing.Tests.csproj"), "Polly.Testing.csproj");
TestProject(File("../src/Polly/Polly.csproj"), File("./Polly.Specs/Polly.Specs.csproj"), "Polly.csproj");
MutationTestProject(File("../src/Polly.Core/Polly.Core.csproj"), File("./Polly.Core.Tests/Polly.Core.Tests.csproj"), "Polly.Core.csproj");
MutationTestProject(File("../src/Polly.RateLimiting/Polly.RateLimiting.csproj"), File("./Polly.RateLimiting.Tests/Polly.RateLimiting.Tests.csproj"), "Polly.RateLimiting.csproj");
MutationTestProject(File("../src/Polly.Extensions/Polly.Extensions.csproj"), File("./Polly.Extensions.Tests/Polly.Extensions.Tests.csproj"), "Polly.Extensions.csproj");
MutationTestProject(File("../src/Polly.Testing/Polly.Testing.csproj"), File("./Polly.Testing.Tests/Polly.Testing.Tests.csproj"), "Polly.Testing.csproj");

context.Environment.WorkingDirectory = oldDirectory;
});

void TestProject(FilePath proj, FilePath testProj, string project)
{
var dotNetBuildSettings = new DotNetBuildSettings
{
Configuration = "Debug",
Verbosity = DotNetVerbosity.Minimal,
NoRestore = true
};

DotNetBuild(proj.ToString(), dotNetBuildSettings);

var strykerPath = Context.Tools.Resolve("Stryker.CLI.dll");
var mutationScore = XmlPeek(proj, "/Project/PropertyGroup/MutationScore/text()", new XmlPeekSettings { SuppressWarning = true });
var score = int.Parse(mutationScore);

Information($"Running mutation tests for '{proj}'. Test Project: '{testProj}'");
Task("__RunLegacyMutationTests")
.Does((context) =>
{
var oldDirectory = context.Environment.WorkingDirectory;
context.Environment.WorkingDirectory = MakeAbsolute(Directory("test"));

var args = $"{strykerPath} --project {project} --test-project {testProj.FullPath} --break-at {score} --config-file {strykerConfig} --output {strykerOutput}/{project}";
MutationTestProject(File("../src/Polly/Polly.csproj"), File("./Polly.Specs/Polly.Specs.csproj"), "Polly.csproj");

var result = StartProcess("dotnet", args);
if (result != 0)
{
throw new InvalidOperationException($"The mutation testing of '{project}' project failed.");
}
}
context.Environment.WorkingDirectory = oldDirectory;
});

Task("__CreateNuGetPackages")
Expand Down Expand Up @@ -252,18 +225,20 @@ Task("__ValidateDocs")
}
});

Task("__CommonBuild")
.IsDependentOn("__Clean")
.IsDependentOn("__RestoreNuGetPackages")
.IsDependentOn("__ValidateDocs")
.IsDependentOn("__BuildSolutions");

//////////////////////////////////////////////////////////////////////
// BUILD TASKS
//////////////////////////////////////////////////////////////////////

Task("Build")
.IsDependentOn("__Clean")
.IsDependentOn("__RestoreNuGetPackages")
.IsDependentOn("__ValidateDocs")
.IsDependentOn("__BuildSolutions")
.IsDependentOn("__CommonBuild")
.IsDependentOn("__ValidateAot")
.IsDependentOn("__RunTests")
.IsDependentOn("__RunMutationTests")
.IsDependentOn("__CreateNuGetPackages");

///////////////////////////////////////////////////////////////////////////////
Expand All @@ -273,6 +248,14 @@ Task("Build")
Task("Default")
.IsDependentOn("Build");

Task("MutationCore")
.IsDependentOn("__CommonBuild")
.IsDependentOn("__RunCoreMutationTests");

Task("MutationLegacy")
.IsDependentOn("__CommonBuild")
.IsDependentOn("__RunLegacyMutationTests");

///////////////////////////////////////////////////////////////////////////////
// EXECUTION
///////////////////////////////////////////////////////////////////////////////
Expand All @@ -287,3 +270,29 @@ string ToolsExePath(string exeFileName) {
var exePath = System.IO.Directory.GetFiles("./tools", exeFileName, SearchOption.AllDirectories).FirstOrDefault();
return exePath;
}

void MutationTestProject(FilePath proj, FilePath testProj, string project)
{
var dotNetBuildSettings = new DotNetBuildSettings
{
Configuration = "Debug",
Verbosity = DotNetVerbosity.Minimal,
NoRestore = true
};

DotNetBuild(proj.ToString(), dotNetBuildSettings);

var strykerPath = Context.Tools.Resolve("Stryker.CLI.dll");
var mutationScore = XmlPeek(proj, "/Project/PropertyGroup/MutationScore/text()", new XmlPeekSettings { SuppressWarning = true });
var score = int.Parse(mutationScore);

Information($"Running mutation tests for '{proj}'. Test Project: '{testProj}'");

var args = $"{strykerPath} --project {project} --test-project {testProj.FullPath} --break-at {score} --config-file {strykerConfig} --output {strykerOutput}/{project}";

var result = StartProcess("dotnet", args);
if (result != 0)
{
throw new InvalidOperationException($"The mutation testing of '{project}' project failed.");
}
}
1 change: 1 addition & 0 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ https://cakebuild.net
Param(
[string]$Script = "build.cake",
[string]$Target = "Default",
[ValidateSet("Default", "MutationCore", "MutationLegacy")]
[string]$Configuration = "Release",
[ValidateSet("Quiet", "Minimal", "Normal", "Verbose", "Diagnostic")]
[string]$Verbosity = "Verbose",
Expand Down