Skip to content

Commit

Permalink
Include more information in the GitHub review body (#24)
Browse files Browse the repository at this point in the history
Also drop the automated review message from the text representation of
the review. It's pretty obvious that it's automated in that context.
  • Loading branch information
cottsay authored Oct 3, 2024
1 parent d7167c0 commit b942937
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
8 changes: 5 additions & 3 deletions rosdistro_reviewer/review.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,11 @@ def summarize(self) -> str:
if not self._elements:
return '(No changes to supported elements were detected)'

message = 'This is an automated review.'
for element, criteria in self.elements.items():
message += f'\n\nFor changes related to {element}:'
message = ''
for idx, (element, criteria) in enumerate(self.elements.items()):
if idx:
message += '\n\n'
message += f'For changes related to {element}:'
for criterion in criteria:
message += '\n* ' + criterion.recommendation.as_symbol()
message += ' ' + textwrap.indent(criterion.rationale, ' ')[2:]
Expand Down
8 changes: 7 additions & 1 deletion rosdistro_reviewer/submitter/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@
GITHUB_TOKEN_ENVIRONMENT_VARIABLE = EnvironmentVariable(
'GITHUB_TOKEN', 'Authentication token secret for GitHub')

BODY_HEADER = """Hi there, thanks for contributing to ROS!
This is an automated review generated by the [rosdistro-reviewer tool](https://github.com/ros-infrastructure/rosdistro-reviewer). If you'd like the tool to run again, just [re-request review from GitHub Actions](https://github.com/ros-infrastructure/rosdistro-reviewer?tab=readme-ov-file#running-rosdistro-reviewer-in-github-actions).
""" # noqa: E501


class GitHubSubmitter(ReviewSubmitterExtensionPoint):
"""Submit reviews to GitHub pull requests."""
Expand Down Expand Up @@ -86,6 +92,6 @@ def _annotation_to_comment(
recommendation = review.recommendation

pr.create_review(
body=message,
body=BODY_HEADER + message,
event=RECOMMENDATION_EVENTS[recommendation],
comments=comments)

0 comments on commit b942937

Please sign in to comment.