Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
thomhurst committed Jul 14, 2024
1 parent 05aa4be commit aa0ce5d
Showing 1 changed file with 5 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -17,13 +18,6 @@ namespace ModularPipelines.Build.Modules;
[DependsOn<WaitForOtherOperatingSystemBuilds>]
public class DownloadCodeCoverageFromOtherOperatingSystemBuildsModule : Module<List<File>>
{
private readonly IGitHubClient _gitHubClient;

public DownloadCodeCoverageFromOtherOperatingSystemBuildsModule(IGitHubClient gitHubClient)
{
_gitHubClient = gitHubClient;
}

/// <inheritdoc/>
protected override async Task<List<File>?> ExecuteAsync(IPipelineContext context, CancellationToken cancellationToken)
{
Expand All @@ -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");
Expand All @@ -47,17 +41,17 @@ 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()))
.SelectMany(x => x.GetFiles(f => f.Extension == ".xml" && f.Name.Contains("cobertura")))
.ToList();
}

private async Task<File> DownloadZip(Artifact artifact)
private async Task<File> 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");

Expand Down

0 comments on commit aa0ce5d

Please sign in to comment.