question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Caching browser binaries

See original GitHub issue

GHA 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

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 the cache 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:closed
  • Created 3 years ago
  • Reactions:8
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
jesstelfordcommented, Jun 14, 2022

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)

0reactions
mxschmittcommented, Aug 20, 2021

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found