Skip to content

ci: use npm ci with caching in all CI workflows#9150

Merged
ericpgreen2 merged 1 commit intomainfrom
ericgreen/ci-npm-hardening
Apr 1, 2026
Merged

ci: use npm ci with caching in all CI workflows#9150
ericpgreen2 merged 1 commit intomainfrom
ericgreen/ci-npm-hardening

Conversation

@ericpgreen2
Copy link
Copy Markdown
Contributor

@ericpgreen2 ericpgreen2 commented Mar 31, 2026

Following the axios supply chain attack (PR #9148 pinned the affected package), this hardens all CI workflows against future npm supply chain attacks.

  • Switch npm installnpm ci in all 6 workflows that install npm dependencies (including scripts/web-test-code-quality.sh)
  • Add cache: 'npm' to all actions/setup-node@v4 steps

Why npm ci: Installs exactly from package-lock.json, never resolves new versions from the registry, and fails if the lockfile is out of sync with package.json. Even if a malicious version is published within a dependency's semver range, CI will only install what's in the committed lockfile.

Why caching: actions/setup-node caches ~/.npm (npm's tarball cache) between runs, keyed by the lockfile hash. Packages are read from cache instead of re-downloaded from the registry. Typically cuts install time 50-70% on cache hits.

Checklist:

  • Covered by tests
  • Ran it and it works as intended
  • Reviewed the diff before requesting a review
  • Checked for unhandled edge cases
  • Linked the issues it closes
  • Checked if the docs need to be updated. If so, create a separate Linear DOCS issue
  • Intend to cherry-pick into the release branch
  • I'm proud of this work!

Developed in collaboration with Claude Code

Switch all GitHub Actions workflows from `npm install` to `npm ci` and
enable npm caching via `actions/setup-node`. This hardens CI against
supply chain attacks by ensuring only lockfile-pinned versions are
installed, and speeds up installs by caching downloaded tarballs.
@ericpgreen2 ericpgreen2 self-assigned this Mar 31, 2026
@ericpgreen2 ericpgreen2 requested a review from AdityaHegde March 31, 2026 12:42
@ericpgreen2 ericpgreen2 merged commit b86785a into main Apr 1, 2026
17 of 23 checks passed
@ericpgreen2 ericpgreen2 deleted the ericgreen/ci-npm-hardening branch April 1, 2026 12:05
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.

2 participants