11name : ' Install Playwright dependencies'
2- description : ' Installs Playwright browsers and system dependencies, keeping both on the Namespace cache volume .'
2+ description : ' Installs Playwright dependencies and caches them .'
33inputs :
44 browsers :
55 description : ' What browsers to install.'
@@ -26,28 +26,43 @@ runs:
2626 shell : bash
2727 working-directory : ${{ inputs.cwd }}
2828
29- - name : Mount Playwright cache
30- uses : namespacelabs/nscloud-cache-action@1124a6f3ce44e5cf84cc22111530961f4d2a15f9 # v1.7.0
29+ - name : Restore cached playwright binaries
30+ uses : actions/cache/restore@v6.1.0
31+ id : playwright-cache
3132 if : steps.playwright-version.outputs.version != ''
3233 with :
33- cache : |
34- playwright
35- apt
34+ path : |
35+ ~/.cache/ms-playwright
36+ # Bump the iteration when bumping runner images to use a new cache
37+ key : playwright-${{ runner.os }}-iteration-1-${{ steps.playwright-version.outputs.version }}
3638
37- # `--with-deps` names packages that the runner image already has (glib, mesa, nss, ...), and `apt-get install` would
38- # upgrade them to the latest Ubuntu update. That is half of the download on a cold cache, and the image versions work.
39- - name : Keep installed apt packages
40- if : steps.playwright-version.outputs.version != ''
41- run : echo 'APT::Get::Upgrade "false";' | sudo tee /etc/apt/apt.conf.d/99-no-upgrade > /dev/null
39+ # We always install all browsers, if uncached
40+ # `npx` runs outside the repo, so it can't pick up a `playwright` that a parallel `pnpm install` is still linking.
41+ - name : Install Playwright dependencies (uncached)
42+ env :
43+ PLAYWRIGHT_VERSION : ${{ steps.playwright-version.outputs.version }}
44+ run : npx -y "playwright@$PLAYWRIGHT_VERSION" install chromium webkit firefox --with-deps
45+ if : steps.playwright-version.outputs.version != '' && steps.playwright-cache.outputs.cache-hit != 'true'
4246 shell : bash
47+ working-directory : ${{ runner.temp }}
4348
44- # Downloads only the browsers and apt packages that are not on the cache volume yet. `npx` runs outside the repo,
45- # so it can't pick up a `playwright` that a parallel `pnpm install` is still linking.
46- - name : Install Playwright
47- if : steps.playwright-version.outputs.version != ''
49+ - name : Install Playwright system dependencies only (cached)
4850 env :
4951 PLAYWRIGHT_BROWSERS : ${{ inputs.browsers || 'chromium webkit firefox' }}
5052 PLAYWRIGHT_VERSION : ${{ steps.playwright-version.outputs.version }}
51- run : npx -y "playwright@$PLAYWRIGHT_VERSION" install --with-deps $PLAYWRIGHT_BROWSERS
53+ run : npx -y "playwright@$PLAYWRIGHT_VERSION" install-deps $PLAYWRIGHT_BROWSERS
54+ if : steps.playwright-version.outputs.version != '' && steps.playwright-cache.outputs.cache-hit == 'true'
5255 shell : bash
5356 working-directory : ${{ runner.temp }}
57+
58+ # Only store cache on develop branch
59+ - name : Store cached playwright binaries
60+ uses : actions/cache/save@v6.1.0
61+ if :
62+ steps.playwright-version.outputs.version != '' && github.event_name == 'push' && github.ref ==
63+ ' refs/heads/develop'
64+ with :
65+ path : |
66+ ~/.cache/ms-playwright
67+ # Bump the iteration when bumping runner images to use a new cache
68+ key : playwright-${{ runner.os }}-iteration-1-${{ steps.playwright-version.outputs.version }}
0 commit comments