Files
VoiceStudio/mobile/android/scripts/resolve-dependencies.sh
Palash Debnath 29ca59dcdc ci: retry rate-limited Android downloads before every build, and racy test cleanup (#4495)
* ci(android): retry every Maven Central download on HTTP 429

* changelog: add fragment for #4495

* test(electron): retry temp-folder cleanup that races a late write

macOS CI failed backend-startup-budget's teardown with ENOTEMPTY when a
write landed while the folder was being removed. Every test that removes
its temp folder with rmSync now retries, as runtime-launch-refusal does.

* test(electron): let report-bug's node:fs typing accept cleanup retries

* ci: read Gradle's real retry key, catch 429s behind any cause, restart racy temp cleanup

- gradle.properties: Gradle 8.13 reads repository.max.tentatives, not
  max.retries, so the limit stayed at three attempts.
- The dependency warm-up walks every getCauses() branch, so a 429 behind a
  timeout in a multi-cause failure still triggers the shell retry.
- removeTempDir() restarts the whole recursive removal on ENOTEMPTY/EBUSY/
  EPERM; rmSync's maxRetries re-runs only the final rmdir and keeps failing
  when a file lands after the folder was listed. Used by every test that
  had the retry options, with a regression test.

* ci: retry rate-limited Gradle downloads before every Android build

The warm-up moves into mobile/android/scripts/resolve-dependencies.sh and its
init script, now run before the emulator jobs and both release builds as well
as the unit-test job. Only a 429 is retried; any other failure is left to the
build step. Release recovery of an older tag takes the scripts from the
workflow's own commit, like the SDK installer. A test keeps every Gradle job
behind the warm-up and checks the retry behaviour with a fake gradlew.

* test(android): give the dictation protocol waits room on a busy CI runner

emptySummaryAndLegacyEofPreserveCommittedText timed out at 2 s on the shared
two-worker runner. Every wait in the file is for an event that should happen,
so one 10 s limit keeps real hangs fast to fail without flaking.

* ci(android): read Maven Central through Google's mirror first

Maven Central kept answering the shared runner IPs with HTTP 429 through
every retry (four rounds over ~5 minutes). resolve-dependencies.sh now
installs an init.d script that lists Google's Maven Central mirror ahead of
the build's repositories for every later Gradle run in the job (build, tests,
emulator). Maven Central stays listed after it, so anything the mirror lacks
still resolves. The release workflow checks the script out with the retry.
2026-11-26 19:05:12 -08:00

27 lines
1.3 KiB
Bash
Executable File

#!/usr/bin/env bash
# Downloads every Gradle dependency before the build, retrying with backoff when
# Maven Central rate-limits (HTTP 429) the shared CI runner IP. Run it from the
# Gradle project directory; extra tasks to run alongside (for example
# :app:prepareRobolectricSdk) are arguments. Any other failure is left to the
# build step, which reports it with its full context.
set -uo pipefail
scripts="$(cd "$(dirname "$0")" && pwd)"
# Every later Gradle run in this job (build, tests, emulator) also reads
# Maven Central through its mirror first: an init.d script applies to all.
init_dir="${GRADLE_USER_HOME:-$HOME/.gradle}/init.d"
mkdir -p "$init_dir" && cp "$scripts/maven-central-mirror.init.gradle" "$init_dir/"
log="$(mktemp)"
trap 'rm -f "$log"' EXIT
for delay in ${RESOLVE_RETRY_DELAYS:-0 30 90 180}; do
sleep "$delay"
./gradlew --no-daemon -I "$scripts/resolve-all.init.gradle" "$@" resolveAllDependencies 2>&1 | tee "$log"
[ "${PIPESTATUS[0]}" -eq 0 ] && exit 0
if ! grep -qE 'status code 429|Too Many Requests' "$log"; then
echo "::warning::Dependency download failed for a reason other than rate limiting; the build step reports it"
exit 0
fi
echo "::warning::Maven Central rate-limited the dependency download; retrying"
done
echo "::error::Maven Central still rate-limits the dependency download after every retry"
exit 1