Update run_CIs_for_external_pr.py to skip passed checks (#16808)

### Description
Update run_CIs_for_external_pr.py to skip passed checks
This commit is contained in:
Yulong Wang 2023-07-24 23:11:53 -07:00 committed by GitHub
parent 2e214d6e27
commit 8b30dc11d7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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