Files
clang-p2996/.github/workflows/pr-subscriber-wait.py
Tom Stellard c532db0133 workflows/pr-subscriber: Use our own custom concurrency implementation (#66263)
The builtin concurrency functionality for the workflows will cancel a
pending job if there is another job from the same workflow running. For
the pr-subscriber job, this means that if multiple labels are added at
the same time, then some of the pr-subscriber jobs will be cancelled and
the PR will not have all the necessary mentions.
2023-09-13 23:46:23 -07:00

28 lines
878 B
Python

import github
import os
import sys
import time
def needs_to_wait(repo):
workflow_name = os.environ.get("GITHUB_WORKFLOW")
run_number = os.environ.get("GITHUB_RUN_NUMBER")
print("Workflow Name:", workflow_name, "Run Number:", run_number)
for status in ["in_progress", "queued"]:
for workflow in repo.get_workflow_runs(status=status):
print("Looking at ", workflow.name, "#", workflow.run_number)
if workflow.name != workflow_name:
continue
if workflow.run_number < int(run_number):
print("Workflow {} still {} ".format(workflow.run_number, status))
return True
return False
repo_name = os.environ.get("GITHUB_REPOSITORY")
token = os.environ.get("GITHUB_TOKEN")
gh = github.Github(token)
repo = gh.get_repo(repo_name)
while needs_to_wait(repo):
time.sleep(30)