Skip to content

Commit 59d13bd

Browse files
committed
Add logging to internal_build.py
1 parent 022a782 commit 59d13bd

File tree

2 files changed

+18
-11
lines changed

2 files changed

+18
-11
lines changed

.github/workflows/internal-build.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ jobs:
2626
CI_CLIENT_SECRET: ${{ secrets.CI_CF_ACCESS_CLIENT_SECRET }}
2727
run: |
2828
python3 ./tools/cross/internal_build.py \
29-
${{github.event.pull_request.id}} \
29+
${{github.event.pull_request.number}} \
3030
${{github.event.pull_request.head.sha}} \
31-
$GITHUB_RUN_ATTEMPT \
31+
${{github.run_attempt}} \
3232
"${{github.event.pull_request.head.ref}}" \
3333
$CI_URL \
3434
$CI_CLIENT_ID \

tools/cross/internal_build.py

+16-9
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import argparse
2-
import requests
3-
import time
42
import sys
3+
import time
4+
5+
import requests
6+
57

68
def parse_args():
79
parser = argparse.ArgumentParser()
@@ -16,32 +18,35 @@ def parse_args():
1618

1719
return parser.parse_args()
1820

21+
1922
if __name__ == "__main__":
2023
args = parse_args()
2124

2225
# Submit build job
2326
headers = {
2427
"CF-Access-Client-Id": args.client_id,
25-
"CF-Access-Client-Secret": args.secret
28+
"CF-Access-Client-Secret": args.secret,
2629
}
2730

2831
payload = {
2932
"pr_id": args.pr_id,
3033
"commit_sha": args.sha,
3134
"run_attempt": args.run_attempt,
32-
"branch_name": args.branch_name
35+
"branch_name": args.branch_name,
3336
}
3437

35-
workflow_id = ''
38+
workflow_id = ""
3639
try:
3740
resp = requests.post(args.URL, headers=headers, json=payload)
3841
resp.raise_for_status()
3942

40-
workflow_id = resp.json().id
43+
workflow_id = resp.json()["workflow_id"]
4144
except Exception as err:
4245
print(f"Unexpected error {err=}, {type(err)=}")
4346
sys.exit(1)
4447

48+
print("Internal build submitted")
49+
4550
time.sleep(30)
4651

4752
# Poll build status
@@ -50,15 +55,18 @@ def parse_args():
5055

5156
while failed_requests < FAILED_REQUEST_LIMIT:
5257
try:
53-
resp = requests.get(args.URL, headers=headers, params={ 'id': workflow_id })
58+
resp = requests.get(args.URL, headers=headers, params={"id": workflow_id})
5459
resp.raise_for_status()
5560

56-
status = resp.json().status
61+
status = resp.json()["status"]
5762
if status == "errored":
63+
print("Build failed")
5864
sys.exit(1)
5965
elif status == "complete":
6066
break
6167

68+
print("Waiting for build to finish..")
69+
6270
except Exception as err:
6371
print(f"Unexpected error {err=}, {type(err)=}")
6472
failed_requests = failed_requests + 1
@@ -68,4 +76,3 @@ def parse_args():
6876
sys.exit(1)
6977

7078
print("Internal build succeeded")
71-

0 commit comments

Comments
 (0)