Skip to content

Commit 877494f

Browse files
committed
ci: add wait ci complete
1 parent c7ddc64 commit 877494f

File tree

1 file changed

+19
-57
lines changed

1 file changed

+19
-57
lines changed

.github/workflows/upstream-sync.yml

Lines changed: 19 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,13 @@ jobs:
9696
9797
echo "PR_NUMBER=$PR_NUMBER" >> $GITHUB_ENV
9898
99-
- name: Check PR status
99+
- name: Check PR status and wait for CI
100100
id: check_pr
101101
if: ${{ env.SKIP_PR != 'true' }}
102102
env:
103103
GITHUB_TOKEN: ${{ secrets.PAT_SERVICE_ACCOUNT }}
104104
run: |
105+
# Check if PR can be merged
105106
MERGE_STATUS=$(gh pr view $PR_NUMBER --repo menloresearch/llama.cpp --json mergeStateStatus --jq '.mergeStateStatus')
106107
echo "PR merge status: $MERGE_STATUS"
107108
@@ -111,65 +112,26 @@ jobs:
111112
exit 0
112113
fi
113114
114-
# Check if there are any CI checks
115-
CI_CHECKS_EXIST=false
116-
MAX_ATTEMPTS=5
117-
118-
for i in $(seq 1 $MAX_ATTEMPTS); do
119-
echo "Checking for CI checks (attempt $i of $MAX_ATTEMPTS)..."
120-
CI_CHECK_COUNT=$(gh pr checks $PR_NUMBER --repo menloresearch/llama.cpp --json name --jq 'length')
121-
122-
if [[ "$CI_CHECK_COUNT" -gt 0 ]]; then
123-
CI_CHECKS_EXIST=true
124-
echo "Found $CI_CHECK_COUNT CI checks"
125-
break
126-
fi
127-
128-
echo "No CI checks found yet, waiting 10 seconds..."
129-
sleep 10
130-
done
131-
132-
# Only wait for CI if checks exist
133-
if [[ "$CI_CHECKS_EXIST" == "true" ]]; then
134-
echo "Waiting for CI checks to complete..."
135-
MAX_WAIT_TIME=10 # Maximum wait time in minutes
136-
WAIT_INTERVAL=30 # Check interval in seconds
137-
ELAPSED_TIME=0
138-
139-
while (( ELAPSED_TIME < MAX_WAIT_TIME * 60 )); do
140-
# Get CI check details
141-
CI_STATUS=$(gh pr checks $PR_NUMBER --repo menloresearch/llama.cpp --json status,conclusion --jq '.[].status')
142-
143-
# If any are still in progress, wait
144-
if echo "$CI_STATUS" | grep -q "IN_PROGRESS"; then
145-
echo "CI is still running, waiting... ($ELAPSED_TIME seconds elapsed of $(( MAX_WAIT_TIME * 60 )) max)"
146-
sleep $WAIT_INTERVAL
147-
ELAPSED_TIME=$((ELAPSED_TIME + WAIT_INTERVAL))
148-
else
149-
# All checks are complete
150-
echo "All CI checks completed!"
151-
152-
# Check for failures
153-
CI_CONCLUSIONS=$(gh pr checks $PR_NUMBER --repo menloresearch/llama.cpp --json conclusion --jq '.[].conclusion')
154-
if echo "$CI_CONCLUSIONS" | grep -qE "FAILURE|CANCELLED|TIMED_OUT"; then
155-
echo "Some CI checks failed. Human review required."
156-
echo "SKIP_MERGE=true" >> $GITHUB_ENV
157-
exit 0
158-
fi
159-
160-
break
161-
fi
162-
163-
# Check if we've exceeded the maximum wait time
164-
if (( ELAPSED_TIME >= MAX_WAIT_TIME * 60 )); then
165-
echo "Maximum wait time of $MAX_WAIT_TIME minutes exceeded. Marking for human review."
115+
# Wait for CI checks using the more reliable method
116+
echo "Waiting for CI checks to complete..."
117+
while true; do
118+
ci_completed=$(gh pr checks $PR_NUMBER --repo menloresearch/llama.cpp --json completedAt --jq '.[].completedAt')
119+
if echo "$ci_completed" | grep -q "0001-01-01T00:00:00Z"; then
120+
echo "CI is still running, waiting..."
121+
sleep 60
122+
else
123+
echo "CI has completed, checking states..."
124+
ci_states=$(gh pr checks $PR_NUMBER --repo menloresearch/llama.cpp --json state --jq '.[].state')
125+
if echo "$ci_states" | grep -vqE "SUCCESS|SKIPPED"; then
126+
echo "CI failed, exiting..."
166127
echo "SKIP_MERGE=true" >> $GITHUB_ENV
167128
exit 0
129+
else
130+
echo "CI passed, proceeding with merge..."
131+
break
168132
fi
169-
done
170-
else
171-
echo "No CI checks found after $MAX_ATTEMPTS attempts. Proceeding with merge."
172-
fi
133+
fi
134+
done
173135
174136
- name: Merge PR and create tag
175137
if: ${{ env.SKIP_PR != 'true' && env.SKIP_MERGE != 'true' }}

0 commit comments

Comments
 (0)