diff --git a/.github/scripts/install-ubuntu-apt-packages.sh b/.github/scripts/install-ubuntu-apt-packages.sh new file mode 100644 index 00000000000..b5790f3f90d --- /dev/null +++ b/.github/scripts/install-ubuntu-apt-packages.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash +set -euo pipefail + +if [ "$#" -eq 0 ]; then + echo 'Usage: install-ubuntu-apt-packages.sh ...' >&2 + exit 2 +fi + +bash "$(dirname "${BASH_SOURCE[0]}")/prepare-ubuntu-apt.sh" + +# Bound both routes while allowing large fallback downloads. +# Run deadlines as root so sudo cannot leave apt in a separate session. +if sudo timeout --kill-after=10s 45 apt-get update -o Acquire::Languages=none && sudo timeout --kill-after=10s 120 apt-get install -y "$@"; then + exit 0 +fi + +echo 'Ubuntu package setup failed; trying the same packages through the MIT mirror.' >&2 +for host in archive.ubuntu.com ports.ubuntu.com mirrors.mit.edu; do + timeout 5 getent ahosts "$host" || true +done + +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 ! sudo timeout --kill-after=10s 120 apt-get update -o Acquire::Languages=none; then + echo 'Index refresh incomplete; attempting the requested packages with available authenticated indexes.' >&2 +fi +sudo timeout --kill-after=10s 600 apt-get install -y "$@" diff --git a/.github/scripts/recover-ubuntu-dpkg.sh b/.github/scripts/recover-ubuntu-dpkg.sh new file mode 100644 index 00000000000..e57a094aa76 --- /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. +sudo timeout --kill-after=10s 30 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/e2e.yml b/.github/workflows/e2e.yml index 9339215a217..ca0f42a63c9 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -123,6 +123,10 @@ jobs: exit 0 fi read -r -a packages <<< "$ORCA_E2E_APT_PACKAGES" + if [ -f .github/scripts/install-ubuntu-apt-packages.sh ]; then + bash .github/scripts/install-ubuntu-apt-packages.sh "${packages[@]}" + exit 0 + fi if [ -f .github/scripts/prepare-ubuntu-apt.sh ]; then bash .github/scripts/prepare-ubuntu-apt.sh else @@ -529,7 +533,12 @@ jobs: ref: ${{ inputs.ref || github.ref }} persist-credentials: false - name: Install headless tools - run: sudo apt-get update && sudo apt-get install -y build-essential ripgrep xvfb openbox x11-utils + run: &install_headless_tools | + if [ -f .github/scripts/install-ubuntu-apt-packages.sh ]; then + bash .github/scripts/install-ubuntu-apt-packages.sh build-essential ripgrep xvfb openbox x11-utils + else + sudo apt-get update && sudo apt-get install -y build-essential ripgrep xvfb openbox x11-utils + fi - uses: ./.github/actions/install-node-dependencies with: native-runtime: electron @@ -636,7 +645,7 @@ jobs: - name: Fetch the 1.4.224 relay sources run: git fetch --no-tags --depth=1 origin +refs/tags/v1.4.224:refs/tags/v1.4.224 - name: Install headless tools - run: sudo apt-get update && sudo apt-get install -y build-essential ripgrep xvfb openbox x11-utils + run: *install_headless_tools - uses: ./.github/actions/install-node-dependencies with: native-runtime: electron diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index bd71e39e97a..ef97a54bf90 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -790,15 +790,7 @@ jobs: id: shells background: true run: | - # Per-connection limits complement the whole-command apt deadlines below. - sudo tee /etc/apt/apt.conf.d/99-orca-shell-contracts >/dev/null <<'APTCONF' - Acquire::http::Timeout "15"; - Acquire::https::Timeout "15"; - Acquire::Retries "1"; - APTCONF - # Unrelated runner repositories may fail refresh; installing zsh must still succeed. - timeout 120 sudo apt-get update || true - timeout 300 sudo apt-get install -y zsh + bash .github/scripts/install-ubuntu-apt-packages.sh zsh # A fixed 4.x release meets the contract without tracking package-repository updates. case "$(uname -m)" in aarch64) arch=aarch64 sha=57349f0111728c64b703a84e611aa97ff4d1fa8466385d64e67bd5bc3ffa49fc ;; @@ -936,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 dependencies through the primary route.' + if ! sudo env "PATH=$PATH" timeout --kill-after=10s 240 ./node_modules/.bin/playwright-core install-deps webkit; then + echo 'Dependency 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 + sudo env "PATH=$PATH" timeout --kill-after=10s 600 ./node_modules/.bin/playwright-core install-deps webkit + fi + timeout --kill-after=10s 180 pnpm exec playwright-core install webkit # The entry lives in mobile/ so one React resolves; without this every RN import is nothing. - uses: ./.github/actions/install-mobile-dependencies