Skip to content

Conversation

@breezewish
Copy link

Description

Hi, thanks for the cool action! This PR attempts to keep behavior of restoring keys by "prefix" instead of exact match (which is exactly the behavior of actions/cache). It could be useful in fallback scenarios.

Motivation and Context

For example:

- uses: actions/cache@v4
  with:
    path: |
      ~/.cache/go-build
      ~/go/pkg/mod
    key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
    restore-keys: |
      ${{ runner.os }}-go-

Suppose that our hash was updated from aaaaaa to bbbbbb, with cache of aaaaaa is available.

Previously actions/cache would first try to restore with keys Linux-go-bbbbbb and then fallback to latest cache with key Linux-go-<any>, which becomes a successful lookup of Linux-go-aaaaaa. So the cache is hit, and try to utilized as much as possible.

In gcs-cache, however, cache will be missed totally because there is no key Linux-go-bbbbbb and Linux-go-.

How Has This Been Tested?

I'm also wondering how this could be tested automatically! Could you give me some advice? Currently I'm testing it manually by applying it in my own workflow.

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
    Considered as a bug fix because it now follows the actions/cache behavior.
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation (add or update README or docs)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

Signed-off-by: Wish <breezewish@outlook.com>
@breezewish breezewish requested a review from danySam as a code owner May 27, 2025 03:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant