Skip to content

Commit d8fce90

Browse files
committed
fix: iOS status check loop
1 parent db97995 commit d8fce90

File tree

2 files changed

+22
-15
lines changed

2 files changed

+22
-15
lines changed

.codebuild/scripts/run-ios-modelgen-e2e-test.sh

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ get_latest_run_id() {
1313
echo "$latest_run_id"
1414
}
1515

16-
# Function to get the status of a workflow run
16+
# Function to get the status of a workflow run - can be queued or in_progress or completed
1717
get_run_status() {
1818
run_id="$1"
1919
run_status=$(curl -s -H "Authorization: Bearer $GITHUB_TOKEN" \
@@ -24,6 +24,17 @@ get_run_status() {
2424
echo "$run_status"
2525
}
2626

27+
# Function to get the status of a test run - can be success or failure
28+
get_test_status() {
29+
run_id="$1"
30+
test_status=$(curl -s -H "Authorization: Bearer $GITHUB_TOKEN" \
31+
-H "Accept: application/vnd.github+json" \
32+
-H "X-GitHub-Api-Version: 2022-11-28" \
33+
"https://api.github.com/repos/$REPO_OWNER/$REPO_NAME/actions/runs/$run_id" | \
34+
jq -r '.conclusion')
35+
echo "$test_status"
36+
}
37+
2738
# Function to trigger a workflow dispatch event to run the e2e test
2839
trigger_workflow() {
2940
curl -s -H "Authorization: Bearer $GITHUB_TOKEN" \
@@ -40,24 +51,25 @@ main() {
4051
# Get the latest run ID and initial status
4152
latest_run_id=$(get_latest_run_id)
4253
echo "Latest run ID: $latest_run_id"
43-
latest_status=$(get_run_status "$latest_run_id")
54+
run_status=$(get_run_status "$latest_run_id")
4455
timeout=$((SECONDS + 600)) # 600 seconds = 10 minutes
4556

4657
# Continuously check for status until completion
47-
while [[ "$latest_status" != "completed" && "$SECONDS" -lt "$timeout" ]]; do
58+
while [[ "$run_status" != "completed" && "$SECONDS" -lt "$timeout" ]]; do
4859
echo "Test run status: $latest_status"
4960
sleep 10 # Wait before checking again
50-
latest_status=$(get_run_status "$latest_run_id")
61+
run_status=$(get_run_status "$latest_run_id")
5162
done
5263

5364
# Check if the run completed within the specified duration
54-
if [[ "$latest_status" != "completed" ]]; then
65+
if [[ "$run_status" != "completed" ]]; then
5566
echo "The test run did not complete within the specified duration."
5667
exit 1
5768
fi
5869

59-
# Check if the run failed and throw an error if it did
60-
if [[ "$latest_status" == "failure" ]]; then
70+
test_status=$(get_test_status "$latest_run_id")
71+
# Check if the test failed and throw an error if it did
72+
if [[ "$test_status" != "success" ]]; then
6173
echo "The test run failed."
6274
exit 1
6375
else

scripts/test-swift-modelgen.sh

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,22 +26,17 @@ function buildModels() {
2626

2727
function buildAndRunModel() {
2828
modelName=$1
29-
cd $modelName
30-
currentDirectory=$(pwd)
31-
3229
pathToSwiftPackage=$2
3330

34-
# copy with replace all files in current directory to the swift package
31+
# copy with replace all model files to the swift package
3532
mkdir -p $pathToSwiftPackage/Sources/models
3633
rm -rf $pathToSwiftPackage/Sources/models/*
37-
cp -r $currentDirectory/* $pathToSwiftPackage/Sources/models
34+
cp -r $modelName/* $pathToSwiftPackage/Sources/models
35+
ls $pathToSwiftPackage/Sources/models
3836

3937
# build and run the model
4038
cd $pathToSwiftPackage
4139
swift build && swift run
42-
43-
# clean up
44-
cd $currentDirectory
4540
}
4641

4742
function createSwiftPackage() {

0 commit comments

Comments
 (0)