From b3c808ea963c94e6ab6272a7f5050b82fdf07eea Mon Sep 17 00:00:00 2001 From: Neil Date: Wed, 11 Nov 2026 07:33:26 -0800 Subject: [PATCH] fix(ci): recover dpkg locks and bound WebKit setup retries --- .github/scripts/install-ubuntu-apt-packages.sh | 14 ++------------ .github/scripts/recover-ubuntu-dpkg.sh | 10 ++++++++++ .github/scripts/use-ubuntu-apt-mirror.sh | 12 ++++++++++++ .github/workflows/pr.yml | 13 ++++++++++++- 4 files changed, 36 insertions(+), 13 deletions(-) create mode 100644 .github/scripts/recover-ubuntu-dpkg.sh create mode 100644 .github/scripts/use-ubuntu-apt-mirror.sh diff --git a/.github/scripts/install-ubuntu-apt-packages.sh b/.github/scripts/install-ubuntu-apt-packages.sh index 72881e7231f..a93614fbde2 100644 --- a/.github/scripts/install-ubuntu-apt-packages.sh +++ b/.github/scripts/install-ubuntu-apt-packages.sh @@ -18,18 +18,8 @@ for host in archive.ubuntu.com ports.ubuntu.com mirrors.mit.edu; do timeout 5 getent ahosts "$host" || true done -# Change repository locations while retaining suites, architectures and signing keys. -for source in /etc/apt/apt-mirrors.txt /etc/apt/sources.list /etc/apt/sources.list.d/*.list /etc/apt/sources.list.d/*.sources; do - if [ -f "$source" ]; then - sudo sed -i -E \ - -e 's#https?://(azure\.archive|archive|security)\.ubuntu\.com/ubuntu#https://mirrors.mit.edu/ubuntu#g' \ - -e 's#https?://ports\.ubuntu\.com/ubuntu-ports#https://mirrors.mit.edu/ubuntu-ports#g' \ - "$source" - fi -done - -# A timed-out install may leave a transaction that apt cannot resume itself. -timeout 30 sudo dpkg --configure -a || true +bash "$(dirname "${BASH_SOURCE[0]}")/use-ubuntu-apt-mirror.sh" +bash "$(dirname "${BASH_SOURCE[0]}")/recover-ubuntu-dpkg.sh" || true # Unrelated repositories may fail refresh; apt still verifies the requested packages. if ! timeout 120 sudo apt-get update -o Acquire::Languages=none; then echo 'Index refresh incomplete; attempting the requested packages with available authenticated indexes.' >&2 diff --git a/.github/scripts/recover-ubuntu-dpkg.sh b/.github/scripts/recover-ubuntu-dpkg.sh new file mode 100644 index 00000000000..3e693de2554 --- /dev/null +++ b/.github/scripts/recover-ubuntu-dpkg.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash +set -euo pipefail + +# A timed-out apt frontend can leave dpkg running in a separate session. +timeout 30 sudo bash -euo pipefail -c ' + while lslocks --noheadings --raw --notruncate --output PATH | grep -E "^/var/lib/dpkg/lock(-frontend)?$" >/dev/null; do + sleep 1 + done + dpkg --configure -a +' diff --git a/.github/scripts/use-ubuntu-apt-mirror.sh b/.github/scripts/use-ubuntu-apt-mirror.sh new file mode 100644 index 00000000000..b3617d59e67 --- /dev/null +++ b/.github/scripts/use-ubuntu-apt-mirror.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash +set -euo pipefail + +# Change repository locations while retaining suites, architectures and signing keys. +for source in /etc/apt/apt-mirrors.txt /etc/apt/sources.list /etc/apt/sources.list.d/*.list /etc/apt/sources.list.d/*.sources; do + if [ -f "$source" ]; then + sudo sed -i -E \ + -e 's#https?://(azure\.archive|archive|security)\.ubuntu\.com/ubuntu#https://mirrors.mit.edu/ubuntu#g' \ + -e 's#https?://ports\.ubuntu\.com/ubuntu-ports#https://mirrors.mit.edu/ubuntu-ports#g' \ + "$source" + fi +done diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index d123500b251..6cf4c1669e0 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -928,7 +928,18 @@ jobs: background: true run: | bash .github/scripts/prepare-ubuntu-apt.sh - pnpm exec playwright-core install --with-deps webkit + if [ ! -f .github/scripts/use-ubuntu-apt-mirror.sh ]; then + pnpm exec playwright-core install --with-deps webkit + exit 0 + fi + echo 'Installing WebKit and its dependencies through the primary route.' + if timeout --kill-after=10s 240 pnpm exec playwright-core install --with-deps webkit; then + exit 0 + fi + echo 'WebKit installation did not complete; retrying with the Ubuntu mirror fallback.' + bash .github/scripts/use-ubuntu-apt-mirror.sh + bash .github/scripts/recover-ubuntu-dpkg.sh || true + timeout --kill-after=10s 360 pnpm exec playwright-core install --with-deps webkit # The entry lives in mobile/ so one React resolves; without this every RN import is nothing. - uses: ./.github/actions/install-mobile-dependencies