Skip to content

Commit

Permalink
Unrolled build for rust-lang#138268
Browse files Browse the repository at this point in the history
Rollup merge of rust-lang#138268 - Kobzol:fix-summary-nan, r=jieyouxu

Handle empty test suites in GitHub job summary report

Should fix [NaN](https://github.com/rust-lang-ci/rust/actions/runs/13739044506#summary-38426140405)s being printed.

r? `@jieyouxu`
  • Loading branch information
rust-timer authored Mar 10, 2025
2 parents 2b285cd + 1483cb6 commit 60c64a8
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/ci/citool/src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ fn render_table(suites: BTreeMap<String, TestSuiteRecord>) -> String {
let mut table = "| Test suite | Passed ✅ | Ignored 🚫 | Failed ❌ |\n".to_string();
writeln!(table, "|:------|------:|------:|------:|").unwrap();

fn compute_pct(value: f64, total: f64) -> f64 {
if total == 0.0 { 0.0 } else { value / total }
}

fn write_row(
buffer: &mut String,
name: &str,
Expand All @@ -75,9 +79,9 @@ fn render_table(suites: BTreeMap<String, TestSuiteRecord>) -> String {
) -> std::fmt::Result {
let TestSuiteRecord { passed, ignored, failed } = record;
let total = (record.passed + record.ignored + record.failed) as f64;
let passed_pct = ((*passed as f64) / total) * 100.0;
let ignored_pct = ((*ignored as f64) / total) * 100.0;
let failed_pct = ((*failed as f64) / total) * 100.0;
let passed_pct = compute_pct(*passed as f64, total) * 100.0;
let ignored_pct = compute_pct(*ignored as f64, total) * 100.0;
let failed_pct = compute_pct(*failed as f64, total) * 100.0;

write!(buffer, "| {surround}{name}{surround} |")?;
write!(buffer, " {surround}{passed} ({passed_pct:.0}%){surround} |")?;
Expand Down

0 comments on commit 60c64a8

Please sign in to comment.