4
4
using Logicality . GitHub . Actions . Workflow ;
5
5
using System . ComponentModel ;
6
6
using System . IO ;
7
+ using System . Net . WebSockets ;
7
8
using static GitHubContexts ;
8
9
9
10
var contexts = Instance ;
33
34
{
34
35
GenerateCiWorkflow ( component ) ;
35
36
GenerateReleaseWorkflow ( component ) ;
36
- GenerateUploadTestResultsWorkflow ( component ) ;
37
37
}
38
38
39
+ GenerateUploadTestResultsWorkflow ( ) ;
40
+
41
+
39
42
void GenerateCiWorkflow ( Component component )
40
43
{
41
44
var workflow = new Workflow ( component . CiWorkflowName ) ;
@@ -175,12 +178,12 @@ git tag -a {component.TagPrefix}-{contexts.Event.Input.Version} -m ""Release v{c
175
178
WriteWorkflow ( workflow , fileName ) ;
176
179
}
177
180
178
- void GenerateUploadTestResultsWorkflow ( Component component )
181
+ void GenerateUploadTestResultsWorkflow ( )
179
182
{
180
- var workflow = new Workflow ( component . TestResultWorkflowName ) ;
183
+ var workflow = new Workflow ( "generate-test-reports" ) ;
181
184
workflow . On
182
185
. WorkflowRun ( )
183
- . Workflows ( component . TestResultWorkflowName )
186
+ . Workflows ( components . Select ( x => x . CiWorkflowName ) . ToArray ( ) )
184
187
. Types ( "completed" ) ;
185
188
186
189
var job = workflow
@@ -194,11 +197,16 @@ void GenerateUploadTestResultsWorkflow(Component component)
194
197
checks : Permission . Write ,
195
198
packages : Permission . Write ) ;
196
199
197
- foreach ( var testProject in component . Tests )
200
+ foreach ( var component in components )
198
201
{
199
- job . StepGenerateReportFromTestArtifact ( component . Name , testProject ) ;
202
+ foreach ( var testProject in component . Tests )
203
+ {
204
+ job . StepGenerateReportFromTestArtifact ( component , testProject ) ;
205
+ }
200
206
}
201
207
208
+ var fileName = $ "generate-test-reports";
209
+ WriteWorkflow ( workflow , fileName ) ;
202
210
}
203
211
204
212
void WriteWorkflow ( Workflow workflow , string fileName )
@@ -279,17 +287,17 @@ public static void StepUploadTestResultsAsArtifact(this Job job, string[] testPr
279
287
( "retention-days" , "5" ) ) ;
280
288
}
281
289
282
- public static void StepGenerateReportFromTestArtifact ( this Job job , string componentName , string testProject )
290
+ internal static void StepGenerateReportFromTestArtifact ( this Job job , Component component , string testProject )
283
291
{
284
292
var path = $ "test/{ testProject } ";
285
293
job . Step ( )
286
- . Name ( $ "Test report - { testProject } ")
294
+ . Name ( $ "Test report - { component . Name } - { testProject } ")
287
295
. Uses ( "dorny/test-reporter@31a54ee7ebcacc03a09ea97a7e5465a47b84aea5" ) // v1.9.1
288
- . If ( "github.event == 'push' && (success() || failure()) " )
296
+ . If ( $ "github.event.workflow_run.workflow == '{ component . CiWorkflowName } ' ")
289
297
. With (
290
298
( "artifact" , "test-results" ) ,
291
299
( "name" , $ "Test Report - { testProject } ") ,
292
- ( "path" , $ "{ componentName } /{ path } /TestResults/{ LogFileName } ") ,
300
+ ( "path" , $ "{ component . Name } /{ path } /TestResults/{ LogFileName } ") ,
293
301
( "reporter" , "dotnet-trx" ) ,
294
302
( "fail-on-error" , "true" ) ,
295
303
( "fail-on-empty" , "true" ) ) ;
0 commit comments