|
2 | 2 | import subprocess
|
3 | 3 | import time
|
4 | 4 |
|
| 5 | + |
5 | 6 | def main():
|
6 |
| - parser = argparse.ArgumentParser() |
7 |
| - parser.add_argument("pr", help="Pull request number") |
8 |
| - parser.add_argument("check", help="Pull request check to poll for") |
9 |
| - args = parser.parse_args() |
10 |
| - |
11 |
| - print(f"Gathering info on the {args.check} check being run for the current pull request.") |
12 |
| - polling = True |
13 |
| - poll_count = 0 |
14 |
| - poll_max = 300 |
15 |
| - check_passed = False |
16 |
| - while(polling): |
17 |
| - for line in subprocess.run(f"gh pr checks -R project-chip/connectedhomeip {args.pr}", stdout=subprocess.PIPE, shell=True).stdout.decode("utf-8").splitlines(): |
18 |
| - if args.check in line: |
19 |
| - print(line) |
20 |
| - if "pending" in line: |
21 |
| - if poll_count == poll_max: |
22 |
| - polling = false |
23 |
| - else: |
24 |
| - poll_count += 1 |
25 |
| - time.sleep(1) |
26 |
| - break |
27 |
| - elif "pass" in line: |
28 |
| - print(f"Fast CI {args.check} has passed; if all fast CI passes, builds and tests may commence.") |
29 |
| - exit(0) |
30 |
| - elif "fail" in line: |
31 |
| - print(f"Fast CI {args.check} has failed; please resolve this issue before running builds and tests.") |
32 |
| - exit(1) |
33 |
| - |
34 |
| - print(f"Polling for completion of fast CI {args.check} failed. Please ensure the name of the check was entered correctly and verify that it should take less than {poll_max} seconds to run.") |
35 |
| - exit(1) |
| 7 | + parser = argparse.ArgumentParser() |
| 8 | + parser.add_argument("pr", help="Pull request number") |
| 9 | + parser.add_argument("check", help="Pull request check to poll for") |
| 10 | + args = parser.parse_args() |
| 11 | + |
| 12 | + print(f"Gathering info on the {args.check} check being run for the current pull request.") |
| 13 | + polling = True |
| 14 | + poll_count = 0 |
| 15 | + poll_max = 300 |
| 16 | + check_passed = False |
| 17 | + while (polling): |
| 18 | + for line in subprocess.run(f"gh pr checks -R project-chip/connectedhomeip {args.pr}", stdout=subprocess.PIPE, shell=True).stdout.decode("utf-8").splitlines(): |
| 19 | + if args.check in line: |
| 20 | + print(line) |
| 21 | + if "pending" in line: |
| 22 | + if poll_count == poll_max: |
| 23 | + polling = false |
| 24 | + else: |
| 25 | + poll_count += 1 |
| 26 | + time.sleep(1) |
| 27 | + break |
| 28 | + elif "pass" in line: |
| 29 | + print(f"Fast CI {args.check} has passed; if all fast CI passes, builds and tests may commence.") |
| 30 | + exit(0) |
| 31 | + elif "fail" in line: |
| 32 | + print(f"Fast CI {args.check} has failed; please resolve this issue before running builds and tests.") |
| 33 | + exit(1) |
| 34 | + |
| 35 | + print( |
| 36 | + f"Polling for completion of fast CI {args.check} failed. Please ensure the name of the check was entered correctly and verify that it should take less than {poll_max} seconds to run.") |
| 37 | + exit(1) |
| 38 | + |
36 | 39 |
|
37 | 40 | if __name__ == "__main__":
|
38 |
| - main() |
| 41 | + main() |
0 commit comments