setup-chrome icon indicating copy to clipboard operation
setup-chrome copied to clipboard

Add persistent cache support using actions/cache

Open mridang opened this issue 2 months ago • 1 comments

Description

The setup-chrome action currently only uses the runner's local tool cache (/opt/hostedtoolcache/) which does not persist across different GitHub Actions runners. This means Chrome is re-downloaded on every workflow run, even when using the same version.

Unlike other setup actions (e.g., actions/setup-go, actions/setup-node), the Chrome installation is not visible in GitHub's cache dashboard and cannot be shared across workflow runs. This results in:

  • Slower workflow runs due to repeated downloads
  • Increased bandwidth usage
  • Inconsistent behavior compared to other GitHub setup actions

Users can currently work around this by manually adding an actions/cache step before setup-chrome, but this requires understanding the internal cache directory structure and adds boilerplate to every workflow.

Solution

Integrate @actions/cache directly into the action to enable persistent caching across workflow runs. This would:

  1. Add @actions/cache as a dependency
  2. Restore the cache from GitHub's cache storage before checking the local tool cache
  3. Save the cache after successful Chrome installation
  4. Make cached Chrome installations visible in the repository's cache dashboard

This could be implemented as an opt-in or opt-out feature via a new input parameter:

- uses: browser-actions/setup-chrome@v2
  with:
    chrome-version: 138
    cache: true  # Enable persistent caching (could default to true)

The cache key should include the OS, architecture, and Chrome version to ensure correct cache invalidation when any of these change.

mridang avatar Oct 15 '25 02:10 mridang

I'm happy to provide a pull-request if you have the bandwidth to review contributions. Thank you.

mridang avatar Oct 15 '25 02:10 mridang