diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 5707fdea6a..13b1986afd 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -338,6 +338,6 @@ jobs: - name: "Formatter progress" run: scripts/formatter_ecosystem_checks.sh - name: "Github step summary" - run: grep "similarity index" target/progress_projects_log.txt | sort > $GITHUB_STEP_SUMMARY + run: cat target/progress_projects_stats.txt > $GITHUB_STEP_SUMMARY - name: "Remove checkouts from cache" run: rm -r target/progress_projects diff --git a/crates/ruff_dev/src/format_dev.rs b/crates/ruff_dev/src/format_dev.rs index 6b83fb57ed..79966a7c06 100644 --- a/crates/ruff_dev/src/format_dev.rs +++ b/crates/ruff_dev/src/format_dev.rs @@ -22,7 +22,7 @@ use std::panic::catch_unwind; use std::path::{Path, PathBuf}; use std::process::ExitCode; use std::time::{Duration, Instant}; -use std::{fmt, fs, io}; +use std::{fmt, fs, io, iter}; use tempfile::NamedTempFile; use tracing::{debug, error, info, info_span}; use tracing_indicatif::span_ext::IndicatifSpanExt; @@ -187,6 +187,9 @@ pub(crate) struct Args { /// Write all log messages (same as cli) to this file #[arg(long)] pub(crate) log_file: Option, + /// Write a markdown table with the similarity indices to this file + #[arg(long)] + pub(crate) stats_file: Option, /// Assert that there are exactly this many input files with errors. This catches regressions /// (or improvements) in the parser. #[arg(long)] @@ -302,6 +305,8 @@ fn format_dev_multi_project(args: &Args) -> anyhow::Result { None => None, }; + let mut results = Vec::new(); + for project_path in project_paths { debug!(parent: None, "Starting {}", project_path.display()); @@ -332,6 +337,7 @@ fn format_dev_multi_project(args: &Args) -> anyhow::Result { write!(error_file, "{}", result.display(args.format)).unwrap(); error_file.flush().unwrap(); } + results.push(result); pb_span.pb_inc(1); } @@ -353,6 +359,35 @@ fn format_dev_multi_project(args: &Args) -> anyhow::Result { duration.as_secs_f32(), ); + if let Some(stats_file) = &args.stats_file { + results.sort_by(|result1, result2| result1.name.cmp(&result2.name)); + let project_col_len = results + .iter() + .map(|result| result.name.len()) + .chain(iter::once("project".len())) + .max() + .unwrap_or_default(); + let mut stats_file = BufWriter::new(File::create(stats_file)?); + writeln!( + stats_file, + "| {:, diff --git a/scripts/formatter_ecosystem_checks.sh b/scripts/formatter_ecosystem_checks.sh index 46d765fb2d..f26405212e 100755 --- a/scripts/formatter_ecosystem_checks.sh +++ b/scripts/formatter_ecosystem_checks.sh @@ -55,10 +55,11 @@ git -C "$dir/cpython" checkout 45de31db9cc9be945702f3a7ca35bbb9f98476af # Uncomment if you want to update the hashes # for i in "$dir"/*/; do git -C "$i" switch main && git -C "$i" pull && echo "# $(basename "$i") $(git -C "$i" rev-parse HEAD)"; done -time cargo run --bin ruff_dev -- format-dev --stability-check --error-file "$target/progress_projects_errors.txt" \ - --log-file "$target/progress_projects_log.txt" --files-with-errors 25 --multi-project "$dir" || ( +time cargo run --bin ruff_dev -- format-dev --stability-check \ + --error-file "$target/progress_projects_errors.txt" --log-file "$target/progress_projects_log.txt" --stats-file "$target/progress_projects_stats.txt" \ + --files-with-errors 25 --multi-project "$dir" || ( echo "Ecosystem check failed" cat "$target/progress_projects_log.txt" exit 1 ) -grep "similarity index" "$target/progress_projects_log.txt" | sort +cat "$target/progress_projects_stats.txt"