Skip to content

Commit

Permalink
[ci] fix getting status of optional workflows in PRs with a lot of co…
Browse files Browse the repository at this point in the history
…mments (#4806)

* Update get_workflow_status.py

* Update get_workflow_status.py
  • Loading branch information
StrikerRUS authored Nov 17, 2021
1 parent b0137de commit 06e3c4a
Showing 1 changed file with 20 additions and 9 deletions.
29 changes: 20 additions & 9 deletions .ci/get_workflow_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,26 @@ def get_runs(trigger_phrase):
pr_runs = []
if environ.get("GITHUB_EVENT_NAME", "") == "pull_request":
pr_number = int(environ.get("GITHUB_REF").split('/')[-2])
req = request.Request(url="{}/repos/microsoft/LightGBM/issues/{}/comments".format(environ.get("GITHUB_API_URL"),
pr_number),
headers={"Accept": "application/vnd.github.v3+json"})
url = request.urlopen(req)
data = json.loads(url.read().decode('utf-8'))
url.close()
pr_runs = [i for i in data
if i['author_association'].lower() in {'owner', 'member', 'collaborator'}
and i['body'].startswith('/gha run {}'.format(trigger_phrase))]
page = 1
while True:
req = request.Request(
url="{}/repos/microsoft/LightGBM/issues/{}/comments?page={}&per_page=100".format(
environ.get("GITHUB_API_URL"),
pr_number,
page
),
headers={"Accept": "application/vnd.github.v3+json"}
)
url = request.urlopen(req)
data = json.loads(url.read().decode('utf-8'))
url.close()
if not data:
break
runs_on_page = [i for i in data
if i['author_association'].lower() in {'owner', 'member', 'collaborator'}
and i['body'].startswith('/gha run {}'.format(trigger_phrase))]
pr_runs.extend(runs_on_page)
page += 1
return pr_runs[::-1]


Expand Down

0 comments on commit 06e3c4a

Please sign in to comment.