[llvm] [GitHub][workflows] Add buildbot information comment to first merged PR from a new contributor (PR #78292)

Aiden Grossman via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 16 11:54:55 PST 2024


================
@@ -240,6 +244,64 @@ def run(self) -> bool:
         return True
 
 
+class PRBuildbotInformation:
+    COMMENT_TAG = "<!--LLVM BUILDBOT INFORMATION COMMENT-->\n"
+
+    def __init__(self, token: str, repo: str, pr_number: int, author: str):
+        repo = github.Github(token).get_repo(repo)
+        self.pr = repo.get_issue(pr_number).as_pull_request()
+        self.author = author
+
+    def should_comment(self) -> bool:
+        # As soon as a new contributor has a PR merged, they are no longer a new contributor.
+        # We can tell that they were a new contributor previously because we would have
+        # added a new contributor greeting comment when they opened the PR.
+        found_greeting = False
+        for comment in self.pr.as_issue().get_comments():
+            if PRGreeter.COMMENT_TAG in comment.body:
+                found_greeting = True
+            elif PRBuildbotInformation.COMMENT_TAG in comment.body:
+                # When an issue is reopened, then closed as merged again, we should not
+                # add a second comment. This event will be rare in practice as it seems
+                # like it's only possible when the main branch is still at the exact
+                # revision that the PR was merged on to, beyond that it's closed forever.
+                return False
+        return found_greeting
+
+    def run(self) -> bool:
+        if not self.should_comment():
+            return
+
+        # This text is using Markdown formatting.
+        comment = f"""\
+{PRBuildbotInformation.COMMENT_TAG}
+@{self.author} Congratulations on having your first Pull Request (PR) merged into the LLVM Project!
+
+Your changes will be combined with recent changes from other authors, then tested
+by our [build bots](https://lab.llvm.org/buildbot/#/console).
+
+If there is a problem with the build, all the change authors will receive an email
+describing the problem. Please check whether the problem has been caused by your
+change, as the change set may include many authors. If the problem affects many
+configurations, you may get many emails for the same problem.
+
+If you are using a GitHub `noreply` email address, you will not receive these emails.
+Instead, someone will comment on this PR to inform you of the issue.
+
+If you do not receive any reports of problems, no action is required from you.
+Your changes are working as expected, well done!
+
+If your change causes an ongoing issue, it may be reverted. This is a [normal part of LLVM development](https://llvm.org/docs/DeveloperPolicy.html#patch-reversion-policy)
+and is not a comment on yourself as an author. The revert commit (or a comment on this PR)
+should explain why it was reverted, how to fix your changes and merge them again.
----------------
boomanaiden154 wrote:

I would add a note here that the policy is to open a new PR relanding the changes.

https://github.com/llvm/llvm-project/pull/78292


More information about the llvm-commits mailing list