Skip to content

Commit aa0ce5d

Browse files
committed
Fix
1 parent 05aa4be commit aa0ce5d

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

src/ModularPipelines.Build/Modules/DownloadCodeCoverageFromOtherOperatingSystemBuildsModule.cs

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using ModularPipelines.Context;
66
using ModularPipelines.FileSystem;
77
using ModularPipelines.GitHub.Attributes;
8+
using ModularPipelines.GitHub.Extensions;
89
using ModularPipelines.Modules;
910
using Octokit;
1011
using File = ModularPipelines.FileSystem.File;
@@ -17,13 +18,6 @@ namespace ModularPipelines.Build.Modules;
1718
[DependsOn<WaitForOtherOperatingSystemBuilds>]
1819
public class DownloadCodeCoverageFromOtherOperatingSystemBuildsModule : Module<List<File>>
1920
{
20-
private readonly IGitHubClient _gitHubClient;
21-
22-
public DownloadCodeCoverageFromOtherOperatingSystemBuildsModule(IGitHubClient gitHubClient)
23-
{
24-
_gitHubClient = gitHubClient;
25-
}
26-
2721
/// <inheritdoc/>
2822
protected override async Task<List<File>?> ExecuteAsync(IPipelineContext context, CancellationToken cancellationToken)
2923
{
@@ -38,7 +32,7 @@ public DownloadCodeCoverageFromOtherOperatingSystemBuildsModule(IGitHubClient gi
3832
var artifacts = await runs.Value!.ToAsyncProcessorBuilder()
3933
.SelectAsync(async run =>
4034
{
41-
var listWorkflowArtifacts = await _gitHubClient.Actions.Artifacts.ListWorkflowArtifacts(BuildConstants.Owner,
35+
var listWorkflowArtifacts = await context.GitHub().Client.Actions.Artifacts.ListWorkflowArtifacts(BuildConstants.Owner,
4236
BuildConstants.RepositoryName, run.Id);
4337

4438
return listWorkflowArtifacts.Artifacts.FirstOrDefault(x => x.Name == "code-coverage") ?? throw new ArgumentException("No code-coverage artifact found");
@@ -47,17 +41,17 @@ public DownloadCodeCoverageFromOtherOperatingSystemBuildsModule(IGitHubClient gi
4741

4842
var zipFiles = await artifacts
4943
.ToAsyncProcessorBuilder()
50-
.SelectAsync(DownloadZip)
44+
.SelectAsync(x => DownloadZip(context.GitHub().Client, x))
5145
.ProcessInParallel();
5246

5347
return zipFiles.Select(x => context.Zip.UnZipToFolder(x, Folder.CreateTemporaryFolder()))
5448
.SelectMany(x => x.GetFiles(f => f.Extension == ".xml" && f.Name.Contains("cobertura")))
5549
.ToList();
5650
}
5751

58-
private async Task<File> DownloadZip(Artifact artifact)
52+
private async Task<File> DownloadZip(IGitHubClient gitHubClient, Artifact artifact)
5953
{
60-
var zipStream = await _gitHubClient.Actions.Artifacts.DownloadArtifact(BuildConstants.Owner,
54+
var zipStream = await gitHubClient.Actions.Artifacts.DownloadArtifact(BuildConstants.Owner,
6155
BuildConstants.RepositoryName,
6256
artifact.Id, "zip");
6357

0 commit comments

Comments
 (0)