From ce415092d5bbc492b585a1743a38fc803a77feb3 Mon Sep 17 00:00:00 2001 From: Scott K Logan Date: Tue, 8 Oct 2024 11:16:14 -0500 Subject: [PATCH] Include introduction only in new GitHub reviews We're expanding the introduction text in the PR body to include more information, and it isn't helpful to include that information in follow-up reviews. If there are any reviews on a PR from 'github-actions[bot]' already, assume it was us. --- rosdistro_reviewer/submitter/github.py | 13 +++++++++++-- test/spell_check.words | 1 + 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/rosdistro_reviewer/submitter/github.py b/rosdistro_reviewer/submitter/github.py index 0ca8c53..1d3f2a1 100644 --- a/rosdistro_reviewer/submitter/github.py +++ b/rosdistro_reviewer/submitter/github.py @@ -16,10 +16,12 @@ GITHUB_TOKEN_ENVIRONMENT_VARIABLE = EnvironmentVariable( 'GITHUB_TOKEN', 'Authentication token secret for GitHub') -BODY_HEADER = """Hi there, thanks for contributing to ROS! +INTRODUCTION = """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 @@ -91,7 +93,14 @@ def _annotation_to_comment( message = review.summarize() recommendation = review.recommendation + # Check if we've already posted a review for this PR + already_reviewed = any( + review.user.login == 'github-actions[bot]' + for review in pr.get_reviews()) + if not already_reviewed: + message = INTRODUCTION + message + pr.create_review( - body=BODY_HEADER + message, + body=message, event=RECOMMENDATION_EVENTS[recommendation], comments=comments) diff --git a/test/spell_check.words b/test/spell_check.words index 41ea49d..9332143 100644 --- a/test/spell_check.words +++ b/test/spell_check.words @@ -26,6 +26,7 @@ lenny libdelta linter linting +login mantic metafunc mktemp