@@ -206,6 +206,32 @@ impl From<String> for Features {
206
206
}
207
207
}
208
208
209
+ #[ derive(
210
+ Debug ,
211
+ Clone ,
212
+ Copy ,
213
+ PartialEq ,
214
+ Eq ,
215
+ strum:: EnumString ,
216
+ strum:: AsRefStr ,
217
+ strum:: Display ,
218
+ strum:: VariantArray ,
219
+ ) ]
220
+ enum CiOs {
221
+ #[ strum( serialize = "windows-latest" ) ]
222
+ Windows ,
223
+ #[ strum( serialize = "macos-latest" ) ]
224
+ Macos ,
225
+ #[ strum( serialize = "ubuntu-latest" ) ]
226
+ Ubuntu ,
227
+ }
228
+
229
+ impl CiOs {
230
+ fn is_main_os ( & self ) -> bool {
231
+ matches ! ( self , CiOs :: Ubuntu )
232
+ }
233
+ }
234
+
209
235
#[ derive( Debug , Clone , Parser ) ]
210
236
struct App {
211
237
#[ clap( flatten) ]
@@ -297,7 +323,7 @@ impl App {
297
323
os_string
298
324
}
299
325
300
- pub ( crate ) fn into_ci_row ( self , os : String ) -> CiMatrixRow {
326
+ pub ( crate ) fn into_ci_row ( self , os : CiOs ) -> CiMatrixRow {
301
327
CiMatrixRow {
302
328
command : self . clone ( ) . into_command_string ( ) . into_string ( ) . unwrap ( ) ,
303
329
name : format ! (
@@ -310,7 +336,8 @@ impl App {
310
336
self . global_args. features. to_string( )
311
337
}
312
338
) ,
313
- os,
339
+ os : os. to_string ( ) ,
340
+ generates_coverage : self . global_args . coverage ,
314
341
}
315
342
}
316
343
}
@@ -494,6 +521,8 @@ struct CiMatrixRow {
494
521
name : String ,
495
522
/// The os to run this on
496
523
os : String ,
524
+ /// If this run produces lcov files
525
+ generates_coverage : bool ,
497
526
}
498
527
499
528
impl Xtasks {
@@ -520,27 +549,26 @@ impl Xtasks {
520
549
let mut output = Self :: ci_matrix ( app_settings) ?;
521
550
output. sort_by ( |e1, e2| e1. subcmd . cmp ( & e2. subcmd ) ) ;
522
551
let mut rows = Vec :: default ( ) ;
523
- for os in & [ "ubuntu-latest" , "macos-latest" , "windows-latest" ] {
552
+ for os in < CiOs as strum :: VariantArray > :: VARIANTS {
524
553
for row in output. iter ( ) {
525
- let is_main_os = os == & "ubuntu-latest" ;
526
554
let step_should_run_on_main_os =
527
555
matches ! ( row. subcmd, Xtasks :: Build | Xtasks :: Docs { .. } ) ;
528
556
let is_coverage_step = row. global_args . coverage ;
529
557
530
- if !is_main_os && step_should_run_on_main_os {
558
+ if !os . is_main_os ( ) && step_should_run_on_main_os {
531
559
continue ;
532
560
}
533
561
534
562
// we only need one source of coverage + windows is slow with this setting
535
- let row = if !is_main_os && is_coverage_step {
563
+ let row = if !os . is_main_os ( ) && is_coverage_step {
536
564
let new_args = row. global_args . clone ( ) . without_coverage ( ) ;
537
565
App {
538
566
global_args : new_args,
539
567
..row. clone ( )
540
568
}
541
- . into_ci_row ( os . to_string ( ) )
569
+ . into_ci_row ( * os )
542
570
} else {
543
- row. clone ( ) . into_ci_row ( os . to_string ( ) )
571
+ row. clone ( ) . into_ci_row ( * os )
544
572
} ;
545
573
546
574
rows. push ( row) ;
0 commit comments