Skip to content

[github action] display black result in job summary#3688

Merged
cooperlees merged 5 commits into
psf:mainfrom
tieum:main
May 15, 2023
Merged

[github action] display black result in job summary#3688
cooperlees merged 5 commits into
psf:mainfrom
tieum:main

Conversation

@tieum

@tieum tieum commented May 13, 2023

Copy link
Copy Markdown
Contributor

Description

This PR updates the black github action to display the output of black in the job summary

Checklist

  • Add an entry in CHANGES.md if necessary?
  • Add / update tests if necessary?
  • Add new / update outdated documentation?

Result looks like this:

- erroring with verbosity on

screenshot-2023-05-13-1727

- success with verbosity off

screenshot-2023-05-13-1741

@cooperlees cooperlees left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Just checking if we should care about the new lines, I feel it might mess up output people maybe parse and make things harder to read ...

Comment thread action/main.py Outdated
break
if not describe_name:
print("::error::Failed to detect action version.", flush=True)
sys.stderr.write("::error::Failed to detect action version.")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Do we care about the newline here you've removed? If so I recommend sticking with print cause I believe it will send correct newline in windows ...

Suggested change
sys.stderr.write("::error::Failed to detect action version.")
print("::error::Failed to detect action version.", file=sys.stderr, flush=True)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It does need to be written to stderr so as errors do not appear in the job summary part (which won't parse it correctly) but the annotation one, like this:
screenshot-2023-05-13-1815
I've updated the PR with your feedback

Comment thread action/main.py Outdated
@tieum tieum requested a review from cooperlees May 14, 2023 12:35
@tieum

tieum commented May 14, 2023

Copy link
Copy Markdown
Contributor Author

I also checked action was correctly running on a Windows runner, an example run is here https://github.com/tieum/atuin-graph/actions/runs/4972553308

screenshot-2023-05-14-1507 screenshot-2023-05-14-1508

@cooperlees cooperlees left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for taking my suggestions into account. This all looks good to me now to get the nicer summary and does the right thing to stderr output for all platforms :)

@cooperlees cooperlees merged commit c97b9c5 into psf:main May 15, 2023
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.

2 participants