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
27 changes: 26 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,31 @@ jobs:
./Artifacts/*
./TestResults/*.trx

mutation-tests-core:
name: "Mutation tests (aweXpect.Core)"
runs-on: ubuntu-latest
env:
STRYKER_DASHBOARD_API_KEY: ${{ secrets.STRYKER_DASHBOARD_API_KEY }}
DOTNET_NOLOGO: true
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Setup .NET SDKs
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
8.0.x
- name: Run mutation tests
run: ./build.sh MutationTestsCore
- name: Upload artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: MutationTestsCore
path: |
./Artifacts/*

mutation-tests-main:
name: "Mutation tests (aweXpect)"
runs-on: ubuntu-latest
Expand Down Expand Up @@ -91,7 +116,7 @@ jobs:

mutation-tests-dashboard:
name: "Mutation tests Dashboard"
needs: [ mutation-tests-main ]
needs: [ mutation-tests-main, mutation-tests-core ]
runs-on: ubuntu-latest
env:
STRYKER_DASHBOARD_API_KEY: ${{ secrets.STRYKER_DASHBOARD_API_KEY }}
Expand Down
48 changes: 34 additions & 14 deletions Pipeline/Build.MutationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,22 @@ partial class Build
Target MutationTestsCore => _ => _
.DependsOn(Compile)
.OnlyWhenDynamic(() => BuildScope == BuildScope.Default)
.OnlyWhenDynamic(() => BranchName != "main")
Comment thread
vbreuss marked this conversation as resolved.
.Executes(() =>
{
ExecuteMutationTest(Solution.aweXpect_Core, [..FrameworkUnitTestProjects, Solution.Tests.aweXpect_Core_Tests,]);
ExecuteMutationTest(Solution.aweXpect_Core,
[..FrameworkUnitTestProjects, Solution.Tests.aweXpect_Core_Tests,]);
});

Target MutationTestsMain => _ => _
.DependsOn(Compile)
.OnlyWhenDynamic(() => BuildScope == BuildScope.Default)
.Executes(() =>
{
ExecuteMutationTest(Solution.aweXpect, [Solution.Tests.aweXpect_Tests, Solution.Tests.aweXpect_Internal_Tests,]);
ExecuteMutationTest(Solution.aweXpect,
[Solution.Tests.aweXpect_Tests, Solution.Tests.aweXpect_Internal_Tests,]);
});

Target MutationTestsComment => _ => _
.After(MutationTestsMain)
.After(MutationTestsCore)
Expand All @@ -51,13 +55,13 @@ partial class Build
{
Log.Debug("Missing PR.txt file in artifacts");
}

string prNumber = File.ReadAllText(ArtifactsDirectory / "aweXpect" / "PR.txt");
Log.Debug("Pull request number: {PullRequestId}", prNumber);
var mutationCommentBodies = new List<string>();
foreach (var file in ArtifactsDirectory.GetFiles("MutationTest_*.md", 2))
List<string> mutationCommentBodies = [];
foreach (AbsolutePath file in ArtifactsDirectory.GetFiles("MutationTest_*.md", 2))
{
var body = await File.ReadAllTextAsync(file);
string body = await File.ReadAllTextAsync(file);
mutationCommentBodies.Add(body);
}

Expand Down Expand Up @@ -116,21 +120,36 @@ await gitHubClient.Issue.Comment.Update("aweXpect", "aweXpect",
await "MutationTestsCore".DownloadArtifactTo(ArtifactsDirectory / "aweXpect.Core", GithubToken);
await "MutationTestsMain".DownloadArtifactTo(ArtifactsDirectory / "aweXpect", GithubToken);

Dictionary<Project, Project[]> projects = new()
Dictionary<Project, Project[]> projects;
if (BranchName != "main")
Comment thread
vbreuss marked this conversation as resolved.
{
projects = new Dictionary<Project, Project[]>
{
Solution.aweXpect, [Solution.Tests.aweXpect_Tests, Solution.Tests.aweXpect_Internal_Tests,]
},
{
Solution.aweXpect, [Solution.Tests.aweXpect_Tests, Solution.Tests.aweXpect_Internal_Tests,]
},
{
Solution.aweXpect_Core, [..FrameworkUnitTestProjects, Solution.Tests.aweXpect_Core_Tests,]
},
};
}
else
{
projects = new Dictionary<Project, Project[]>
{
Solution.aweXpect_Core, [..FrameworkUnitTestProjects, Solution.Tests.aweXpect_Core_Tests,]
},
};
{
Solution.aweXpect, [Solution.Tests.aweXpect_Tests, Solution.Tests.aweXpect_Internal_Tests,]
},
};
}

string apiKey = Environment.GetEnvironmentVariable("STRYKER_DASHBOARD_API_KEY");
foreach (KeyValuePair<Project, Project[]> project in projects)
{
string branchName = File.ReadAllText(ArtifactsDirectory / project.Key.Name / "BranchName.txt");
string reportComment =
File.ReadAllText(ArtifactsDirectory / project.Key.Name / "Stryker" / "reports" / "mutation-report.json");
File.ReadAllText(ArtifactsDirectory / project.Key.Name / "Stryker" / "reports" /
"mutation-report.json");
using HttpClient client = new();
client.DefaultRequestHeaders.Add("X-Api-Key", apiKey);
// https://stryker-mutator.io/docs/General/dashboard/#send-a-report-via-curl
Expand Down Expand Up @@ -204,7 +223,8 @@ private void ExecuteMutationTest(Project project, Project[] testProjects)
$"Stryker did not execute successfully for {project.Name}: (exit code {process.ExitCode}).");
}

File.WriteAllText(ArtifactsDirectory / $"MutationTest_{project.Name}.md", CreateMutationCommentBody(project.Name));
File.WriteAllText(ArtifactsDirectory / $"MutationTest_{project.Name}.md",
CreateMutationCommentBody(project.Name));

if (GitHubActions?.IsPullRequest == true)
{
Expand Down
Loading