Skip to content

Commit 08374e7

Browse files
ilopezlunaclaude
andcommitted
ci(release): guard run-ID polling against transient gh failures
Follow-up to #1005 (Sourcery review). The monotonic run-ID polling loops compared `$CANDIDATE` numerically without validating it. If `gh run list` fails transiently or returns an unexpected payload, CANDIDATE can be empty or non-numeric and `[ "$CANDIDATE" -gt "$BEFORE_ID" ]` errors with "integer expression expected" — the exact kind of flake this logic was meant to absorb. - Tolerate transient `gh` failures mid-poll (`2>/dev/null || echo ""`) and skip any iteration where CANDIDATE is empty/non-numeric instead of erroring. - Validate BEFORE_ID up front and fail with a clear message (before dispatch) if it can't be read. - Include before/last-seen IDs and wait duration in the failure message to make race/misconfig diagnosis easier. Applied to both the desktop (release-cli-dd.yml) and packaging (release-model.yml) trigger jobs. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 2221f17 commit 08374e7

1 file changed

Lines changed: 36 additions & 6 deletions

File tree

.github/workflows/release.yml

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -528,28 +528,43 @@ jobs:
528528
BEFORE_ID=$(gh run list \
529529
--repo docker/inference-engine-llama.cpp \
530530
--workflow release-cli-dd.yml \
531-
--limit 1 --json databaseId --jq '.[0].databaseId // 0')
531+
--limit 1 --json databaseId --jq '.[0].databaseId // 0' 2>/dev/null || echo "")
532+
case "$BEFORE_ID" in
533+
''|*[!0-9]*)
534+
echo "::error::Could not read the pre-dispatch run ID for release-cli-dd.yml"
535+
exit 1
536+
;;
537+
esac
532538
533539
gh workflow run release-cli-dd.yml \
534540
--repo docker/inference-engine-llama.cpp \
535541
-f model-cli-ref="$RELEASE_TAG" \
536542
-f tag="v$VERSION"
537543
544+
# Poll for the run WE just triggered: the first run whose ID exceeds
545+
# BEFORE_ID. Tolerate transient `gh` failures mid-poll (empty or
546+
# non-numeric CANDIDATE) by skipping the iteration — a flaky query
547+
# must not abort the release on `integer expression expected`.
538548
RUN_ID=""
549+
LAST_SEEN=""
539550
for _ in $(seq 1 30); do
540551
sleep 3
541552
CANDIDATE=$(gh run list \
542553
--repo docker/inference-engine-llama.cpp \
543554
--workflow release-cli-dd.yml \
544-
--limit 1 --json databaseId --jq '.[0].databaseId // 0')
555+
--limit 1 --json databaseId --jq '.[0].databaseId // 0' 2>/dev/null || echo "")
556+
case "$CANDIDATE" in
557+
''|*[!0-9]*) continue ;;
558+
esac
559+
LAST_SEEN="$CANDIDATE"
545560
if [ "$CANDIDATE" -gt "$BEFORE_ID" ]; then
546561
RUN_ID="$CANDIDATE"
547562
break
548563
fi
549564
done
550565
551566
if [ -z "$RUN_ID" ]; then
552-
echo "::error::Failed to determine Desktop CLI release run ID"
567+
echo "::error::Failed to determine Desktop CLI release run ID after ~90s (before=$BEFORE_ID, last seen=${LAST_SEEN:-none})"
553568
exit 1
554569
fi
555570
@@ -596,27 +611,42 @@ jobs:
596611
BEFORE_ID=$(gh run list \
597612
--repo docker/packaging \
598613
--workflow release-model.yml \
599-
--limit 1 --json databaseId --jq '.[0].databaseId // 0')
614+
--limit 1 --json databaseId --jq '.[0].databaseId // 0' 2>/dev/null || echo "")
615+
case "$BEFORE_ID" in
616+
''|*[!0-9]*)
617+
echo "::error::Could not read the pre-dispatch run ID for release-model.yml"
618+
exit 1
619+
;;
620+
esac
600621
601622
gh workflow run release-model.yml \
602623
--repo docker/packaging \
603624
-f ref="$RELEASE_TAG"
604625
626+
# Poll for the run WE just triggered: the first run whose ID exceeds
627+
# BEFORE_ID. Tolerate transient `gh` failures mid-poll (empty or
628+
# non-numeric CANDIDATE) by skipping the iteration — a flaky query
629+
# must not abort the release on `integer expression expected`.
605630
RUN_ID=""
631+
LAST_SEEN=""
606632
for _ in $(seq 1 30); do
607633
sleep 3
608634
CANDIDATE=$(gh run list \
609635
--repo docker/packaging \
610636
--workflow release-model.yml \
611-
--limit 1 --json databaseId --jq '.[0].databaseId // 0')
637+
--limit 1 --json databaseId --jq '.[0].databaseId // 0' 2>/dev/null || echo "")
638+
case "$CANDIDATE" in
639+
''|*[!0-9]*) continue ;;
640+
esac
641+
LAST_SEEN="$CANDIDATE"
612642
if [ "$CANDIDATE" -gt "$BEFORE_ID" ]; then
613643
RUN_ID="$CANDIDATE"
614644
break
615645
fi
616646
done
617647
618648
if [ -z "$RUN_ID" ]; then
619-
echo "::error::Failed to determine packaging workflow run ID"
649+
echo "::error::Failed to determine packaging workflow run ID after ~90s (before=$BEFORE_ID, last seen=${LAST_SEEN:-none})"
620650
exit 1
621651
fi
622652

0 commit comments

Comments
 (0)