actions / cache

Cache dependencies and build outputs in GitHub Actions
MIT License
4.45k stars 1.18k forks source link

Wrong Cache restore operation #1433

Open P1119r1m opened 1 month ago

P1119r1m commented 1 month ago

When trying to restore the "cache-toolchains-atf-d64" the Cache action actually restores "cache-toolchains-atf-d64x" (with 'x' at the end):

Run actions/cache/restore@v3 with: path: /work/atf_toolchains key: cache-toolchains-atf-d64 enableCrossOsArchive: false fail-on-cache-miss: false lookup-only: false ... Cache restored successfully Cache restored from key: cache-toolchains-atf-d64x

joshmgross commented 1 month ago

Cache keys are prefix-matched, so if your restore key is cache-toolchains-atf-d64 then both cache-toolchains-atf-d64 and cache-toolchains-atf-d64x would be a valid cache to restore.

restore-keys - An ordered list of prefix-matched keys to use for restoring stale cache if no cache hit occurred for key.

P1119r1m commented 1 month ago

Cache keys are prefix-matched, so if your restore key is cache-toolchains-atf-d64 then both cache-toolchains-atf-d64 and cache-toolchains-atf-d64x would be a valid cache to restore.

restore-keys - An ordered list of prefix-matched keys to use for restoring stale cache if no cache hit occurred for key.

Thank you for clarifying.

UPD. Please note that the original issue was related to the key input, not the restore-keys.

Could you please update the documentation to include information about the key as well, since it currently only details the "prefix-match" behavior for restore-keys?

The current documentation contains following infomation:

Inputs

  • key - An explicit key for a cache entry. See creating a cache key.
  • ...
  • restore-keys - An ordered list of prefix-matched keys to use for restoring stale cache if no cache hit occurred for key.

It would be helpful to provide additional details on how the key itself functions in relation to cache hits and misses.

joshmgross commented 1 month ago

👋 I've checked the internal service implementation and it appears that our documentation is incorrect. key uses prefix-matching similar to how restore-keys works.