Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

fix(ci): add apt retries for Playwright dependencies (#17328)

Tobias Wochingerae2b6dbd394a
diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml
index d9c2e51b30..5e34c1410a 100644
--- a/.github/workflows/pipeline.yml
+++ b/.github/workflows/pipeline.yml
@@ -505,23 +505,7 @@ jobs:
# same reason. `prisma generate` only reads the schema; it needs no DB.
run: pnpm --filter=shared run db:generate
- name: Install playwright
- # apt-get (pulled in by --with-deps) occasionally stalls against a
- # slow/unresponsive mirror and can ride the job's timeout-minutes
- # instead of failing fast (observed: a 10-minute hang cancelled by
- # the job timeout). A normal install takes well under a minute, so
- # bound each attempt and retry instead of trusting the job-level
- # timeout as the only guard.
- run: |
- attempt=1
- until timeout 120 pnpm --filter=web exec playwright install --with-deps --only-shell chromium; do
- if [ "$attempt" -ge 3 ]; then
- echo "Playwright install failed after 3 attempts" >&2
- exit 1
- fi
- echo "Attempt $attempt failed (possibly a stalled apt mirror), retrying in $((attempt * 15))s..." >&2
- sleep $((attempt * 15))
- attempt=$((attempt + 1))
- done
+ run: bash scripts/ci/install-playwright.sh
- name: run Storybook tests
run: pnpm --filter web run test-storybook
- name: build Storybook
@@ -1179,7 +1163,7 @@ jobs:
(set +e; docker compose -f docker-compose.dev.yml up -d --wait --wait-timeout 180 > /tmp/compose-up.log 2>&1; echo $? > /tmp/compose-up.exit) &
- name: Install playwright in background
run: |
- (set +e; pnpm --filter=web exec playwright install --with-deps --only-shell chromium > /tmp/playwright-install.log 2>&1; echo $? > /tmp/playwright-install.exit) &
+ (set +e; bash scripts/ci/install-playwright.sh > /tmp/playwright-install.log 2>&1; echo $? > /tmp/playwright-install.exit) &
- name: Build
run: pnpm run build --filter=!ai-gateway
env:
diff --git a/scripts/ci/install-playwright.sh b/scripts/ci/install-playwright.sh
new file mode 100755
index 0000000000..9dfb70b029
--- /dev/null
+++ b/scripts/ci/install-playwright.sh
@@ -0,0 +1,31 @@
+#!/usr/bin/env bash
+
+set -euo pipefail
+
+readonly APT_MIRRORS_FILE="${PLAYWRIGHT_APT_MIRRORS_FILE:-/etc/apt/blacksmith-ubuntu-mirrors.txt}"
+readonly APT_SOURCES_FILE="${PLAYWRIGHT_APT_SOURCES_FILE:-/etc/apt/sources.list.d/ubuntu.sources}"
+readonly APT_CONFIG_FILE="${PLAYWRIGHT_APT_CONFIG_FILE:-/etc/apt/apt.conf.d/80-playwright-network-retries}"
+readonly COMMUNITY_MIRRORS=(
+ "https://mirror.pilotfiber.com/ubuntu/"
+ "https://mirror.tzulo.com/ubuntu/"
+)
+
+sudo tee "${APT_CONFIG_FILE}" > /dev/null <<'EOF'
+Acquire::Retries "3";
+EOF
+
+if [[ -f "${APT_MIRRORS_FILE}" && -f "${APT_SOURCES_FILE}" ]]; then
+ # Prefer the independent mirrors while Canonical's endpoints are degraded.
+ for mirror in "${COMMUNITY_MIRRORS[@]}"; do
+ mirror_entry="${mirror}"$'\tpriority:0'
+ if ! grep -Fqx "${mirror_entry}" "${APT_MIRRORS_FILE}"; then
+ printf '%s\n' "${mirror_entry}" | sudo tee -a "${APT_MIRRORS_FILE}" > /dev/null
+ fi
+ done
+
+ sudo sed -i -E \
+ "s|https?://security\\.ubuntu\\.com/ubuntu/?|mirror+file:${APT_MIRRORS_FILE}|g" \
+ "${APT_SOURCES_FILE}"
+fi
+
+pnpm --filter=web exec playwright install --with-deps --only-shell chromium