Skip to content

Commit ccad708

Browse files
committed
Add --dont-wait option
1 parent 3239af9 commit ccad708

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

misc/scripts/accept-expected-changes-from-ci.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ def get_log_content(status: GithubStatus) -> str:
220220
return content
221221

222222

223-
def main(pr_number: Optional[int], sha_override: Optional[str] = None, force=False):
223+
def main(pr_number: Optional[int], sha_override: Optional[str] = None, force=False, wait_for_ci=True):
224224
if not pr_number and not sha_override:
225225
raise Exception("Must specify either a PR number or a SHA")
226226

@@ -273,8 +273,9 @@ def main(pr_number: Optional[int], sha_override: Optional[str] = None, force=Fal
273273
if status.state == "failure":
274274
lang_test_failures.append(status)
275275
elif status.state == "pending":
276-
LOGGER.error(f"Language tests ({status.context}) are still running, please wait for them to finish before running this script again")
277-
sys.exit(1)
276+
if wait_for_ci:
277+
LOGGER.error(f"Language tests ({status.context}) are still running, please wait for them to finish before running this script again (or run with --dont-wait)")
278+
sys.exit(1)
278279

279280
job_failure_urls = set()
280281
for lang_test_failure in lang_test_failures:
@@ -327,9 +328,10 @@ def main(pr_number: Optional[int], sha_override: Optional[str] = None, force=Fal
327328
check_failure_urls = []
328329
for check in check_suites["check_suites"]:
329330
if check["status"] != "completed":
330-
print(check)
331-
LOGGER.error("At least one check not completed yet!")
332-
sys.exit(1)
331+
if wait_for_ci:
332+
print(check)
333+
LOGGER.error("At least one check not completed yet!")
334+
sys.exit(1)
333335

334336
if check["conclusion"] == "failure":
335337
check_failure_urls.append(check["check_runs_url"])
@@ -460,6 +462,7 @@ def printHelp():
460462
# parse command line arguments
461463
parser = argparse.ArgumentParser()
462464
parser.add_argument("--force", action="store_true", help="Apply patches even if the local SHA is different from the GitHub PR SHA")
465+
parser.add_argument("--dont-wait", dest="wait_for_ci", action="store_false", help="Do not wait for all CI jobs to finish")
463466
parser.add_argument("posarg", nargs="?", default=None)
464467

465468
if DEBUG_LOG_FILE:
@@ -494,4 +497,4 @@ def printHelp():
494497
else:
495498
pr_number = int(args.posarg)
496499

497-
main(pr_number, override_sha, force=args.force)
500+
main(pr_number, override_sha, force=args.force, wait_for_ci=args.wait_for_ci)

0 commit comments

Comments
 (0)