Skip to content

Commit dc7db70

Browse files
committed
improvement(ci): install e2e browser system packages from a per-image cache
1 parent 9743e49 commit dc7db70

3 files changed

Lines changed: 41 additions & 3 deletions

File tree

‎.github/scripts/http-e2e.sh‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ realtime_pid=''
3333
realtime_tag=''
3434
realtime_log=''
3535
browsers_pid=''
36+
browsers_started=0
3637
local_app_url=''
3738
extra_pids=()
3839
extra_tags=()
@@ -85,6 +86,7 @@ start_browser_install() {
8586
local name=$1
8687
shift
8788
browsers_log="$report_dir/$name-playwright-install.log"
89+
browsers_started=$SECONDS
8890
setsid --wait bash "$GITHUB_WORKSPACE/.github/scripts/install-playwright.sh" "$@" > "$browsers_log" 2>&1 &
8991
browsers_pid=$!
9092
}
@@ -97,6 +99,8 @@ wait_for_browsers() {
9799
exit 1
98100
fi
99101
browsers_pid=''
102+
echo "Browsers installed $((SECONDS - browsers_started))s after the install started"
103+
grep -E '^(Installed system dependencies|Stored [0-9]+ packages)' "$browsers_log" || true
100104
}
101105

102106
# start_app <name> <port> <label> [record-http-status]

‎.github/scripts/install-playwright.sh‎

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
#!/usr/bin/env bash
22
# The dependency dry run uses the pinned driver's package list without updating apt.
3+
#
4+
# PLAYWRIGHT_APT_CACHE names a directory of .deb files kept between runs (the workflow restores it
5+
# per runner image and browser set). With it, missing system libraries install from those files
6+
# without reaching an Ubuntu mirror, whose stalls have held a suite in this step for 16 minutes.
7+
# A cold or incomplete cache falls back to `install-deps`, then stores what apt downloaded.
38
set -euo pipefail
49

510
browsers=()
@@ -10,7 +15,24 @@ for argument in "$@"; do
1015
esac
1116
done
1217

13-
if ! bunx --no-install playwright install-deps --dry-run "${browsers[@]}"; then
14-
bunx --no-install playwright install-deps "${browsers[@]}"
18+
deps_present() {
19+
bunx --no-install playwright install-deps --dry-run "${browsers[@]}" > /dev/null 2>&1
20+
}
21+
22+
cache=${PLAYWRIGHT_APT_CACHE:-}
23+
if ! deps_present; then
24+
if [ -n "$cache" ] && compgen -G "$cache/*.deb" > /dev/null &&
25+
sudo apt-get install -y --no-install-recommends "$cache"/*.deb && deps_present; then
26+
echo "Installed system dependencies from $cache"
27+
else
28+
bunx --no-install playwright install-deps "${browsers[@]}"
29+
if [ -n "$cache" ] && compgen -G '/var/cache/apt/archives/*.deb' > /dev/null; then
30+
mkdir -p "$cache"
31+
cp /var/cache/apt/archives/*.deb "$cache"/
32+
echo "Stored $(find "$cache" -name '*.deb' | wc -l) packages in $cache"
33+
elif [ -n "$cache" ]; then
34+
echo "::warning::apt kept no downloaded packages; nothing to cache for the next run."
35+
fi
36+
fi
1537
fi
1638
exec bunx --no-install playwright install "$@"

‎.github/workflows/checks.yml‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,18 @@ jobs:
265265
with:
266266
provider: github
267267

268+
# Browser system libraries, as downloaded .deb files, per runner image and group (each group
269+
# installs its own browsers); install-playwright.sh reads and fills it.
270+
- name: Read the runner image
271+
id: runner-image
272+
run: echo "version=$ImageOS-$ImageVersion" >> "$GITHUB_OUTPUT"
273+
274+
- name: Restore browser system packages
275+
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v5
276+
with:
277+
path: ~/.cache/playwright-apt
278+
key: playwright-apt-${{ steps.runner-image.outputs.version }}-${{ hashFiles('bun.lock') }}-${{ matrix.group }}
279+
268280
# Migrations create their own extensions, as on a fresh self-hosted install.
269281
- name: Provision the database through migrations
270282
if: matrix.group != 'project-files'
@@ -317,7 +329,7 @@ jobs:
317329
- name: Run end-to-end suites
318330
timeout-minutes: 19
319331
working-directory: apps/sim
320-
run: bash ../../.github/scripts/http-e2e.sh "${{ matrix.group }}"
332+
run: PLAYWRIGHT_APT_CACHE="$HOME/.cache/playwright-apt" bash ../../.github/scripts/http-e2e.sh "${{ matrix.group }}"
321333

322334
- name: Upload acceptance timing and coverage reports
323335
if: always()

0 commit comments

Comments
 (0)