Skip to content

Commit 74c9102

Browse files
committed
Record bootstrap step durations into GitHub summary in citool
1 parent 3c3232e commit 74c9102

File tree

7 files changed

+33
-8
lines changed

7 files changed

+33
-8
lines changed

src/build_helper/src/metrics.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ pub fn format_build_steps(root: &BuildStep) -> String {
172172
let mut output = String::new();
173173
for (level, step) in substeps {
174174
let label = format!("{}{}", ".".repeat(level as usize), step.r#type);
175-
writeln!(output, "{label:<65}{:>8.2}s", step.duration.as_secs_f64()).unwrap();
175+
writeln!(output, "{label:.<65}{:>8.2}s", step.duration.as_secs_f64()).unwrap();
176176
}
177177
output
178178
}

src/ci/citool/src/metrics.rs

+27-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ use std::io::Write;
44
use std::path::Path;
55

66
use anyhow::Context;
7-
use build_helper::metrics::{JsonNode, JsonRoot, TestOutcome, TestSuite, TestSuiteMetadata};
7+
use build_helper::metrics::{
8+
BuildStep, JsonNode, JsonRoot, TestOutcome, TestSuite, TestSuiteMetadata, format_build_steps,
9+
};
810

911
pub fn postprocess_metrics(metrics_path: &Path, summary_path: &Path) -> anyhow::Result<()> {
1012
let metrics = load_metrics(metrics_path)?;
@@ -15,7 +17,30 @@ pub fn postprocess_metrics(metrics_path: &Path, summary_path: &Path) -> anyhow::
1517
.open(summary_path)
1618
.with_context(|| format!("Cannot open summary file at {summary_path:?}"))?;
1719

18-
record_test_suites(&metrics, &mut file)?;
20+
if !metrics.invocations.is_empty() {
21+
writeln!(file, "# Bootstrap steps")?;
22+
record_bootstrap_step_durations(&metrics, &mut file)?;
23+
record_test_suites(&metrics, &mut file)?;
24+
}
25+
26+
Ok(())
27+
}
28+
29+
fn record_bootstrap_step_durations(metrics: &JsonRoot, file: &mut File) -> anyhow::Result<()> {
30+
for invocation in &metrics.invocations {
31+
let step = BuildStep::from_invocation(invocation);
32+
let table = format_build_steps(&step);
33+
writeln!(
34+
file,
35+
r"<details>
36+
<summary>{}</summary>
37+
<pre><code>{table}</code></pre>
38+
</details>
39+
",
40+
invocation.cmdline
41+
)?;
42+
}
43+
eprintln!("Recorded {} bootstrap invocation(s)", metrics.invocations.len());
1944

2045
Ok(())
2146
}

src/doc/book

Submodule book updated 66 files

src/llvm-project

src/tools/cargo

Submodule cargo updated 132 files

0 commit comments

Comments
 (0)