mirror of https://github.com/astral-sh/ruff
Show a pretty markdown table in formatter ecosystem checks (#6496)
**Summary** The formatter ecosystem checks will now print a markdown table you can copy&paste into your PR description.  copied markdown: | project | similarity index | |--------------|------------------| | build | 0.75623 | | cpython | 0.75989 | | django | 0.99784 | | transformers | 0.99470 | | typeshed | 0.74853 | | warehouse | 0.99585 | | zulip | 0.99702 | raw markdown: ```markdown | project | similarity index | |--------------|------------------| | build | 0.75623 | | cpython | 0.75989 | | django | 0.99784 | | transformers | 0.99470 | | typeshed | 0.74853 | | warehouse | 0.99585 | | zulip | 0.99702 | ```
This commit is contained in:
parent
f2939c678b
commit
8b24238d19
|
|
@ -338,6 +338,6 @@ jobs:
|
||||||
- name: "Formatter progress"
|
- name: "Formatter progress"
|
||||||
run: scripts/formatter_ecosystem_checks.sh
|
run: scripts/formatter_ecosystem_checks.sh
|
||||||
- name: "Github step summary"
|
- 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"
|
- name: "Remove checkouts from cache"
|
||||||
run: rm -r target/progress_projects
|
run: rm -r target/progress_projects
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ use std::panic::catch_unwind;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
use std::process::ExitCode;
|
use std::process::ExitCode;
|
||||||
use std::time::{Duration, Instant};
|
use std::time::{Duration, Instant};
|
||||||
use std::{fmt, fs, io};
|
use std::{fmt, fs, io, iter};
|
||||||
use tempfile::NamedTempFile;
|
use tempfile::NamedTempFile;
|
||||||
use tracing::{debug, error, info, info_span};
|
use tracing::{debug, error, info, info_span};
|
||||||
use tracing_indicatif::span_ext::IndicatifSpanExt;
|
use tracing_indicatif::span_ext::IndicatifSpanExt;
|
||||||
|
|
@ -187,6 +187,9 @@ pub(crate) struct Args {
|
||||||
/// Write all log messages (same as cli) to this file
|
/// Write all log messages (same as cli) to this file
|
||||||
#[arg(long)]
|
#[arg(long)]
|
||||||
pub(crate) log_file: Option<PathBuf>,
|
pub(crate) log_file: Option<PathBuf>,
|
||||||
|
/// Write a markdown table with the similarity indices to this file
|
||||||
|
#[arg(long)]
|
||||||
|
pub(crate) stats_file: Option<PathBuf>,
|
||||||
/// Assert that there are exactly this many input files with errors. This catches regressions
|
/// Assert that there are exactly this many input files with errors. This catches regressions
|
||||||
/// (or improvements) in the parser.
|
/// (or improvements) in the parser.
|
||||||
#[arg(long)]
|
#[arg(long)]
|
||||||
|
|
@ -302,6 +305,8 @@ fn format_dev_multi_project(args: &Args) -> anyhow::Result<bool> {
|
||||||
None => None,
|
None => None,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let mut results = Vec::new();
|
||||||
|
|
||||||
for project_path in project_paths {
|
for project_path in project_paths {
|
||||||
debug!(parent: None, "Starting {}", project_path.display());
|
debug!(parent: None, "Starting {}", project_path.display());
|
||||||
|
|
||||||
|
|
@ -332,6 +337,7 @@ fn format_dev_multi_project(args: &Args) -> anyhow::Result<bool> {
|
||||||
write!(error_file, "{}", result.display(args.format)).unwrap();
|
write!(error_file, "{}", result.display(args.format)).unwrap();
|
||||||
error_file.flush().unwrap();
|
error_file.flush().unwrap();
|
||||||
}
|
}
|
||||||
|
results.push(result);
|
||||||
|
|
||||||
pb_span.pb_inc(1);
|
pb_span.pb_inc(1);
|
||||||
}
|
}
|
||||||
|
|
@ -353,6 +359,35 @@ fn format_dev_multi_project(args: &Args) -> anyhow::Result<bool> {
|
||||||
duration.as_secs_f32(),
|
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,
|
||||||
|
"| {:<project_col_len$} | similarity index |",
|
||||||
|
"project"
|
||||||
|
)?;
|
||||||
|
writeln!(
|
||||||
|
stats_file,
|
||||||
|
"|-{:-<project_col_len$}-|------------------|",
|
||||||
|
""
|
||||||
|
)?;
|
||||||
|
for result in results {
|
||||||
|
writeln!(
|
||||||
|
stats_file,
|
||||||
|
"| {:<project_col_len$} | {:.5} |",
|
||||||
|
result.name,
|
||||||
|
result.statistics.similarity_index()
|
||||||
|
)?;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if let Some(files_with_errors) = args.files_with_errors {
|
if let Some(files_with_errors) = args.files_with_errors {
|
||||||
if total_syntax_error_in_input != files_with_errors {
|
if total_syntax_error_in_input != files_with_errors {
|
||||||
error!(
|
error!(
|
||||||
|
|
@ -433,7 +468,13 @@ fn format_dev_project(
|
||||||
|
|
||||||
let duration = start.elapsed();
|
let duration = start.elapsed();
|
||||||
|
|
||||||
|
let name = files[0]
|
||||||
|
.file_name()
|
||||||
|
.unwrap_or(files[0].as_os_str())
|
||||||
|
.to_string_lossy()
|
||||||
|
.to_string();
|
||||||
Ok(CheckRepoResult {
|
Ok(CheckRepoResult {
|
||||||
|
name,
|
||||||
duration,
|
duration,
|
||||||
file_count: formatted_counter,
|
file_count: formatted_counter,
|
||||||
diagnostics,
|
diagnostics,
|
||||||
|
|
@ -511,6 +552,7 @@ fn diff_show_only_changes(
|
||||||
}
|
}
|
||||||
|
|
||||||
struct CheckRepoResult {
|
struct CheckRepoResult {
|
||||||
|
name: String,
|
||||||
duration: Duration,
|
duration: Duration,
|
||||||
file_count: usize,
|
file_count: usize,
|
||||||
diagnostics: Vec<Diagnostic>,
|
diagnostics: Vec<Diagnostic>,
|
||||||
|
|
|
||||||
|
|
@ -55,10 +55,11 @@ git -C "$dir/cpython" checkout 45de31db9cc9be945702f3a7ca35bbb9f98476af
|
||||||
# Uncomment if you want to update the hashes
|
# 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
|
# 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" \
|
time cargo run --bin ruff_dev -- format-dev --stability-check \
|
||||||
--log-file "$target/progress_projects_log.txt" --files-with-errors 25 --multi-project "$dir" || (
|
--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"
|
echo "Ecosystem check failed"
|
||||||
cat "$target/progress_projects_log.txt"
|
cat "$target/progress_projects_log.txt"
|
||||||
exit 1
|
exit 1
|
||||||
)
|
)
|
||||||
grep "similarity index" "$target/progress_projects_log.txt" | sort
|
cat "$target/progress_projects_stats.txt"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue