99 new ( "ignore-this" ,
1010 [ "IgnoreThis" ] ,
1111 [ "IgnoreThis.Tests" ] ,
12- "it" ) ,
12+ "it" ,
13+ [ GitHubHostedRunners . UbuntuLatest ] ) ,
1314
1415 new ( "access-token-management" ,
1516 [ "AccessTokenManagement" , "AccessTokenManagement.OpenIdConnect" ] ,
1617 [ "AccessTokenManagement.Tests" ] ,
17- "atm" ) ,
18+ "atm" ,
19+ [ GitHubHostedRunners . UbuntuLatest ] ) ,
1820
1921 new ( "identity-model" ,
2022 [ "IdentityModel" ] ,
2123 [ "IdentityModel.Tests" ] ,
22- "im" ) ,
24+ "im" ,
25+ [ GitHubHostedRunners . UbuntuLatest , GitHubHostedRunners . WindowsLatest ] ) ,
2326
2427 new ( "identity-model-oidc-client" ,
2528 [ "IdentityModel.OidcClient" , "IdentityModel.OidcClient.Extensions" ] ,
2629 [ "IdentityModel.OidcClient.Tests" ] ,
27- "imoc" ) ,
30+ "imoc" ,
31+ [ GitHubHostedRunners . UbuntuLatest ] ) ,
2832
2933 new ( "introspection" ,
3034 [ "AspNetCore.Authentication.OAuth2Introspection" ] ,
3135 [ "AspNetCore.Authentication.OAuth2Introspection.Tests" ] ,
32- "intro" ) ,
36+ "intro" ,
37+ [ GitHubHostedRunners . UbuntuLatest ] ) ,
3338] ;
3439
3540foreach ( var component in components )
@@ -68,8 +73,22 @@ void GenerateCiWorkflow(Component component)
6873
6974 var job = workflow
7075 . Job ( "build" )
71- . Name ( "Build" )
72- . RunsOn ( GitHubHostedRunners . UbuntuLatest )
76+ . Name ( "Build" ) ;
77+
78+ if ( component . RunsOn . Length == 1 )
79+ {
80+ job . RunsOn ( component . RunsOn [ 0 ] ) ;
81+ }
82+ else
83+ {
84+ job . Strategy ( )
85+ . Matrix ( ( "os" , component . RunsOn ) )
86+ . FailFast ( false )
87+ . Job
88+ . RunsOn ( "${{ matrix.os }}" ) ;
89+ }
90+
91+ job = job
7392 . Defaults ( ) . Run ( "bash" , component . Name )
7493 . Job ;
7594
@@ -90,12 +109,23 @@ void GenerateCiWorkflow(Component component)
90109
91110 job . StepVerifyFormatting ( ) ;
92111
112+ var runsOnIncludesWindows = component . RunsOn . Contains ( GitHubHostedRunners . WindowsLatest ) ;
93113 foreach ( var testProject in component . Tests )
94114 {
95- job . StepTest ( component . Name , testProject ) ;
115+ job . StepTest ( component . Name , testProject , runsOnIncludesWindows ) ;
116+
117+ if ( runsOnIncludesWindows )
118+ {
119+ job . StepTest ( component . Name , testProject , false , "net481" ) ;
120+ }
96121 }
97122
98- job . StepUploadTestResultsAsArtifact ( component ) ;
123+ job . StepUploadTestResultsAsArtifact ( component , runsOnIncludesWindows ) ;
124+
125+ if ( runsOnIncludesWindows )
126+ {
127+ job . StepUploadTestResultsAsArtifact ( component , false , "net481" ) ;
128+ }
99129
100130 job . StepToolRestore ( ) ;
101131
@@ -235,6 +265,11 @@ void GenerateUploadTestResultsWorkflow()
235265 foreach ( var testProject in component . Tests )
236266 {
237267 job . StepGenerateReportFromTestArtifact ( component , testProject ) ;
268+
269+ if ( component . RunsOn . Contains ( GitHubHostedRunners . WindowsLatest ) )
270+ {
271+ job . StepGenerateReportFromTestArtifact ( component , $ "{ testProject } -net481", "test-results-net481" ) ;
272+ }
238273 }
239274 }
240275
@@ -249,7 +284,7 @@ void WriteWorkflow(Workflow workflow, string fileName)
249284 Console . WriteLine ( $ "Wrote workflow to { filePath } ") ;
250285}
251286
252- record Component ( string Name , string [ ] Projects , string [ ] Tests , string TagPrefix )
287+ record Component ( string Name , string [ ] Projects , string [ ] Tests , string TagPrefix , string [ ] RunsOn )
253288{
254289 public string CiWorkflowName => $ "{ Name } /ci";
255290 public string ReleaseWorkflowName => $ "{ Name } /release";
@@ -270,39 +305,74 @@ public static void StepSetupDotNet(this Job job)
270305 public static Step IfRefMain ( this Step step )
271306 => step . If ( "github.ref == 'refs/heads/main'" ) ;
272307
273- public static void StepTest ( this Job job , string componentName , string testProject )
308+ internal static Step IfWindows ( this Step step )
309+ => step . If ( "matrix.os == 'windows-latest'" ) ;
310+
311+ internal static Step IfNotWindows ( this Step step )
312+ => step . If ( "matrix.os != 'windows-latest'" ) ;
313+
314+ public static void StepTest ( this Job job , string componentName , string testProject , bool excludeOnWindows , string ? framework = null )
274315 {
316+ var testProjectFullName = $ "{ testProject } { ( framework == null ? string . Empty : $ "-{ framework } ") } ";
275317 var path = $ "test/{ testProject } ";
276- var logFileName = $ "{ testProject } .trx";
318+ var logFileName = $ "{ testProjectFullName } .trx";
277319 var flags = $ "--logger \" console;verbosity=normal\" " +
278320 $ "--logger \" trx;LogFileName={ logFileName } \" " +
279321 $ "--collect:\" XPlat Code Coverage\" ";
280- job . Step ( )
281- . Name ( $ "Test - { testProject } ")
322+
323+ if ( framework != null )
324+ {
325+ flags += $ " --framework { framework } ";
326+ }
327+
328+ var testStep = job . Step ( )
329+ . Name ( $ "Test - { testProjectFullName } ")
282330 . Run ( $ "dotnet test -c Release { path } { flags } ") ;
283331
332+ if ( excludeOnWindows )
333+ {
334+ testStep . IfNotWindows ( ) ;
335+ }
336+
337+ if ( framework == "net481" )
338+ {
339+ testStep . IfWindows ( ) ;
340+ }
284341 }
285342
286- internal static void StepUploadTestResultsAsArtifact ( this Job job , Component component )
287- => job . Step ( )
288- . Name ( $ "Test report")
343+ internal static void StepUploadTestResultsAsArtifact ( this Job job , Component component , bool excludeOnWindows , string ? framework = null )
344+ {
345+ var nameSuffix = framework == null ? string . Empty : $ "-{ framework } ";
346+ var uploadStep = job . Step ( )
347+ . Name ( $ "Test report{ nameSuffix } ")
289348 . If ( "success() || failure()" )
290349 . Uses ( "actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882" ) // 4.4.3
291350 . With (
292- ( "name" , "test-results" ) ,
351+ ( "name" , $ "test-results{ nameSuffix } ") ,
293352 ( "path" , string . Join ( Environment . NewLine , component . Tests
294- . Select ( testProject => $ "{ component . Name } /test/{ testProject } /TestResults/{ testProject } .trx") ) ) ,
353+ . Select ( testProject => $ "{ component . Name } /test/{ testProject } /TestResults/{ testProject } { nameSuffix } .trx") ) ) ,
295354 ( "retention-days" , "5" ) ) ;
296355
297- internal static void StepGenerateReportFromTestArtifact ( this Job job , Component component , string testProject )
356+ if ( excludeOnWindows )
357+ {
358+ uploadStep . IfNotWindows ( ) ;
359+ }
360+
361+ if ( framework == "net481" )
362+ {
363+ uploadStep . IfWindows ( ) ;
364+ }
365+ }
366+
367+ internal static void StepGenerateReportFromTestArtifact ( this Job job , Component component , string testProject , string ? artifactName = "test-results" )
298368 {
299369 var path = $ "test/{ testProject } ";
300370 job . Step ( )
301371 . Name ( $ "Test report - { component . Name } - { testProject } ")
302372 . Uses ( "dorny/test-reporter@31a54ee7ebcacc03a09ea97a7e5465a47b84aea5" ) // v1.9.1
303373 . If ( $ "github.event.workflow.name == '{ component . CiWorkflowName } '")
304374 . With (
305- ( "artifact" , "test-results ") ,
375+ ( "artifact" , $ " { artifactName } ") ,
306376 ( "name" , $ "Test Report - { testProject } ") ,
307377 ( "path" , $ "{ testProject } .trx") ,
308378 ( "reporter" , "dotnet-trx" ) ,
0 commit comments