[llvm] [Github] Add job to count running jobs (PR #80250)
Aiden Grossman via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 31 23:01:59 PST 2024
https://github.com/boomanaiden154 created https://github.com/llvm/llvm-project/pull/80250
This patch adds a script to automatically query the number of running jobs and print them to the terminal as this functionality isn't available through the Github UI (unless you are a Github administrator).
>From 47a7d9402146a5e1a9741ced2f6fada19d2c2e61 Mon Sep 17 00:00:00 2001
From: Aiden Grossman <agrossman154 at yahoo.com>
Date: Thu, 1 Feb 2024 06:59:40 +0000
Subject: [PATCH] [Github] Add job to count running jobs
This patch adds a script to automatically query the number of running
jobs and print them to the terminal as this functionality isn't
available through the Github UI (unless you are a Github administrator).
---
llvm/utils/count_running_jobs.py | 49 ++++++++++++++++++++++++++++++++
1 file changed, 49 insertions(+)
create mode 100644 llvm/utils/count_running_jobs.py
diff --git a/llvm/utils/count_running_jobs.py b/llvm/utils/count_running_jobs.py
new file mode 100644
index 0000000000000..a53bc02f7b0ae
--- /dev/null
+++ b/llvm/utils/count_running_jobs.py
@@ -0,0 +1,49 @@
+# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+# See https://llvm.org/LICENSE.txt for license information.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+"""Tool for counting the number of currently running Github actions jobs.
+
+This tool counts and enumerates the currently active jobs in Github actions
+for the monorepo.
+
+python3 ./count_running_jobs.py --token=<github token>
+
+Note that the token argument is optional. If it is not specified, the queries
+will be performed unauthenticated.
+"""
+
+import argparse
+import github
+
+
+def main(token):
+ workflows = (
+ github.Github(args.token)
+ .get_repo("llvm/llvm-project")
+ .get_workflow_runs(status="in_progress")
+ )
+
+ in_progress_jobs = 0
+
+ for workflow in workflows:
+ for job in workflow.jobs():
+ if job.status == "in_progress":
+ print(f"{workflow.name}/{job.name}")
+ in_progress_jobs += 1
+
+ print(f"\nFound {in_progress_jobs} running jobs.")
+
+
+if __name__ == "__main__":
+ parser = argparse.ArgumentParser(
+ description="A tool for listing and counting Github actions jobs"
+ )
+ parser.add_argument(
+ "--token",
+ type=str,
+ help="The Github token to use to authorize with the API",
+ default=None,
+ nargs="?",
+ )
+ args = parser.parse_args()
+ main(args.token)
More information about the llvm-commits
mailing list