ci(#1347): re-run a build that failed only in its native-assets downloads
Package build hooks (sqlite3, llamadart) download prebuilt libraries during flutter build. A bad download fails the build with "Building native assets failed" although the code is fine. It hit Windows, macOS and Android four times on 2026-11-30, each needing a manual re-run, once on a release-promotion PR. flutter-build-retry.sh runs the build and builds again, up to 3 attempts in all, only when the output names that failure. Any other failure is returned at once. Every native flutter build in build.yml, release-signed.yml, ios-signed.yml and macos-signed.yml goes through it; the Windows steps run it under bash. A new build.yml step proves it: a clean build runs once, a failure that clears runs twice, a lasting one stops at 3 and fails, and a compile error is not retried. Run locally against a retry that never retries and one that retries everything, the step fails both. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>pull/1356/head
parent
9168dea755
commit
01e07562d6
@ -0,0 +1,33 @@
|
||||
#!/usr/bin/env bash
|
||||
# Run a flutter build, and re-run it only when it failed in the native-assets
|
||||
# step (#1347). Package build hooks (sqlite3, llamadart) download prebuilt
|
||||
# libraries during the build; a bad or broken download fails the whole build
|
||||
# with "Building native assets failed" although the code is fine. Any other
|
||||
# failure is returned at once, unretried.
|
||||
#
|
||||
# Usage: flutter-build-retry.sh <command> [args...]
|
||||
# FLUTTER_BUILD_ATTEMPTS sets the total number of attempts (default 3).
|
||||
set -uo pipefail
|
||||
|
||||
attempts="${FLUTTER_BUILD_ATTEMPTS:-3}"
|
||||
marker='Building native assets failed'
|
||||
log="$(mktemp)"
|
||||
trap 'rm -f "${log}"' EXIT
|
||||
|
||||
status=1
|
||||
for ((i = 1; i <= attempts; i++)); do
|
||||
"$@" 2>&1 | tee "${log}"
|
||||
status=${PIPESTATUS[0]}
|
||||
if [ "${status}" -eq 0 ]; then
|
||||
exit 0
|
||||
fi
|
||||
if ! grep -qF "${marker}" "${log}"; then
|
||||
exit "${status}"
|
||||
fi
|
||||
if [ "${i}" -lt "${attempts}" ]; then
|
||||
echo "::warning::Native assets failed on attempt ${i} of ${attempts}; building again (#1347)."
|
||||
fi
|
||||
done
|
||||
|
||||
echo "::error::Native assets failed on all ${attempts} attempts (#1347)."
|
||||
exit "${status}"
|
||||
Loading…
Reference in new issue