diff --git a/tools/python/run_CIs_for_external_pr.py b/tools/python/run_CIs_for_external_pr.py index b472e9538e..beee4efc74 100644 --- a/tools/python/run_CIs_for_external_pr.py +++ b/tools/python/run_CIs_for_external_pr.py @@ -25,9 +25,9 @@ def parse_args(): return args -def run_gh_pr_command(command: typing.List[str]): +def run_gh_pr_command(command: typing.List[str], check=True): try: - return subprocess.run(["gh", "pr", *command], capture_output=True, text=True, check=True) + return subprocess.run(["gh", "pr", *command], capture_output=True, text=True, check=check) except subprocess.CalledProcessError as cpe: print(cpe) print(cpe.stderr) @@ -51,9 +51,23 @@ def main(): print(f"PR {pr_id} is not OPEN. Currently in state {pieces[1]}.") sys.exit(-1) + print("Check passed pipelines") + gh_out = run_gh_pr_command(["checks", pr_id, "--required"], check=False) + # output format is a tab separated list of columns: + # (pipeline name) "\t" (status) "\t" (ran time) "\t" (url) + checked_pipelines = [ + columns[0] + for columns in (line.strip().split("\t") for line in gh_out.stdout.split("\n")) + if len(columns) == 4 and columns[1] == "pass" + ] + print("Adding azp run commands") # Current pipelines. These change semi-frequently and may need updating. + # + # Note: there is no easy way to get the list for azp "required" pipelines before they starts. + # we need to maintain this list manually. + # pipelines = [ # windows "Windows ARM64 QNN CI Pipeline", @@ -80,6 +94,9 @@ def main(): "onnxruntime-binary-size-checks-ci-pipeline", ] + # remove pipelines that have already run successfully + pipelines = [p for p in pipelines if p not in checked_pipelines] + # azp run is limited to 10 pipelines at a time max_pipelines_per_comment = 10 start = 0