Skip to content

Commit 4d3b82f

Browse files
committed
output coverage in the matrix
1 parent 2809440 commit 4d3b82f

File tree

2 files changed

+38
-19
lines changed

2 files changed

+38
-19
lines changed

.github/workflows/bevy_mod_scripting.yml

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -74,21 +74,12 @@ jobs:
7474
- name: Check
7575
run: |
7676
${{ matrix.run_args.command }}
77-
78-
- name: Upload lcov files if any exist
79-
if: ${{ matrix.run_args.os == 'ubuntu-latest' }}
80-
uses: actions/upload-artifact@v4
81-
with:
82-
name: lcov-${{ matrix.run_args.os }}-${{ matrix.run_args.name }}
83-
path: |
84-
**/lcov.*
85-
if-no-files-found: ignore
8677
- name: Install lcov/genhtml
87-
if: ${{ matrix.run_args.os == 'ubuntu-latest' }}
78+
if: ${{ matrix.run_args.generates_coverage }}
8879
run: |
8980
sudo apt-get install lcov -y
9081
- name: Report code coverage
91-
if: ${{ matrix.run_args.os == 'ubuntu-latest' }}
82+
if: ${{ matrix.run_args.generates_coverage }}
9283
uses: zgosalvez/github-actions-report-lcov@v3
9384
with:
9485
coverage-files: |

crates/xtask/src/main.rs

Lines changed: 36 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,32 @@ impl From<String> for Features {
206206
}
207207
}
208208

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+
209235
#[derive(Debug, Clone, Parser)]
210236
struct App {
211237
#[clap(flatten)]
@@ -297,7 +323,7 @@ impl App {
297323
os_string
298324
}
299325

300-
pub(crate) fn into_ci_row(self, os: String) -> CiMatrixRow {
326+
pub(crate) fn into_ci_row(self, os: CiOs) -> CiMatrixRow {
301327
CiMatrixRow {
302328
command: self.clone().into_command_string().into_string().unwrap(),
303329
name: format!(
@@ -310,7 +336,8 @@ impl App {
310336
self.global_args.features.to_string()
311337
}
312338
),
313-
os,
339+
os: os.to_string(),
340+
generates_coverage: self.global_args.coverage,
314341
}
315342
}
316343
}
@@ -494,6 +521,8 @@ struct CiMatrixRow {
494521
name: String,
495522
/// The os to run this on
496523
os: String,
524+
/// If this run produces lcov files
525+
generates_coverage: bool,
497526
}
498527

499528
impl Xtasks {
@@ -520,27 +549,26 @@ impl Xtasks {
520549
let mut output = Self::ci_matrix(app_settings)?;
521550
output.sort_by(|e1, e2| e1.subcmd.cmp(&e2.subcmd));
522551
let mut rows = Vec::default();
523-
for os in &["ubuntu-latest", "macos-latest", "windows-latest"] {
552+
for os in <CiOs as strum::VariantArray>::VARIANTS {
524553
for row in output.iter() {
525-
let is_main_os = os == &"ubuntu-latest";
526554
let step_should_run_on_main_os =
527555
matches!(row.subcmd, Xtasks::Build | Xtasks::Docs { .. });
528556
let is_coverage_step = row.global_args.coverage;
529557

530-
if !is_main_os && step_should_run_on_main_os {
558+
if !os.is_main_os() && step_should_run_on_main_os {
531559
continue;
532560
}
533561

534562
// 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 {
536564
let new_args = row.global_args.clone().without_coverage();
537565
App {
538566
global_args: new_args,
539567
..row.clone()
540568
}
541-
.into_ci_row(os.to_string())
569+
.into_ci_row(*os)
542570
} else {
543-
row.clone().into_ci_row(os.to_string())
571+
row.clone().into_ci_row(*os)
544572
};
545573

546574
rows.push(row);

0 commit comments

Comments
 (0)