Skip to content

Add the node module: Node, npm/pnpm/Yarn, a frozen install and its cache - #54

Open
ndbroadbent wants to merge 3 commits into
mainfrom
modules/node
Open

ndbroadbent wants to merge 3 commits into
mainfrom
modules/node

Conversation

@ndbroadbent

@ndbroadbent ndbroadbent commented Dec 4, 2026 •

Copy link
Copy Markdown
Member

The node module (modules design, #10). It's based on main, not on narrow_inputs (#26).

What it does

modules: [node] (or - node: { path: web }) adds:

  • Node at the version the project pins. It looks for .nvmrc or .node-version in path, then at the root, then engines.node in the package's package.json, then version:. version: preinstalled uses the image's or runner's Node. On GitHub this is actions/setup-node, pinned to a commit. On CircleCI, Node comes from the job's image, which must be a node or cimg/node image matching the pinned version; a mismatch, or a range, is an error with a fix.
  • The package manager. It takes packageManager from package.json, else the one lockfile present (two lockfiles is an error that names both). pnpm uses pnpm/action-setup on GitHub; Yarn, and pnpm on CircleCI, go through Corepack. Corepack is installed first when the Node doesn't bundle it (Node 25+).
  • A frozen install: npm ci, pnpm install --frozen-lockfile, yarn install --immutable (Berry) or --frozen-lockfile (Classic), in path.
  • The download cache, keyed on the lockfile. On GitHub that's setup-node's cache with cache-dependency-path. On CircleCI it's restore_cache/save_cache keyed node-v1-{{ arch }}-<pm>-{{ checksum "<lockfile>" }}, with a fixed pnpm store.
  • Inputs, inside path: every package.json, the lockfiles, pnpm-workspace.yaml, .npmrc, Yarn's config, releases and patches, patches/, and the version file it found.

Mistakes fail when the config loads, each with a fix: no package.json, nothing pinning Node, two version files, a version file plus version:, pnpm or Yarn without a packageManager version, a missing lockfile, Bun (not supported yet).

src/modules/steps.rs holds step helpers that modules share. Modules get a Context (root and image) so they can check the image.

Tests

  • Unit tests (src/modules/node/tests.rs): pnpm, npm and Yarn on both providers, Yarn Classic vs Berry, the CircleCI image check, engines.node (a range on GitHub, a number on CircleCI, a version file winning), every mistake, and the inputs in a sub-path.
  • A golden fixture (integration_tests/module_node/) for both providers.
  • mockci (tests/module_node.rs):
    • a skipped job installs nothing;
    • the job reruns when any of these changes: the lockfile, .npmrc, pnpm-workspace.yaml, a workspace package's package.json, patches/, the root .nvmrc, a package-level .node-version, engines.node, or the module's parameters.
  • The docs page, module README, skill and catalogue are updated. task ci passes with no warnings.

Get evidence
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

`modules: [node]` installs the Node the project pins and its package
manager, runs a frozen install and caches the package manager's
downloads, on GitHub Actions and CircleCI.

- Node's version: .nvmrc or .node-version in `path`, else at the root,
  else package.json's engines.node, else `version:` (or `preinstalled`).
  On CircleCI the job's image must be a node/cimg/node image matching
  the pinned version.
- Package manager: package.json's packageManager, else the one lockfile
  present. pnpm and Yarn go through pnpm/action-setup or Corepack.
- Install: npm ci, pnpm install --frozen-lockfile, yarn install
  --immutable (Berry) or --frozen-lockfile (Classic).
- Cache: setup-node's cache keyed on the lockfile on GitHub;
  restore_cache/save_cache keyed on the lockfile's checksum on CircleCI.
- Inputs: package.json files, lockfiles, pnpm-workspace.yaml, .npmrc,
  Yarn config and patches, and the version file.

Tests: unit tests for detection, expansion and every mistake; a golden
fixture for both providers; mockci scenarios that a skipped job installs
nothing and that each contributed input and the parameters rerun it.
…h; always install the pinned Corepack; set pnpm 11's store dir

This branch has not been deployed

No deployments
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.

1 participant