Skip to content

Commit 42e8837

Browse files
fabiobaltieridanieldegrasse
authored andcommitted
scripts: do_not_merge: wait for manifest before checking
Seems like github relabel rerun is susceptible to race conditions and may not rerun the label check script if the manifest workflow runs at the same time. Delay the check to explicitly wait until the currently checked sha had a successful manifest run. Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
1 parent db18e4c commit 42e8837

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

scripts/ci/do_not_merge.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@
44
# SPDX-License-Identifier: Apache-2.0
55

66
import argparse
7+
import datetime
78
import os
89
import sys
10+
import time
911

1012
import github
1113

@@ -31,6 +33,30 @@ def parse_args(argv):
3133
return parser.parse_args(argv)
3234

3335

36+
WAIT_FOR_WORKFLOWS = set({"Manifest"})
37+
WAIT_FOR_DELAY_S = 60
38+
39+
40+
def workflow_delay(repo, pr):
41+
print(f"PR is at {pr.head.sha}")
42+
43+
while True:
44+
runs = repo.get_workflow_runs(head_sha=pr.head.sha)
45+
46+
completed = set()
47+
for run in runs:
48+
print(f"{run.name}: {run.status} {run.conclusion} {run.html_url}")
49+
if run.status == "completed" and run.conclusion == "success":
50+
completed.add(run.name)
51+
52+
if WAIT_FOR_WORKFLOWS.issubset(completed):
53+
return
54+
55+
ts = datetime.datetime.now()
56+
print(f"wait: {ts} completed={completed}")
57+
time.sleep(WAIT_FOR_DELAY_S)
58+
59+
3460
def main(argv):
3561
args = parse_args(argv)
3662

@@ -42,6 +68,8 @@ def main(argv):
4268
repo = gh.get_repo("zephyrproject-rtos/zephyr")
4369
pr = repo.get_pull(args.pull_request)
4470

71+
workflow_delay(repo, pr)
72+
4573
print(f"pr: {pr.html_url}")
4674

4775
fail = False

0 commit comments

Comments
 (0)