From a316e6d99db6d315daa22546970f8e90e2d16b14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Ber=C3=A1nek?= Date: Tue, 14 May 2024 11:06:13 +0200 Subject: [PATCH] Show mean of primary/secondary results in GitHub summary comment tooltip --- site/src/github/comparison_summary.rs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/site/src/github/comparison_summary.rs b/site/src/github/comparison_summary.rs index 715afc5cb..e3f607645 100644 --- a/site/src/github/comparison_summary.rs +++ b/site/src/github/comparison_summary.rs @@ -324,8 +324,25 @@ fn write_metric_summary( write_summary_table(&primary, &secondary, false, message); } DefaultMetricVisibility::Hidden => { + let format_summary = + |buffer: &mut Vec, label: &str, summary: &ArtifactComparisonSummary| { + if summary.is_relevant() { + buffer.push(format!( + "{label} {:.1}%", + summary.arithmetic_mean_of_changes() + )); + } + }; + + // At this point, we know that at least one of primary or secondary are relevant + let mut results = vec![]; + format_summary(&mut results, "primary", &primary); + format_summary(&mut results, "secondary", &secondary); + + let summary = format!("Results ({})", results.join(", ")); + // `
` means it is hidden, requiring a click to reveal. - message.push_str("
\nResults\n\n"); + message.push_str(&format!("
\n{summary}\n\n")); message.push_str( "This is a less reliable metric that may be of interest but was not \ used to determine the overall result at the top of this comment.\n\n",