Skip to content

Commit f78ee79

Browse files
committed
CI: Retry apt ops for mirror sync resilience
Ubuntu package mirrors occasionally sync during CI execution, causing transient failures with file size mismatches. Add 3-attempt retry loops with exponential backoff to all apt update operations across host-x64, host-arm64, and static-analysis jobs. - Wrap apt-get/apt update in retry loops with 5s delay between attempts - Add Acquire::Retries=3 flag to all apt commands for download resilience - Apply to install steps and fallback wget installation paths
1 parent 966e5c1 commit f78ee79

File tree

1 file changed

+29
-8
lines changed

1 file changed

+29
-8
lines changed

.github/workflows/main.yml

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,14 @@ jobs:
6969

7070
- name: Install dependencies
7171
run: |
72-
sudo apt-get update -q=2
73-
sudo apt-get install -q=2 curl libsdl2-dev libsdl2-mixer-dev device-tree-compiler expect bc p7zip-full
72+
# Retry apt-get update to handle transient mirror sync issues
73+
for i in 1 2 3; do
74+
sudo apt-get update -q=2 -o Acquire::Retries=3 && break || {
75+
echo "apt-get update attempt $i failed, retrying..."
76+
sleep 5
77+
}
78+
done
79+
sudo apt-get install -q=2 -o Acquire::Retries=3 curl libsdl2-dev libsdl2-mixer-dev device-tree-compiler expect bc p7zip-full
7480
shell: bash
7581

7682
- name: Install RISC-V Toolchain
@@ -301,8 +307,14 @@ jobs:
301307
githubToken: ${{ github.token }}
302308
# No 'sudo' is available
303309
install: |
304-
apt update -qq
305-
apt install -yqq make git curl wget clang libsdl2-dev libsdl2-mixer-dev lsb-release software-properties-common gnupg bc
310+
# Retry apt update to handle transient mirror sync issues
311+
for i in 1 2 3; do
312+
apt update -qq -o Acquire::Retries=3 && break || {
313+
echo "apt update attempt $i failed, retrying..."
314+
sleep 5
315+
}
316+
done
317+
apt install -yqq -o Acquire::Retries=3 make git curl wget clang libsdl2-dev libsdl2-mixer-dev lsb-release software-properties-common gnupg bc
306318
which wget || echo "WARNING: wget not found after installation"
307319
# FIXME: gcc build fails on Aarch64/Linux hosts
308320
env: |
@@ -311,7 +323,10 @@ jobs:
311323
run: |
312324
# Verify and install wget if needed (workaround for install step issues)
313325
if ! command -v wget > /dev/null 2>&1; then
314-
apt update -qq && apt install -yqq wget
326+
for i in 1 2 3; do
327+
apt update -qq -o Acquire::Retries=3 && break || sleep 5
328+
done
329+
apt install -yqq -o Acquire::Retries=3 wget
315330
fi
316331
git config --global --add safe.directory ${{ github.workspace }}
317332
git config --global --add safe.directory ${{ github.workspace }}/src/softfloat
@@ -570,12 +585,18 @@ jobs:
570585
# LLVM static analysis
571586
- name: set up scan-build
572587
run: |
573-
sudo apt-get update -q=2
574-
sudo apt-get install -q=2 curl libsdl2-dev libsdl2-mixer-dev
588+
# Retry apt-get update to handle transient mirror sync issues
589+
for i in 1 2 3; do
590+
sudo apt-get update -q=2 -o Acquire::Retries=3 && break || {
591+
echo "apt-get update attempt $i failed, retrying..."
592+
sleep 5
593+
}
594+
done
595+
sudo apt-get install -q=2 -o Acquire::Retries=3 curl libsdl2-dev libsdl2-mixer-dev
575596
.ci/fetch.sh -q -o llvm.sh https://apt.llvm.org/llvm.sh
576597
chmod +x ./llvm.sh
577598
sudo ./llvm.sh 18
578-
sudo apt-get install -q=2 clang-18 clang-tools-18
599+
sudo apt-get install -q=2 -o Acquire::Retries=3 clang-18 clang-tools-18
579600
shell: bash
580601
- name: run scan-build without JIT
581602
env:

0 commit comments

Comments
 (0)