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/27 00:55:49 UTC

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

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