From d5d016b7699368d53e33d97679883627e240ae1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Valentin=20Breu=C3=9F?= Date: Wed, 13 Aug 2025 18:36:43 +0200 Subject: [PATCH] fix: error in build pipeline - Only write PR.txt when the build runs as part of a pull request - Execute the MutationTestsComment in the CI-Analysis step - Extract artifacts to separate directories so as not to overwrite the mutation-report.json files --- Pipeline/Build.MutationTests.cs | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/Pipeline/Build.MutationTests.cs b/Pipeline/Build.MutationTests.cs index cbe04c3f9..8254da73d 100644 --- a/Pipeline/Build.MutationTests.cs +++ b/Pipeline/Build.MutationTests.cs @@ -44,18 +44,17 @@ partial class Build .After(MutationTestsMain) .After(MutationTestsCore) .DependsOn(MutationTestsDashboard) - .OnlyWhenDynamic(() => GitHubActions.IsPullRequest) .Executes(async () => { - if (!File.Exists(ArtifactsDirectory / "PR.txt")) + if (!File.Exists(ArtifactsDirectory / "aweXpect" / "PR.txt")) { Log.Debug("Missing PR.txt file in artifacts"); } - string prNumber = File.ReadAllText(ArtifactsDirectory / "PR.txt"); + string prNumber = File.ReadAllText(ArtifactsDirectory / "aweXpect" / "PR.txt"); Log.Debug("Pull request number: {PullRequestId}", prNumber); var mutationCommentBodies = new List(); - foreach (var file in ArtifactsDirectory.GetFiles("MutationTest_*.md")) + foreach (var file in ArtifactsDirectory.GetFiles("MutationTest_*.md", 2)) { var body = await File.ReadAllTextAsync(file); mutationCommentBodies.Add(body); @@ -63,6 +62,7 @@ partial class Build if (mutationCommentBodies.Count == 0) { + Log.Warning("No files matching \"MutationTest_*.md\" found"); return; } @@ -112,8 +112,8 @@ await gitHubClient.Issue.Comment.Update("aweXpect", "aweXpect", .Executes(async () => { ArtifactsDirectory.CreateDirectory(); - await "MutationTestsCore".DownloadArtifactTo(ArtifactsDirectory, GithubToken); - await "MutationTestsMain".DownloadArtifactTo(ArtifactsDirectory, GithubToken); + await "MutationTestsCore".DownloadArtifactTo(ArtifactsDirectory / "aweXpect.Core", GithubToken); + await "MutationTestsMain".DownloadArtifactTo(ArtifactsDirectory / "aweXpect", GithubToken); Dictionary projects = new() { @@ -125,11 +125,11 @@ await gitHubClient.Issue.Comment.Update("aweXpect", "aweXpect", }, }; string apiKey = Environment.GetEnvironmentVariable("STRYKER_DASHBOARD_API_KEY"); - string branchName = File.ReadAllText(ArtifactsDirectory / "BranchName.txt"); foreach (KeyValuePair project in projects) { + string branchName = File.ReadAllText(ArtifactsDirectory / project.Key.Name / "BranchName.txt"); string reportComment = - File.ReadAllText(ArtifactsDirectory / "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 @@ -205,11 +205,11 @@ private void ExecuteMutationTest(Project project, Project[] testProjects) } File.WriteAllText(ArtifactsDirectory / $"MutationTest_{project.Name}.md", CreateMutationCommentBody(project.Name)); - - int? prId = GitHubActions?.PullRequestNumber; - if (prId != null) + + if (GitHubActions?.IsPullRequest == true) { - File.WriteAllText(ArtifactsDirectory / "PR.txt", prId.Value.ToString()); + Log.Information($"Write pull request number to PR.txt: {GitHubActions?.PullRequestNumber}"); + File.WriteAllText(ArtifactsDirectory / "PR.txt", GitHubActions?.PullRequestNumber?.ToString()); } }