actions / actions/cache

Partial match even when only using `key`

Open
#1,145 5 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

documentation
Dominant language
TypeScript
Stars
5.6k
Forks
1.6k
PR merge metrics
No merged PRs in 30d

Description

I've been using something as simple as:

      - name: Restore Rust
        id: restore
        uses: actions/cache/restore@v3
        with:
          path: ~/.rustup
          key: rust

But for some reason, if the cache doesn't exist, it actually matches on a different key, in this case I've named another cache rustfmt:

2023-04-03T15:07:35.2300547Z ##[group]Run actions/cache/restore@v3
2023-04-03T15:07:35.2300888Z with:
2023-04-03T15:07:35.2301091Z   path: ~/.rustup
2023-04-03T15:07:35.2301275Z   key: rust
2023-04-03T15:07:35.2301523Z   enableCrossOsArchive: false
2023-04-03T15:07:35.2301775Z   fail-on-cache-miss: false
2023-04-03T15:07:35.2301993Z   lookup-only: false
2023-04-03T15:07:35.2302195Z env:
2023-04-03T15:07:35.2302425Z   CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
2023-04-03T15:07:35.2302664Z   CARGO_TERM_COLOR: always
2023-04-03T15:07:35.2302882Z ##[endgroup]
2023-04-03T15:07:36.9535578Z Received 0 of 175967939 (0.0%), 0.0 MBs/sec
2023-04-03T15:07:37.9543626Z Received 88080384 of 175967939 (50.1%), 41.9 MBs/sec
2023-04-03T15:07:38.9676366Z Received 175967939 of 175967939 (100.0%), 55.6 MBs/sec
2023-04-03T15:07:38.9683911Z Cache Size: ~168 MB (175967939 B)
2023-04-03T15:07:38.9973074Z [command]/usr/bin/tar -xf /home/runner/work/_temp/a4330e53-f698-4883-9b37-40e2223e5e9c/cache.tzst -P -C /home/runner/work/despair/despair --use-compress-program unzstd
2023-04-03T15:07:40.1776290Z Cache restored successfully
2023-04-03T15:07:40.5518473Z Cache restored from key: rustfmt

It seems to me that the documentation is pretty clear that key is used for exact matches and restore-keys for partial matches. Furthermore steps.restore.outputs.cache-hit is actually set to true.

Is this a bug, or did I misunderstand the documentation?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the actions/cache/restore@v3 entry point and reproduce the YAML with key: rust alongside an existing rustfmt cache. Check key matching and the cache-hit output against the documented contract. Done means the behavior is explained and the implementation, documentation, or tests are identified as needing correction.

Written by the indexing model from the issue text.

Assessment

Tech stack
github-actions, typescript
Domain
ci-cd
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.