Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Node version to cache key #1172

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

clintonb
Copy link

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.
  • Mark if tests were added or updated to cover the changes.

@clintonb clintonb requested a review from a team as a code owner December 14, 2024 07:46
@textbook
Copy link

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:

describe('getNodeVersionFromFile', () => {
each`
contents | expected
${'12'} | ${'12'}
${'12.3'} | ${'12.3'}
${'12.3.4'} | ${'12.3.4'}
${'v12.3.4'} | ${'12.3.4'}
${'lts/erbium'} | ${'lts/erbium'}
${'lts/*'} | ${'lts/*'}
${'nodejs 12.3.4'} | ${'12.3.4'}
${'ruby 2.3.4\nnodejs 12.3.4\npython 3.4.5'} | ${'12.3.4'}
${''} | ${''}
${'unknown format'} | ${'unknown format'}
${' 14.1.0 '} | ${'14.1.0'}
${'{"volta": {"node": ">=14.0.0 <=17.0.0"}}'}| ${'>=14.0.0 <=17.0.0'}
${'{"volta": {"extends": "./package.json"}}'}| ${'18.0.0'}
${'{"engines": {"node": "17.0.0"}}'} | ${'17.0.0'}
${'{}'} | ${null}
`.it('parses "$contents"', ({contents, expected}) => {

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Include Node.js version in cache key
5 participants