You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by GitBox <gi...@apache.org> on 2022/01/19 01:26:51 UTC

[GitHub] [tvm] driazati opened a new pull request #9973: Add bot to ping reviewers after no activity

driazati opened a new pull request #9973:
URL: https://github.com/apache/tvm/pull/9973


   This will add a comment from GitHub actions after X amount of time has passed after the last comment on a PR. This should help keep the backlog of PRs clean by remininding people to do a review or update their PRs. Unlike issues where having long term open issues that are legit bugs, PRs shouldn't be open indefinitely, so this bot will incentivize people to keep the PR backlog clean.
       
       The specific rule this operates under is: if there has been no comment or review in `--wait-time-minutes` (as checked by GitHub Actions every 15 minutes via the cron workflow in this PR), leave a comment on the PR @-ing all the relevant people, including anyone who has left a review or who was cc'ed at any point in the PR.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [tvm] areusch merged pull request #9973: Add bot to ping reviewers after no activity

Posted by GitBox <gi...@apache.org>.
areusch merged pull request #9973:
URL: https://github.com/apache/tvm/pull/9973


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [tvm] areusch commented on a change in pull request #9973: Add bot to ping reviewers after no activity

Posted by GitBox <gi...@apache.org>.
areusch commented on a change in pull request #9973:
URL: https://github.com/apache/tvm/pull/9973#discussion_r793170795



##########
File path: tests/scripts/ping_reviewers.py
##########
@@ -0,0 +1,223 @@
+#!/usr/bin/env python3
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+import os
+import argparse
+import re
+import datetime
+import json
+from typing import Dict, Any, List
+
+from git_utils import git, GitHubRepo, parse_remote
+
+
+def prs_query(user: str, repo: str, cursor: str = None):
+    after = ""
+    if cursor is not None:
+        after = f', before:"{cursor}"'
+    return f"""
+        {{
+    repository(name: "{repo}", owner: "{user}") {{
+        pullRequests(states: [OPEN], last: 10{after}) {{
+        edges {{
+            cursor
+        }}
+        nodes {{
+            number
+            url
+            body
+            isDraft
+            author {{
+                login
+            }}
+            reviews(last:100) {{
+                nodes {{
+                    author {{ login }}
+                    comments(last:100) {{
+                        nodes {{
+                            updatedAt
+                            bodyText
+                        }}
+                    }}
+                }}
+            }}
+            publishedAt
+            comments(last:100) {{
+                nodes {{
+                    authorAssociation
+                    bodyText
+                    updatedAt
+                    author {{
+                        login
+                    }}
+                }}
+            }}
+        }}
+        }}
+    }}
+    }}
+    """
+
+
+def find_reviewers(body: str) -> List[str]:

Review comment:
       is there a way to query the "Review requests" from GH instead? after we turn off CODEOWNERS this field will become more useful.

##########
File path: tests/python/unittest/test_ci.py
##########
@@ -53,6 +53,72 @@ def run(pr_body, expected_reviewers):
     )
 
 
+def test_ping_reviewers():
+    reviewers_script = REPO_ROOT / "tests" / "scripts" / "ping_reviewers.py"
+
+    def run(pr, check):
+        data = {
+            "data": {
+                "repository": {
+                    "pullRequests": {
+                        "nodes": [pr],
+                        "edges": [],
+                    }
+                }
+            }
+        }
+        proc = subprocess.run(
+            [
+                str(reviewers_script),
+                "--dry-run",
+                "--wait-time-minutes",
+                "1",
+                "--cutoff-pr-number",
+                "5",
+                "--allowlist",
+                "user",
+                "--pr-json",
+                json.dumps(data),
+            ],
+            stdout=subprocess.PIPE,
+            stderr=subprocess.PIPE,
+            encoding="utf-8",
+        )
+        if proc.returncode != 0:
+            raise RuntimeError(f"Process failed:\nstdout:\n{proc.stdout}\n\nstderr:\n{proc.stderr}")
+
+        assert check in proc.stdout
+
+    run(
+        {
+            "isDraft": True,
+        },
+        "Checking 0 PRs",
+    )
+
+    run(
+        {
+            "isDraft": False,
+            "number": 2,
+        },
+        "Checking 0 PRs",
+    )
+
+    run(

Review comment:
       can you add one for which there is recent comment activity and no ping is done?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [tvm] driazati commented on a change in pull request #9973: Add bot to ping reviewers after no activity

Posted by GitBox <gi...@apache.org>.
driazati commented on a change in pull request #9973:
URL: https://github.com/apache/tvm/pull/9973#discussion_r793926985



##########
File path: tests/scripts/ping_reviewers.py
##########
@@ -0,0 +1,223 @@
+#!/usr/bin/env python3
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+import os
+import argparse
+import re
+import datetime
+import json
+from typing import Dict, Any, List
+
+from git_utils import git, GitHubRepo, parse_remote
+
+
+def prs_query(user: str, repo: str, cursor: str = None):
+    after = ""
+    if cursor is not None:
+        after = f', before:"{cursor}"'
+    return f"""
+        {{
+    repository(name: "{repo}", owner: "{user}") {{
+        pullRequests(states: [OPEN], last: 10{after}) {{
+        edges {{
+            cursor
+        }}
+        nodes {{
+            number
+            url
+            body
+            isDraft
+            author {{
+                login
+            }}
+            reviews(last:100) {{
+                nodes {{
+                    author {{ login }}
+                    comments(last:100) {{
+                        nodes {{
+                            updatedAt
+                            bodyText
+                        }}
+                    }}
+                }}
+            }}
+            publishedAt
+            comments(last:100) {{
+                nodes {{
+                    authorAssociation
+                    bodyText
+                    updatedAt
+                    author {{
+                        login
+                    }}
+                }}
+            }}
+        }}
+        }}
+    }}
+    }}
+    """
+
+
+def find_reviewers(body: str) -> List[str]:

Review comment:
       We can add that functionality later if need be, but most PRs people are going to be cc-ing people anyways due to the other bot. The main reason I didn't add it here is that non-committers can't be added to the reviewers list until they've actually left a review (which this does query for)




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org