Skip to content
TypeScript

fix(ci): add fallback Ubuntu package mirrors (#9864)

maria4ade36518023
diff --git a/.github/actions/setup-apt-mirrors/action.yml b/.github/actions/setup-apt-mirrors/action.yml
new file mode 100644
index 00000000000..5beff201d18
--- /dev/null
+++ b/.github/actions/setup-apt-mirrors/action.yml
@@ -0,0 +1,22 @@
+name: Setup APT mirrors
+description: Configure Ubuntu package downloads with automatic mirror failover.
+runs:
+ using: composite
+ steps:
+ - shell: bash
+ run: |
+ # Replace the existing Blacksmith mirror list as well as direct sources.
+ printf '%s\tpriority:%s\n' \
+ https://archive.ubuntu.com/ubuntu 1 \
+ https://mirrors.edge.kernel.org/ubuntu 2 \
+ https://mirror.math.princeton.edu/pub/ubuntu 3 \
+ | sudo tee /etc/apt/blacksmith-ubuntu-mirrors.txt > /dev/null
+
+ # APT's mirror transport retries each file against the next server.
+ sudo find /etc/apt -maxdepth 2 -type f \( -name '*.list' -o -name '*.sources' \) \
+ -exec sed -i -E \
+ 's#https?://(([^/]+\.)?archive|security)\.ubuntu\.com/ubuntu/?#mirror+file:/etc/apt/blacksmith-ubuntu-mirrors.txt#g' {} +
+
+ # Move on to a fallback before an unreachable server exhausts the job.
+ printf '%s\n' 'Acquire::http::Timeout "15";' 'Acquire::https::Timeout "15";' \
+ | sudo tee /etc/apt/apt.conf.d/80-mirror-timeouts > /dev/null
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index fba55f53aaf..6c0866fa63a 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -51,6 +51,8 @@ jobs:
- name: Typecheck
run: vpr typecheck
+ - uses: ./.github/actions/setup-apt-mirrors
+
- name: Install browser secret helper build libraries
run: |
sudo sed -i 's|http://|https://|g' /etc/apt/blacksmith-ubuntu-mirrors.txt /etc/apt/sources.list.d/ubuntu.sources
@@ -90,6 +92,8 @@ jobs:
- name: Ensure Electron runtime is installed
run: vp run --filter @t3tools/desktop ensure:electron
+ - uses: ./.github/actions/setup-apt-mirrors
+
- name: Install browser secret helper build libraries
run: |
sudo sed -i 's|http://|https://|g' /etc/apt/blacksmith-ubuntu-mirrors.txt /etc/apt/sources.list.d/ubuntu.sources
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 404e4e8075c..517a2fdb2ad 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -216,6 +216,8 @@ jobs:
- name: Typecheck
run: vp run typecheck
+ - uses: ./.github/actions/setup-apt-mirrors
+
- name: Install browser secret helper build libraries
run: sudo apt-get update && sudo apt-get install -y libsecret-1-dev pkg-config
@@ -527,6 +529,9 @@ jobs:
exit $code
}
+ - uses: ./.github/actions/setup-apt-mirrors
+ if: matrix.platform == 'linux'
+
- name: Install Linux desktop build libraries
if: matrix.platform == 'linux'
shell: bash