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.

Use restore-key to find cache, when exact match is not available

See original GitHub issue

Description: Similar to #410 and #441, but these are closed without any result. Cache is correctly stored in the Post Setup Node, but not hit in the next run.

Run actions/setup-node@v3
  with:
    node-version: 16
    cache: yarn
    always-auth: false
    check-latest: false
    token: ***
Found in cache @ /opt/hostedtoolcache/node/16.18.0/x64
Environment details
  node: v16.18.0
  yarn: 1.22.19
  npm: 8.19.2
  
/usr/local/bin/yarn --version
1.22.19
/usr/local/bin/yarn cache dir
/home/runner/.cache/yarn/v6
yarn cache is not found

I think this is a combined bug report and feature request. As I checked the code in this action and it just checks cache with one primary key. Maybe additional restore-keys can be provided. This is available in the JS API.

Maybe node-cache-${platform}-${packageManager}- is a good restore-key, which would solve the missing hit with an updated lockfile. This would match the example from the actions/cache docs

Action version: v3

Platform:

  • Ubuntu
  • macOS
  • Windows

Runner type:

  • Hosted
  • Self-hosted

Tools version: node 14 & 16, yarn

Repro steps:
public repo: https://github.com/nklayman/vue-cli-plugin-electron-builder

Expected behavior: When lockfile is updated, it should hit the most recent cache in that branch scope.

Actual behavior: When lockfile is updated, it doesn’t hit any cache. Updated lockfile, no cache hit: https://github.com/nklayman/vue-cli-plugin-electron-builder/actions/runs/3481884289 Same lockfile, cache hit: https://github.com/nklayman/vue-cli-plugin-electron-builder/actions/runs/3487432460

Issue Analytics

  • State:closed
  • Created 10 months ago
  • Reactions:2
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
dmitry-shibanovcommented, Nov 17, 2022

Hello @MatthijsBurgh. Could you please rename the issue because it is not a bug but a feature request.

0reactions
MatthijsBurghcommented, Dec 20, 2022

@dsame I still have the PR open. I will probably work on it during the Christmas break.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Restore Poetry cache when there's no exact match #483
With Poetry, you will only get a cache hit if the poetry.lock hasn't changed. This means that dependency installation will take longer ...
Read more >
Pipeline caching - Azure - Microsoft Learn
If no cache is found, the step completes and the next step in the job ... find an exact match but wants to...
Read more >
Cache.match() - Web APIs - MDN Web Docs
The match() method of the Cache interface returns a Promise that resolves to the Response associated with the first matching request in the ......
Read more >
Do Not Let NPM Cache Snowball on CI - Gleb Bahmutov
The restore-keys are fallbacks. If the cache with the exact key is not found, the actions/cache tries to find a cache where the...
Read more >
Azure Pipelines Cache Task and ng is not recognized
ENABLE_CACHE, '0') # if we didn't get an match for node_modules, see if we have a recent copy of the .npm cache folder...
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