Skip to content

Commit 680509d

Browse files
committed
fix(ci): time the browser install itself and let an updated package set save under a new key
1 parent dc7db70 commit 680509d

3 files changed

Lines changed: 29 additions & 9 deletions

File tree

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ realtime_pid=''
3333
realtime_tag=''
3434
realtime_log=''
3535
browsers_pid=''
36-
browsers_started=0
3736
local_app_url=''
3837
extra_pids=()
3938
extra_tags=()
@@ -86,7 +85,6 @@ start_browser_install() {
8685
local name=$1
8786
shift
8887
browsers_log="$report_dir/$name-playwright-install.log"
89-
browsers_started=$SECONDS
9088
setsid --wait bash "$GITHUB_WORKSPACE/.github/scripts/install-playwright.sh" "$@" > "$browsers_log" 2>&1 &
9189
browsers_pid=$!
9290
}
@@ -99,8 +97,7 @@ wait_for_browsers() {
9997
exit 1
10098
fi
10199
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
100+
grep -E '^(Installed system dependencies|Stored [0-9]+ packages|Browser install took)' "$browsers_log" || true
104101
}
105102

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

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,12 @@
44
# PLAYWRIGHT_APT_CACHE names a directory of .deb files kept between runs (the workflow restores it
55
# per runner image and browser set). With it, missing system libraries install from those files
66
# 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.
7+
# A cold or incomplete cache falls back to `install-deps`, then stores what apt downloaded and
8+
# writes `$cache/.updated`, which tells the workflow to save the cache under a new key.
89
set -euo pipefail
910

11+
started=$SECONDS
12+
1013
browsers=()
1114
for argument in "$@"; do
1215
case "$argument" in
@@ -22,17 +25,19 @@ deps_present() {
2225
cache=${PLAYWRIGHT_APT_CACHE:-}
2326
if ! deps_present; then
2427
if [ -n "$cache" ] && compgen -G "$cache/*.deb" > /dev/null &&
25-
sudo apt-get install -y --no-install-recommends "$cache"/*.deb && deps_present; then
28+
sudo apt-get install -y --no-install-recommends --no-download "$cache"/*.deb && deps_present; then
2629
echo "Installed system dependencies from $cache"
2730
else
2831
bunx --no-install playwright install-deps "${browsers[@]}"
2932
if [ -n "$cache" ] && compgen -G '/var/cache/apt/archives/*.deb' > /dev/null; then
3033
mkdir -p "$cache"
3134
cp /var/cache/apt/archives/*.deb "$cache"/
35+
touch "$cache/.updated"
3236
echo "Stored $(find "$cache" -name '*.deb' | wc -l) packages in $cache"
3337
elif [ -n "$cache" ]; then
3438
echo "::warning::apt kept no downloaded packages; nothing to cache for the next run."
3539
fi
3640
fi
3741
fi
38-
exec bunx --no-install playwright install "$@"
42+
bunx --no-install playwright install "$@"
43+
echo "Browser install took $((SECONDS - started))s"

‎.github/workflows/checks.yml‎

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,11 +271,14 @@ jobs:
271271
id: runner-image
272272
run: echo "version=$ImageOS-$ImageVersion" >> "$GITHUB_OUTPUT"
273273

274+
# Restores the newest saved set by prefix. A cache key is never overwritten, so a run that had
275+
# to add packages saves a new one below.
274276
- name: Restore browser system packages
275-
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v5
277+
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v5
276278
with:
277279
path: ~/.cache/playwright-apt
278-
key: playwright-apt-${{ steps.runner-image.outputs.version }}-${{ hashFiles('bun.lock') }}-${{ matrix.group }}
280+
key: playwright-apt-${{ steps.runner-image.outputs.version }}-${{ hashFiles('bun.lock') }}-${{ matrix.group }}-${{ github.run_id }}-${{ github.run_attempt }}
281+
restore-keys: playwright-apt-${{ steps.runner-image.outputs.version }}-${{ hashFiles('bun.lock') }}-${{ matrix.group }}-
279282

280283
# Migrations create their own extensions, as on a fresh self-hosted install.
281284
- name: Provision the database through migrations
@@ -331,6 +334,21 @@ jobs:
331334
working-directory: apps/sim
332335
run: PLAYWRIGHT_APT_CACHE="$HOME/.cache/playwright-apt" bash ../../.github/scripts/http-e2e.sh "${{ matrix.group }}"
333336

337+
- name: Check for new browser system packages
338+
id: apt-cache
339+
run: |
340+
if [ -f "$HOME/.cache/playwright-apt/.updated" ]; then
341+
rm "$HOME/.cache/playwright-apt/.updated"
342+
echo 'updated=true' >> "$GITHUB_OUTPUT"
343+
fi
344+
345+
- name: Save browser system packages
346+
if: steps.apt-cache.outputs.updated == 'true'
347+
uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v5
348+
with:
349+
path: ~/.cache/playwright-apt
350+
key: playwright-apt-${{ steps.runner-image.outputs.version }}-${{ hashFiles('bun.lock') }}-${{ matrix.group }}-${{ github.run_id }}-${{ github.run_attempt }}
351+
334352
- name: Upload acceptance timing and coverage reports
335353
if: always()
336354
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2

0 commit comments

Comments
 (0)