Skip to content

chore(ci): add composite setup-node action with npm cache#6177

Merged
macko911 merged 8 commits into
masterfrom
matej/nan-5527-create-composite-setup-node-action-with-npm-cache
Jun 3, 2026
Merged

chore(ci): add composite setup-node action with npm cache#6177
macko911 merged 8 commits into
masterfrom
matej/nan-5527-create-composite-setup-node-action-with-npm-cache

Conversation

@macko911

@macko911 macko911 commented May 19, 2026

Copy link
Copy Markdown
Contributor

Problem

npm caching was inconsistent across CI workflows — some used cache: 'npm', others didn't. New workflows could easily forget it. Also, master pushes from the merge-queue bot skip npm ci via the should-run check, so no npm cache was ever saved on refs/heads/master, meaning every feature branch paid a cold cache miss on first run.

This also lays the ground for enabling pnpm across the monorepo.

Solution

Add .github/actions/setup-node, a composite action wrapping actions/setup-node@v4 with cache: 'npm' always set. Migrate all workflows to use it.

Add cache-warmup.yaml that runs on every master push, doing just enough (checkout + setup-node + npm ci) to land an npm cache on refs/heads/master so feature branches can restore it.

Only cli-verification.yaml and managed-release.yaml genuinely gain new caching — the rest were already using cache: 'npm' and are just migrated to the composite action.

Fixes NAN-5527

Testing

  • CI green on this PR
  • After merge, Cache Warmup workflow runs on the master push and saves a cache entry on refs/heads/master
  • Next feature branch's first run shows a cache hit in the setup-node logs

@linear

linear Bot commented May 19, 2026

Copy link
Copy Markdown

NAN-5527

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 11 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Re-trigger cubic

Comment thread .github/workflows/cache-warmup.yaml Fixed
@macko911 macko911 force-pushed the matej/nan-5527-create-composite-setup-node-action-with-npm-cache branch from 7cb53e5 to 4f87990 Compare May 26, 2026 21:47
macko911 added 5 commits May 27, 2026 15:32
Adds .github/actions/setup-node wrapping actions/setup-node@v4 with
cache: 'npm' and cache-dependency-path: 'package-lock.json' always set,
and migrates every workflow that checks out the repo to use it. New
workflows can no longer forget npm caching.

In managed-release.yaml, reorder checkout before setup-node in both
jobs so the local composite is on disk and package-lock.json is
available for cache key computation.

The verify job in cli-verification.yaml keeps the raw setup-node@v4 -
it has no checkout step and only runs npm install -g, so the composite
would neither resolve nor benefit from caching.
Most workflow runs on direct pushes to master originate from the
merge-queue bot, which trips the existing should-run short-circuit
and skips npm ci. As a result, no node-cache ever lands on
refs/heads/master, and every feature branch pays a cold cache miss
on its first run.

This workflow runs unconditionally on push to master and does just
enough work to populate the npm cache (~30-60s), so feature branches
restore it on first run.
Add a check-lockfile input (default true) that runs
npm install --package-lock-only --ignore-scripts followed by
git diff --exit-code package-lock.json. Fails the job if
package-lock.json is out of sync with package.json.

Disabled for publish.yaml (pins npm to 11.5.1 after the composite
runs, so the check would execute with the wrong npm version) and for
managed-release.yaml (workspace-scoped install against master
commits, already validated at merge time).
@macko911 macko911 force-pushed the matej/nan-5527-create-composite-setup-node-action-with-npm-cache branch from 4f87990 to c9b9af5 Compare May 27, 2026 13:34
macko911 added 3 commits May 27, 2026 16:13
The check ran `npm install --package-lock-only` and diffed the result,
but different npm versions (10.9.x on CI vs 11.x locally) produce
slightly different lockfile output (e.g. `"peer": true` on optional
platform packages), causing false positives on every CI job.

The check is redundant anyway — all workflows run `npm ci` after
setup-node, which already fails on a genuine lockfile/package.json mismatch.
Upgrade npm to 11.12.1 in the setup-node action so CI and local
environments use the same version, eliminating lockfile format
divergence caused by npm metadata differences across versions.

Restore the lockfile consistency check and remove the now-redundant
npm upgrade step from publish.yaml.
@macko911 macko911 marked this pull request as ready for review May 28, 2026 09:22

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2f4733713c

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread .github/workflows/managed-release.yaml
@macko911 macko911 requested a review from rossmcewan June 2, 2026 06:29
@macko911 macko911 added this pull request to the merge queue Jun 3, 2026
Merged via the queue into master with commit 2dd4581 Jun 3, 2026
30 checks passed
@macko911 macko911 deleted the matej/nan-5527-create-composite-setup-node-action-with-npm-cache branch June 3, 2026 09:13
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.

3 participants