Skip to content

Commit a6b4284

Browse files
authored
[Actions] Resolve ocassional errors from the package install step, optimize the process (#50)
* Refactor Linux build workflow for package installation * Update workflow to use development branch for ThunderLibraries * Update workflow to use main branch for ThunderLibraries
1 parent 34faad6 commit a6b4284

File tree

1 file changed

+43
-16
lines changed

1 file changed

+43
-16
lines changed

.github/workflows/Linux build template.yml

Lines changed: 43 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,49 @@ jobs:
1616
# ----- Packages & artifacts -----
1717
name: Build type - ${{matrix.build_type}}${{matrix.architecture == '32' && ' x86' || ''}}
1818
steps:
19-
- name: Install necessary packages
20-
uses: nick-fields/retry@v3
21-
with:
22-
timeout_minutes: 10
23-
max_attempts: 10
24-
command: |
25-
sudo gem install apt-spy2
26-
sudo apt-spy2 fix --commit --launchpad --country=US
27-
echo "deb http://archive.ubuntu.com/ubuntu/ jammy main universe restricted multiverse" | sudo tee -a /etc/apt/sources.list
28-
echo "deb http://archive.ubuntu.com/ubuntu/ jammy-updates main universe restricted multiverse" | sudo tee -a /etc/apt/sources.list
29-
sudo dpkg --add-architecture i386
30-
sudo apt-get update
31-
sudo apt install python3-pip build-essential cmake ninja-build libusb-1.0-0-dev ${{matrix.architecture == '32' && 'zlib1g-dev:i386 libssl-dev:i386 gcc-13-multilib g++-13-multilib' || 'zlib1g-dev libssl-dev'}}
32-
python3 -m venv venv
33-
source venv/bin/activate
34-
pip install jsonref
19+
- name: Prepare apt (add i386 if needed)
20+
if: ${{ matrix.architecture == '32' }}
21+
run: |
22+
sudo dpkg --add-architecture i386
23+
24+
- name: Update apt indices (with retries)
25+
shell: bash
26+
run: |
27+
set -euo pipefail
28+
for attempt in {1..5}; do
29+
if sudo apt-get update -o Acquire::Retries=5 -o Acquire::http::Timeout=30; then
30+
break
31+
fi
32+
echo "apt-get update failed (attempt $attempt), retrying..."
33+
sleep $((attempt*10))
34+
done
35+
36+
- name: Install system dependencies
37+
shell: bash
38+
run: |
39+
set -euo pipefail
40+
export DEBIAN_FRONTEND=noninteractive
41+
PKGS="python3-venv python3-pip build-essential cmake ninja-build libusb-1.0-0-dev"
42+
if [ "${{ matrix.architecture }}" = "32" ]; then
43+
PKGS="$PKGS zlib1g-dev:i386 libssl-dev:i386 libsbc-dev:i386 gcc-13-multilib g++-13-multilib"
44+
else
45+
PKGS="$PKGS zlib1g-dev libssl-dev libsbc-dev"
46+
fi
47+
for attempt in {1..4}; do
48+
if sudo apt-get install -y --no-install-recommends $PKGS; then
49+
break
50+
fi
51+
echo "apt-get install failed (attempt $attempt), cleaning up & retrying..."
52+
sudo apt-get clean
53+
sleep $((attempt*15))
54+
done
55+
56+
- name: Set up Python environment
57+
run: |
58+
python3 -m venv venv
59+
source venv/bin/activate
60+
pip install --upgrade pip
61+
pip install jsonref
3562
3663
- name: Download artifacts
3764
uses: actions/download-artifact@v4

0 commit comments

Comments
 (0)