Skip to content

Commit 66d8377

Browse files
[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.
1 parent eac8604 commit 66d8377

File tree

1 file changed

+26
-2
lines changed

1 file changed

+26
-2
lines changed

llvm/utils/count_running_jobs.py

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import github
1717

1818

19-
def main(token):
19+
def main(token, filter_gha_runners):
2020
workflows = (
2121
github.Github(args.token)
2222
.get_repo("llvm/llvm-project")
@@ -28,6 +28,17 @@ def main(token):
2828
for workflow in workflows:
2929
for job in workflow.jobs():
3030
if job.status == "in_progress":
31+
# TODO(boomanaiden154): Remove the try/except block once we are able
32+
# to pull in a PyGithub release that has the runner_group_name property
33+
# for workflow jobs.
34+
try:
35+
if filter_gha_runners and job.runner_group_name != "GitHub Actions":
36+
continue
37+
except:
38+
print(
39+
"Failed to filter runners. Your PyGithub version is "
40+
"most likely too old."
41+
)
3142
print(f"{workflow.name}/{job.name}")
3243
in_progress_jobs += 1
3344

@@ -45,5 +56,18 @@ def main(token):
4556
default=None,
4657
nargs="?",
4758
)
59+
parser.add_argument(
60+
"--filter-gha-runners",
61+
help="Only consider jobs running on hosted Github actions runners",
62+
action="store_true",
63+
)
64+
parser.add_argument(
65+
"--no-filter-gha-runners",
66+
dest="filter_gha_runners",
67+
action="store_false",
68+
help="Consider all running jobs",
69+
)
70+
parser.set_defaults(filter_gha_runners=False)
71+
4872
args = parser.parse_args()
49-
main(args.token)
73+
main(args.token, args.filter_gha_runners)

0 commit comments

Comments
 (0)