55using ModularPipelines . Context ;
66using ModularPipelines . FileSystem ;
77using ModularPipelines . GitHub . Attributes ;
8+ using ModularPipelines . GitHub . Extensions ;
89using ModularPipelines . Modules ;
910using Octokit ;
1011using File = ModularPipelines . FileSystem . File ;
@@ -17,13 +18,6 @@ namespace ModularPipelines.Build.Modules;
1718[ DependsOn < WaitForOtherOperatingSystemBuilds > ]
1819public 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