Added Node version to cache key
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.
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.