setup-node icon indicating copy to clipboard operation
setup-node copied to clipboard

Added Node version to cache key

Open clintonb opened this issue 1 year ago • 1 comments

Description: The Node.js version is now included in the cache key to ensure caches are invalidated, and dependencies reinstalled, when changing Node.js versions.

Related issue: Fixes #1171

Check list:

  • [ ] Mark if documentation changes are required.
  • [x] Mark if tests were added or updated to cover the changes.

clintonb avatar Dec 14 '24 07:12 clintonb

Shouldn't this use the actual major Node version in the cache key? The linked issue says:

The major version number, (e.g., 22 in 22.12) should be used to avoid unnecessary invalidation when upgrading to patch or minor versions.

That makes sense to me. But the implementation here uses version, which is either core.getInput("node-version") (any supported version) or whatever was pulled from the node-version-file. This could be a major version, but equally could be a minor or patch version, a range, or something like latest or lts/*. For example any of the following could come from the file:

https://github.com/actions/setup-node/blob/48b90677b6048efbc723b11a94acb950d3f1ac36/tests/main.test.ts#L92-L110

I think this should be using the resolved Node version, i.e. what's used as outputs.node-version, and taking the major version from it.

textbook avatar Jan 12 '25 16:01 textbook