Skip to content

[Github] Add ability to filter jobs in job counting script #82136

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 26 additions & 2 deletions llvm/utils/count_running_jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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

Expand All @@ -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)