Skip to content

Show azpysdk Black output in CI#46454

Open
JennyPng wants to merge 1 commit intoAzure:mainfrom
JennyPng:black-output
Open

Show azpysdk Black output in CI#46454
JennyPng wants to merge 1 commit intoAzure:mainfrom
JennyPng:black-output

Conversation

@JennyPng
Copy link
Copy Markdown
Member

@JennyPng JennyPng commented Apr 21, 2026

@JennyPng JennyPng mentioned this pull request Apr 21, 2026
@JennyPng JennyPng marked this pull request as ready for review April 21, 2026 22:36
@JennyPng JennyPng requested a review from scbedd as a code owner April 21, 2026 22:36
Copilot AI review requested due to automatic review settings April 21, 2026 22:36
@JennyPng JennyPng requested a review from mccoyp as a code owner April 21, 2026 22:36
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves CI diagnostics for azpysdk black by running Black in “check/diff” mode in CI and logging the diff output directly to the job logs, addressing the visibility gap described in #46417.

Changes:

  • Run Black with --check --diff when in_ci() is true (no in-place formatting during CI runs).
  • Capture and log Black stdout/stderr (diff + summary) when formatting issues are detected.
  • Extend format_directory to accept a check_only flag and adjust subprocess behavior accordingly.

Comment on lines +74 to 81
has_issues = result.returncode != 0 if check_only else "reformatted" in stderr_text

if has_issues:
if check_only:
logger.info(
f"The package {package_name} needs reformat. Run `azpysdk black .` locally from the package root to reformat."
f"The package {package_name} has black formatting issues. "
f"Run `azpysdk black .` locally from the package root to reformat."
)
Copy link

Copilot AI Apr 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In CI (check_only=True), has_issues is based on any non-zero return code, but the log message always frames it as “black formatting issues”. Black uses different exit codes (e.g., 1 = would reformat, >1 = usage/internal error), so a black crash/invalid config would be misreported and its output logged at INFO. Consider branching on result.returncode in check-only mode (treat ==1 as formatting diff, and >1 as an execution failure logged at ERROR, ideally propagating the real return code).

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make black output in CI visible to the user

2 participants