fix(ci): use npm-shrinkwrap.json for node_modules cache key#1325
Conversation
hashFiles('package-lock.json') returns empty string since only
npm-shrinkwrap.json is tracked, causing all runs to share a single
stale cache key. This led to lint and typecheck failures when the
stale node_modules had outdated type definitions.
Package TarballHow to installgh release download pr-1325-tarball --repo aws/agentcore-cli --pattern "*.tgz" --dir /tmp/pr-tarball
npm install -g /tmp/pr-tarball/aws-agentcore-0.14.1.tgz |
|
Claude Security Review: no high-confidence findings. (run) |
agentcore-cli-automation
left a comment
There was a problem hiding this comment.
Verified the analysis: npm-shrinkwrap.json is the only lockfile tracked in the repo (package-lock.json is not committed), so hashFiles('package-lock.json') returns an empty string and the cache key collapses to a constant node-modules- across all runs — matching the symptoms described.
The fix replaces all 6 occurrences in .github/workflows/lint.yml consistently. Other references to package-lock.json in sync-preview.yml and pr-size.yml are intentional (sync-preview generates one from upstream; pr-size filters it from diff size) and correctly left alone.
Note: existing caches keyed as node-modules- will linger until they expire (7 days idle) or are manually evicted, but that's harmless — the new key simply won't match them and the setup job will populate the correct cache on first run after merge.
LGTM.
Description
The
Quality and Safety Checksworkflow cachesnode_modulesusinghashFiles('package-lock.json')as the key, butpackage-lock.jsonis no longer tracked since it was replaced bynpm-shrinkwrap.json. This causeshashFilesto return an empty string, so the cache key is alwaysnode-modules-(constant across all runs).This means:
setupjob's cache save races with itself and often fails ("another job may be creating this cache")node_modulesfrom a previous run with older SDK type definitionsThe fix changes all
hashFiles('package-lock.json')references tohashFiles('npm-shrinkwrap.json').Related Issue
Closes #
Documentation PR
N/A
Type of Change
Testing
npm run test:unitandnpm run test:integnpm run typechecknpm run lintsrc/assets/, I rannpm run test:update-snapshotsand committed the updated snapshotsChecklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the
terms of your choice.