-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add artifact size and step duration summaries from
opt-dist
to gith…
…ub job summary
- Loading branch information
Showing
6 changed files
with
162 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,3 +21,4 @@ serde = { version = "1", features = ["derive"] } | |
serde_json = "1" | ||
glob = "0.3" | ||
tempfile = "3.5" | ||
tabled = "0.13" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
use std::io::Write; | ||
|
||
use tabled::builder::Builder; | ||
use tabled::settings::object::Columns; | ||
use tabled::settings::style::{BorderChar, Offset}; | ||
use tabled::settings::{Modify, Style}; | ||
|
||
use crate::environment::Environment; | ||
use crate::utils::io::get_files_from_dir; | ||
|
||
pub fn print_binary_sizes(env: &dyn Environment) -> anyhow::Result<()> { | ||
use humansize::format_size; | ||
use humansize::BINARY; | ||
use std::fmt::Write; | ||
|
||
let root = env.build_artifacts().join("stage2"); | ||
|
||
let mut files = get_files_from_dir(&root.join("bin"), None)?; | ||
files.extend(get_files_from_dir(&root.join("lib"), Some(".so"))?); | ||
files.sort_unstable(); | ||
|
||
let items: Vec<_> = files | ||
.into_iter() | ||
.map(|file| { | ||
let size = std::fs::metadata(file.as_std_path()).map(|m| m.len()).unwrap_or(0); | ||
let size_formatted = format_size(size, BINARY); | ||
let name = file.file_name().unwrap().to_string(); | ||
(name, size_formatted) | ||
}) | ||
.collect(); | ||
|
||
// Write to log | ||
let mut output = String::new(); | ||
for (name, size_formatted) in items.iter() { | ||
let name = format!("{}:", name); | ||
writeln!(output, "{name:<50}{size_formatted:>10}")?; | ||
} | ||
log::info!("Rustc artifact size\n{output}"); | ||
|
||
// Write to GitHub summary | ||
if let Ok(summary_path) = std::env::var("GITHUB_STEP_SUMMARY") { | ||
let mut builder = Builder::default(); | ||
for (name, size_formatted) in items { | ||
builder.push_record(vec![name, size_formatted]); | ||
} | ||
|
||
builder.set_header(vec!["Artifact", "Size"]); | ||
let mut table = builder.build(); | ||
|
||
let mut file = std::fs::File::options().append(true).create(true).open(summary_path)?; | ||
writeln!( | ||
file, | ||
"# Artifact size\n{}\n", | ||
table.with(Style::markdown()).with( | ||
Modify::new(Columns::single(1)).with(BorderChar::horizontal(':', Offset::End(0))), | ||
) | ||
)?; | ||
} | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters