black-primer: Print summary after individual failures (#2570)

If the individual failures are verbose, it's useful to have
the summary at the end. Otherwise, it can be really difficult
to figure out which projects have an issue.
This commit is contained in:
Nipunn Koorapati 2021-10-28 10:35:37 -07:00 committed by GitHub
parent 467efe1556
commit 5434407af7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 28 additions and 17 deletions

View File

@ -8,13 +8,17 @@
- Add new `--workers` parameter (#2514) - Add new `--workers` parameter (#2514)
- Fixed feature detection for positional-only arguments in lambdas (#2532) - Fixed feature detection for positional-only arguments in lambdas (#2532)
- Bumped typed-ast version minimum to 1.4.3 for 3.10 compatiblity (#2519) - Bumped typed-ast version minimum to 1.4.3 for 3.10 compatiblity (#2519)
- Add primer support for --projects (#2555)
### _Blackd_ ### _Blackd_
- Remove dependency on aiohttp-cors (#2500) - Remove dependency on aiohttp-cors (#2500)
- Bump required aiohttp version to 3.7.4 (#2509) - Bump required aiohttp version to 3.7.4 (#2509)
### _Black-Primer_
- Add primer support for --projects (#2555)
- Print primer summary after individual failures (#2570)
### Integrations ### Integrations
- Allow to pass `target_version` in the vim plugin (#1319) - Allow to pass `target_version` in the vim plugin (#1319)

View File

@ -88,6 +88,18 @@ def analyze_results(project_count: int, results: Results) -> int:
failed_pct = round(((results.stats["failed"] / project_count) * 100), 2) failed_pct = round(((results.stats["failed"] / project_count) * 100), 2)
success_pct = round(((results.stats["success"] / project_count) * 100), 2) success_pct = round(((results.stats["success"] / project_count) * 100), 2)
if results.failed_projects:
click.secho("\nFailed projects:\n", bold=True)
for project_name, project_cpe in results.failed_projects.items():
print(f"## {project_name}:")
print(f" - Returned {project_cpe.returncode}")
if project_cpe.stderr:
print(f" - stderr:\n{project_cpe.stderr.decode('utf8')}")
if project_cpe.stdout:
print(f" - stdout:\n{project_cpe.stdout.decode('utf8')}")
print("")
click.secho("-- primer results 📊 --\n", bold=True) click.secho("-- primer results 📊 --\n", bold=True)
click.secho( click.secho(
f"{results.stats['success']} / {project_count} succeeded ({success_pct}%) ✅", f"{results.stats['success']} / {project_count} succeeded ({success_pct}%) ✅",
@ -110,16 +122,8 @@ def analyze_results(project_count: int, results: Results) -> int:
) )
if results.failed_projects: if results.failed_projects:
click.secho("\nFailed projects:\n", bold=True) failed = ", ".join(results.failed_projects.keys())
click.secho(f"\nFailed projects: {failed}\n", bold=True)
for project_name, project_cpe in results.failed_projects.items():
print(f"## {project_name}:")
print(f" - Returned {project_cpe.returncode}")
if project_cpe.stderr:
print(f" - stderr:\n{project_cpe.stderr.decode('utf8')}")
if project_cpe.stdout:
print(f" - stdout:\n{project_cpe.stdout.decode('utf8')}")
print("")
return results.stats["failed"] return results.stats["failed"]

View File

@ -20,6 +20,14 @@
EXPECTED_ANALYSIS_OUTPUT = """\ EXPECTED_ANALYSIS_OUTPUT = """\
Failed projects:
## black:
- Returned 69
- stdout:
Black didn't work
-- primer results 📊 -- -- primer results 📊 --
68 / 69 succeeded (98.55%) 68 / 69 succeeded (98.55%)
@ -28,12 +36,7 @@
- 0 projects skipped due to Python version - 0 projects skipped due to Python version
- 0 skipped due to long checkout - 0 skipped due to long checkout
Failed projects: Failed projects: black
## black:
- Returned 69
- stdout:
Black didn't work
""" """
FAKE_PROJECT_CONFIG = { FAKE_PROJECT_CONFIG = {