From aa0ce5d9eae9e573c06c2298cab0248345745347 Mon Sep 17 00:00:00 2001 From: Tom Longhurst <30480171+thomhurst@users.noreply.github.com> Date: Sun, 14 Jul 2024 17:55:30 +0100 Subject: [PATCH] Fix --- ...verageFromOtherOperatingSystemBuildsModule.cs | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/src/ModularPipelines.Build/Modules/DownloadCodeCoverageFromOtherOperatingSystemBuildsModule.cs b/src/ModularPipelines.Build/Modules/DownloadCodeCoverageFromOtherOperatingSystemBuildsModule.cs index 3d47cf315b..5ee7398bce 100644 --- a/src/ModularPipelines.Build/Modules/DownloadCodeCoverageFromOtherOperatingSystemBuildsModule.cs +++ b/src/ModularPipelines.Build/Modules/DownloadCodeCoverageFromOtherOperatingSystemBuildsModule.cs @@ -5,6 +5,7 @@ using ModularPipelines.Context; using ModularPipelines.FileSystem; using ModularPipelines.GitHub.Attributes; +using ModularPipelines.GitHub.Extensions; using ModularPipelines.Modules; using Octokit; using File = ModularPipelines.FileSystem.File; @@ -17,13 +18,6 @@ namespace ModularPipelines.Build.Modules; [DependsOn] public class DownloadCodeCoverageFromOtherOperatingSystemBuildsModule : Module> { - private readonly IGitHubClient _gitHubClient; - - public DownloadCodeCoverageFromOtherOperatingSystemBuildsModule(IGitHubClient gitHubClient) - { - _gitHubClient = gitHubClient; - } - /// protected override async Task?> ExecuteAsync(IPipelineContext context, CancellationToken cancellationToken) { @@ -38,7 +32,7 @@ public DownloadCodeCoverageFromOtherOperatingSystemBuildsModule(IGitHubClient gi var artifacts = await runs.Value!.ToAsyncProcessorBuilder() .SelectAsync(async run => { - var listWorkflowArtifacts = await _gitHubClient.Actions.Artifacts.ListWorkflowArtifacts(BuildConstants.Owner, + var listWorkflowArtifacts = await context.GitHub().Client.Actions.Artifacts.ListWorkflowArtifacts(BuildConstants.Owner, BuildConstants.RepositoryName, run.Id); return listWorkflowArtifacts.Artifacts.FirstOrDefault(x => x.Name == "code-coverage") ?? throw new ArgumentException("No code-coverage artifact found"); @@ -47,7 +41,7 @@ public DownloadCodeCoverageFromOtherOperatingSystemBuildsModule(IGitHubClient gi var zipFiles = await artifacts .ToAsyncProcessorBuilder() - .SelectAsync(DownloadZip) + .SelectAsync(x => DownloadZip(context.GitHub().Client, x)) .ProcessInParallel(); return zipFiles.Select(x => context.Zip.UnZipToFolder(x, Folder.CreateTemporaryFolder())) @@ -55,9 +49,9 @@ public DownloadCodeCoverageFromOtherOperatingSystemBuildsModule(IGitHubClient gi .ToList(); } - private async Task DownloadZip(Artifact artifact) + private async Task DownloadZip(IGitHubClient gitHubClient, Artifact artifact) { - var zipStream = await _gitHubClient.Actions.Artifacts.DownloadArtifact(BuildConstants.Owner, + var zipStream = await gitHubClient.Actions.Artifacts.DownloadArtifact(BuildConstants.Owner, BuildConstants.RepositoryName, artifact.Id, "zip");