[llvm] 66d8377 - [Github] Add ability to filter jobs in job counting script (#82136)

via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 19 16:28:49 PST 2024


Author: Aiden Grossman
Date: 2024-02-19T16:28:47-08:00
New Revision: 66d8377dbddbf8eb2d692b93e5984bb38fa698e7

URL: https://github.com/llvm/llvm-project/commit/66d8377dbddbf8eb2d692b93e5984bb38fa698e7
DIFF: https://github.com/llvm/llvm-project/commit/66d8377dbddbf8eb2d692b93e5984bb38fa698e7.diff

LOG: [Github] Add ability to filter jobs in job counting script (#82136)

This patch adds a new flag pair, --filter-gha-runners, and
--no-filter-gha-runners, that filters out all non-Github hosted runners
so that we can actual counts of the Github runners, where we are
actually limited.

Added: 
    

Modified: 
    llvm/utils/count_running_jobs.py

Removed: 
    


################################################################################
diff  --git a/llvm/utils/count_running_jobs.py b/llvm/utils/count_running_jobs.py
index a53bc02f7b0ae1..dee822a811258e 100644
--- a/llvm/utils/count_running_jobs.py
+++ b/llvm/utils/count_running_jobs.py
@@ -16,7 +16,7 @@
 import github
 
 
-def main(token):
+def main(token, filter_gha_runners):
     workflows = (
         github.Github(args.token)
         .get_repo("llvm/llvm-project")
@@ -28,6 +28,17 @@ def main(token):
     for workflow in workflows:
         for job in workflow.jobs():
             if job.status == "in_progress":
+                # TODO(boomanaiden154): Remove the try/except block once we are able
+                # to pull in a PyGithub release that has the runner_group_name property
+                # for workflow jobs.
+                try:
+                    if filter_gha_runners and job.runner_group_name != "GitHub Actions":
+                        continue
+                except:
+                    print(
+                        "Failed to filter runners. Your PyGithub version is "
+                        "most likely too old."
+                    )
                 print(f"{workflow.name}/{job.name}")
                 in_progress_jobs += 1
 
@@ -45,5 +56,18 @@ def main(token):
         default=None,
         nargs="?",
     )
+    parser.add_argument(
+        "--filter-gha-runners",
+        help="Only consider jobs running on hosted Github actions runners",
+        action="store_true",
+    )
+    parser.add_argument(
+        "--no-filter-gha-runners",
+        dest="filter_gha_runners",
+        action="store_false",
+        help="Consider all running jobs",
+    )
+    parser.set_defaults(filter_gha_runners=False)
+
     args = parser.parse_args()
-    main(args.token)
+    main(args.token, args.filter_gha_runners)


        


More information about the llvm-commits mailing list