actions / actions/setup-node

Add fallback cache keys

Open
#1,120 2 comments 6 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature request
Dominant language
TypeScript
Stars
5k
Forks
1.7k
Avg merge
3d 12h
Merged PRs (30d)
2

Description

Description:

Currently the cache key is always node-cache-{platform}-{packageManager}-{fileHash(lockfile)}, which means the cache is invalid if any one dependency changed. I want to achieve something like this restore-keys:

restore-keys: |
  npm-feature-${{ hashFiles('package-lock.json') }}
  npm-feature-
  npm-

Justification:

It would be very helpful if the same cache can be reused across many places even if their package.json has changed.

Are you willing to submit a PR?

I noticed that Yarn berry already has some logic about this, can we expand that use cases to all package managers?

Contributor guide

No contributing guide indexed for this repository

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 in src/cache-restore.ts around line 56, where the existing Yarn Berry cache logic is referenced. Examine how fallback restore keys could be expanded to all package managers; done means setup-node can reuse caches through fallback keys when a lockfile or package.json has changed.

Written by the indexing model from the issue text.

Assessment

Tech stack
github-actions, node.js, typescript
Domain
ci-cd
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.