Caching browser binaries
See original GitHub issueGHA caching docs recommend caching the NPM / Yarn cache (~/.npm
/ yarn cache dir
), which does not have browser binaries. This means that the binaries are downloaded on every CI execution, which can be optimized. With the @actions/tool-cache package, this Action can potentially implement caching for binaries.
What this could look like:
- Define the
PLAYWRIGHT_BROWSERS_PATH
environment variable to specify a fixed location for the binaries to be downloaded - Cache this location with
tc.cacheDir(dir, 'playwright-browsers', playwrightVersion)
(docs) - Restore at the same location with
tc.find
(docs) - This would require defining
runs.post
in the action.yml, like the actions/cache does it here. However, this bit is not documented in the metadata syntax reference for GHA ~(is it for some whitelisted actions only?)~- Verified with #11 that
runs.post
will work
- Verified with #11 that
Alternatively, we could achieve caching in user-land by reusing the cache
action (this could be an MVP implementation):
- Set the
PLAYWRIGHT_BROWSERS_PATH
to a certain path, and use the same path with thecache
action - Use the cache action in the workflow (this will end up being duplicated, since users will have a caching action for npm/yarn already)
- name: Cache browsers
id: cache-browsers
uses: actions/cache@v1
with:
path: <same as PLAYWRIGHT_BROWSERS_PATH>
key: key: ${{ runner.os }}-${{ hashFiles('package.json') }}
Issue Analytics
- State:
- Created 3 years ago
- Reactions:8
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Is there a way for GitHub Action to Cache the Playwright ...
Playwright downloads Chromium, WebKit and Firefox browsers into the OS-specific cache folders: %USERPROFILE%\AppData\Local\ms-playwright on ...
Read more >Caching playwright browser binaries in bitbucket pipelines
Solution with caching browsers within default location leads to this (in all 4 cases mentioned in comment of the file):. While not caching...
Read more >Binary Caching | Microsoft Learn
Binary caching is a vcpkg feature that saves copies of library binaries in a shared location that can be accessed by vcpkg for...
Read more >How To Use Blob Objects in Browser to Cache | by Zachary Lee
Caching can greatly improve application performance Blob objects in browsers are file-like objects of immutable, raw data; they can be read as text...
Read more >Caching binary content coming from databases
Normally when dealing with web applications and static content, you can rely on the browser to do caching even when you haven't done ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
For caching binaries on GitHub Actions, see https://github.com/microsoft/playwright/issues/7249#issuecomment-1154603556
(Sorry for the zombie post; this issue comes in as the top result when searching for
Playwright cache binaries
, and I wanted to point weary travellers [such as my future self] in the right direction)Currently its not planned to cache browser’s. It’s different on each language binding and depends on the version.
If you still want caching, you can do it manually with https://github.com/actions/cache A Cache key: playwright version (or whole file e.g. package.json, requirements.txt etc.) Cache folder: https://playwright.dev/docs/browsers#managing-browser-binaries
As written above, this can be also leveraged using the
PLAYWRIGHT_BROWSERS_PATH
environment variable.