diff options
| author | Jakub Beránek <berykubik@gmail.com> | 2025-03-02 18:23:11 +0100 |
|---|---|---|
| committer | Jakub Beránek <berykubik@gmail.com> | 2025-03-04 12:31:53 +0100 |
| commit | 7b53ac7ee67fbd62cadd883c860a6df263b6a481 (patch) | |
| tree | efe4dc1cd0911b63ee958186103c925de9fcdc34 /src | |
| parent | ead58ea6f8bf860459fe5351a83717a8e591b0af (diff) | |
| download | rust-7b53ac7ee67fbd62cadd883c860a6df263b6a481.tar.gz rust-7b53ac7ee67fbd62cadd883c860a6df263b6a481.zip | |
Record bootstrap step durations into GitHub summary in citool
Diffstat (limited to 'src')
| -rw-r--r-- | src/build_helper/src/metrics.rs | 10 | ||||
| -rw-r--r-- | src/ci/citool/src/metrics.rs | 30 |
2 files changed, 36 insertions, 4 deletions
diff --git a/src/build_helper/src/metrics.rs b/src/build_helper/src/metrics.rs index 4b585c15182..eb306550fc4 100644 --- a/src/build_helper/src/metrics.rs +++ b/src/build_helper/src/metrics.rs @@ -175,8 +175,14 @@ pub fn format_build_steps(root: &BuildStep) -> String { let mut output = String::new(); for (level, step) in substeps { - let label = format!("{}{}", ".".repeat(level as usize), step.r#type); - writeln!(output, "{label:<65}{:>8.2}s", step.duration.as_secs_f64()).unwrap(); + let label = format!( + "{}{}", + ".".repeat(level as usize), + // Bootstrap steps can be generic and thus contain angle brackets (<...>). + // However, Markdown interprets these as HTML, so we need to escap ethem. + step.r#type.replace('<', "<").replace('>', ">") + ); + writeln!(output, "{label:.<65}{:>8.2}s", step.duration.as_secs_f64()).unwrap(); } output } diff --git a/src/ci/citool/src/metrics.rs b/src/ci/citool/src/metrics.rs index 9a1c7c4d910..2386413ed6b 100644 --- a/src/ci/citool/src/metrics.rs +++ b/src/ci/citool/src/metrics.rs @@ -4,7 +4,9 @@ use std::io::Write; use std::path::Path; use anyhow::Context; -use build_helper::metrics::{JsonNode, JsonRoot, TestOutcome, TestSuite, TestSuiteMetadata}; +use build_helper::metrics::{ + BuildStep, JsonNode, JsonRoot, TestOutcome, TestSuite, TestSuiteMetadata, format_build_steps, +}; pub fn postprocess_metrics(metrics_path: &Path, summary_path: &Path) -> anyhow::Result<()> { let metrics = load_metrics(metrics_path)?; @@ -15,7 +17,31 @@ pub fn postprocess_metrics(metrics_path: &Path, summary_path: &Path) -> anyhow:: .open(summary_path) .with_context(|| format!("Cannot open summary file at {summary_path:?}"))?; - record_test_suites(&metrics, &mut file)?; + if !metrics.invocations.is_empty() { + writeln!(file, "# Bootstrap steps")?; + record_bootstrap_step_durations(&metrics, &mut file)?; + record_test_suites(&metrics, &mut file)?; + } + + Ok(()) +} + +fn record_bootstrap_step_durations(metrics: &JsonRoot, file: &mut File) -> anyhow::Result<()> { + for invocation in &metrics.invocations { + let step = BuildStep::from_invocation(invocation); + let table = format_build_steps(&step); + eprintln!("Step `{}`\n{table}\n", invocation.cmdline); + writeln!( + file, + r"<details> +<summary>{}</summary> +<pre><code>{table}</code></pre> +</details> +", + invocation.cmdline + )?; + } + eprintln!("Recorded {} bootstrap invocation(s)", metrics.invocations.len()); Ok(()) } |
