This is an automated email from the ASF dual-hosted git repository.

lidavidm pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-adbc.git


The following commit(s) were added to refs/heads/main by this push:
     new 58a0acd29 ci: allow dependabot to ping itself (#1929)
58a0acd29 is described below

commit 58a0acd29b8c0bc7e0f6a2909cb6b78664c8fafc
Author: David Li <[email protected]>
AuthorDate: Tue Jun 25 09:39:49 2024 +0900

    ci: allow dependabot to ping itself (#1929)
    
    Fixes #1856.
    Fixes #1859.
---
 .github/workflows/dev_pr.yml           |  4 ++-
 .github/workflows/dev_pr/body_check.py | 63 ++++++++++++++++++++++++++++++++++
 2 files changed, 66 insertions(+), 1 deletion(-)

diff --git a/.github/workflows/dev_pr.yml b/.github/workflows/dev_pr.yml
index 78f4ba243..407d2baad 100644
--- a/.github/workflows/dev_pr.yml
+++ b/.github/workflows/dev_pr.yml
@@ -23,6 +23,8 @@ on:
       - opened
       - edited
       - synchronize
+      - ready_for_review
+      - review_requested
 
 permissions:
   contents: read
@@ -64,4 +66,4 @@ jobs:
         env:
           PR_BODY: ${{ github.event.pull_request.body }}
         run: |
-          [[ "${PR_BODY}" =~ @[a-zA-Z0-9]+ ]] && exit 1 || true
+          python .github/workflows/dev_pr/body_check.py $(pwd)/pr_checkout 
"$PR_BODY"
diff --git a/.github/workflows/dev_pr/body_check.py 
b/.github/workflows/dev_pr/body_check.py
new file mode 100644
index 000000000..10edbe099
--- /dev/null
+++ b/.github/workflows/dev_pr/body_check.py
@@ -0,0 +1,63 @@
+#!/usr/bin/env python
+
+# 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 argparse
+import re
+import sys
+import typing
+
+PING_RE = re.compile(r"@([a-zA-Z0-9\-]+)")
+IGNORED_USERNAMES = {"dependabot"}
+
+
+def check_pr_body(body: str) -> typing.List[str]:
+    """Check a PR body and return a list of reasons why it's invalid."""
+
+    reasons = []
+    matches = PING_RE.findall(body)
+    for username in matches:
+        if username in IGNORED_USERNAMES:
+            continue
+        reasons.append(f"Please don't ping {username} in the PR description")
+
+    return reasons
+
+
+def main():
+    parser = argparse.ArgumentParser()
+    parser.add_argument("body", help="The PR body to check")
+
+    args = parser.parse_args()
+
+    print(f'PR body: "{args.body}"')
+    print("=" * 60)
+
+    reasons = check_pr_body(args.body)
+    if not reasons:
+        print("PR body is valid")
+        return 0
+
+    print("PR body is invalid:")
+    for reason in reasons:
+        print("-", reason)
+    return 1
+
+
+if __name__ == "__main__":
+    sys.exit(main())

Reply via email to