[llvm] workflows/commit-access-review: Exclude users who have recently requested access (PR #119102)

Tom Stellard via llvm-commits llvm-commits at lists.llvm.org
Sat Dec 7 16:40:00 PST 2024


https://github.com/tstellar updated https://github.com/llvm/llvm-project/pull/119102

>From 2d232348c18edbc83b9c8ac63670274e7e653d7e Mon Sep 17 00:00:00 2001
From: Tom Stellard <tstellar at redhat.com>
Date: Sat, 7 Dec 2024 16:22:00 -0800
Subject: [PATCH 1/3] workflows/commit-access-review: Exclude users who have
 recently requested access

Now that we are accepting commit access requests via GitHub issues,
we can keep track of how has recently requested access.
---
 .github/workflows/commit-access-review.py | 44 +++++++++++++----------
 1 file changed, 26 insertions(+), 18 deletions(-)

diff --git a/.github/workflows/commit-access-review.py b/.github/workflows/commit-access-review.py
index 91d3a61cdcb175..cb4588670777f9 100644
--- a/.github/workflows/commit-access-review.py
+++ b/.github/workflows/commit-access-review.py
@@ -67,39 +67,47 @@ def check_manual_requests(
 ) -> list[str]:
     """
     Return a list of users who have been asked since ``start_date`` if they
-    want to keep their commit access.
+    want to keep their commit access or if they have applied for commit
+    access since ``start_date``
     """
+
     query = """
-        query ($query: String!) {
-          search(query: $query, type: ISSUE, first: 100) {
+        query ($query: String!, $after: String) {
+          search(query: $query, type: ISSUE, first: 100, after: $after) {
             nodes {
               ... on Issue {
-                body
-                comments (first: 100) {
-                  nodes {
-                    author {
-                      login
-                    }
-                  }
+                author {
+                  login
                 }
+                body
               }
             }
+            pageInfo {
+              hasNextPage
+              endCursor
+            }
           }
         }
         """
     formatted_start_date = start_date.strftime("%Y-%m-%dT%H:%M:%S")
     variables = {
-        "query": f"type:issue created:>{formatted_start_date} org:llvm repo:llvm-project label:infra:commit-access"
+      "query": f"type:issue created:>{formatted_start_date} org:llvm repo:llvm-project label:infra:commit-access,infra:commit-access-request"
     }
 
-    res_header, res_data = gh._Github__requester.graphql_query(
-        query=query, variables=variables
-    )
-    data = res_data["data"]
+    has_next_page = True
     users = []
-    for issue in data["search"]["nodes"]:
-        users.extend([user[1:] for user in re.findall("@[^ ,\n]+", issue["body"])])
-
+    while has_next_page:
+        res_header, res_data = gh._Github__requester.graphql_query(
+            query=query, variables=variables
+        )
+        data = res_data["data"]
+        for issue in data["search"]["nodes"]:
+            users.extend([user[1:] for user in re.findall("@[^ ,\n]+", issue["body"])])
+            if issue['author']:
+                users.append(issue['author']['login'])
+        has_next_page = data["search"]["pageInfo"]["hasNextPage"]
+        if has_next_page:
+            variables["after"] = data["search"]["pageInfo"]["endCursor"]
     return users
 
 

>From 61e49728fd0cdc898e4eaa03595f46c810241b35 Mon Sep 17 00:00:00 2001
From: Tom Stellard <tstellar at redhat.com>
Date: Sat, 7 Dec 2024 16:31:53 -0800
Subject: [PATCH 2/3] Fix formatting

---
 .github/workflows/commit-access-review.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/.github/workflows/commit-access-review.py b/.github/workflows/commit-access-review.py
index cb4588670777f9..c11dd4d6be72c1 100644
--- a/.github/workflows/commit-access-review.py
+++ b/.github/workflows/commit-access-review.py
@@ -91,7 +91,7 @@ def check_manual_requests(
         """
     formatted_start_date = start_date.strftime("%Y-%m-%dT%H:%M:%S")
     variables = {
-      "query": f"type:issue created:>{formatted_start_date} org:llvm repo:llvm-project label:infra:commit-access,infra:commit-access-request"
+        "query": f"type:issue created:>{formatted_start_date} org:llvm repo:llvm-project label:infra:commit-access,infra:commit-access-request"
     }
 
     has_next_page = True
@@ -104,7 +104,7 @@ def check_manual_requests(
         for issue in data["search"]["nodes"]:
             users.extend([user[1:] for user in re.findall("@[^ ,\n]+", issue["body"])])
             if issue['author']:
-                users.append(issue['author']['login'])
+                users.append(issue["author"]["login"])
         has_next_page = data["search"]["pageInfo"]["hasNextPage"]
         if has_next_page:
             variables["after"] = data["search"]["pageInfo"]["endCursor"]

>From a14742e94d606f1bb7c519b2120af9935277ade9 Mon Sep 17 00:00:00 2001
From: Tom Stellard <tstellar at redhat.com>
Date: Sat, 7 Dec 2024 16:39:41 -0800
Subject: [PATCH 3/3] Fix formatting

---
 .github/workflows/commit-access-review.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.github/workflows/commit-access-review.py b/.github/workflows/commit-access-review.py
index c11dd4d6be72c1..4f539fe98004a0 100644
--- a/.github/workflows/commit-access-review.py
+++ b/.github/workflows/commit-access-review.py
@@ -103,7 +103,7 @@ def check_manual_requests(
         data = res_data["data"]
         for issue in data["search"]["nodes"]:
             users.extend([user[1:] for user in re.findall("@[^ ,\n]+", issue["body"])])
-            if issue['author']:
+            if issue["author"]:
                 users.append(issue["author"]["login"])
         has_next_page = data["search"]["pageInfo"]["hasNextPage"]
         if has_next_page:



More information about the llvm-commits mailing list