Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show mean of primary/secondary results in GitHub summary comment tooltip #1907

Merged
merged 1 commit into from
May 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion site/src/github/comparison_summary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -324,8 +324,25 @@ fn write_metric_summary(
write_summary_table(&primary, &secondary, false, message);
}
DefaultMetricVisibility::Hidden => {
let format_summary =
|buffer: &mut Vec<String>, 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(", "));

// `<details>` means it is hidden, requiring a click to reveal.
message.push_str("<details>\n<summary>Results</summary>\n\n");
message.push_str(&format!("<details>\n<summary>{summary}</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",
Expand Down
Loading