diff --git a/README.md b/README.md index e9e8b42..3b7678b 100644 --- a/README.md +++ b/README.md @@ -121,7 +121,8 @@ workflows: ``` The `rust` module installs the toolchain your project pins, caches cargo's downloads and build output, and adds -`Cargo.toml`, `Cargo.lock` and the toolchain file to the job's hash. `node`, Playwright and services are next. +`Cargo.toml`, `Cargo.lock` and the toolchain file to the job's hash. The `node` module does the same for +Node with npm, pnpm or Yarn. Playwright and services are next. ## Install diff --git a/docs/src/content/docs/modules.md b/docs/src/content/docs/modules.md index 137a060..103a463 100644 --- a/docs/src/content/docs/modules.md +++ b/docs/src/content/docs/modules.md @@ -7,7 +7,7 @@ A module is setup you'd otherwise paste into every job: installing a toolchain, that setup depends on. A job lists its modules under `modules:`, and cigen expands each into ordinary steps before a provider sees the job. -The project in this page's examples is a Rust crate: +The project in this page's examples is a Rust crate with a Node frontend: ```toml title="Cargo.toml" [package] @@ -98,8 +98,61 @@ It installs with `rustup`, which GitHub's runners and the Rust images ship. On G architecture, the toolchain and `Cargo.lock`. Its full reference is [`src/modules/rust/README.md`](https://github.com/DocSpring/cigen/blob/main/src/modules/rust/README.md). +## The `node` module + +Installs Node and the package manager your project pins (npm, pnpm or Yarn), runs a frozen install, and caches the +package manager's downloads. Node's version comes from `.nvmrc` or `.node-version`, else `engines.node` in +`package.json`, and pnpm's or Yarn's from `packageManager` in `package.json`: + +```json title="package.json" +{ + "private": true, + "packageManager": "pnpm@9.15.0", + "scripts": { "lint": "eslint ." } +} +``` + +```yaml title="pnpm-lock.yaml" +lockfileVersion: '9.0' +``` + +```text title=".nvmrc" +22 +``` + +```yaml +# cigen.yml +provider: github + +workflows: + ci: + jobs: + lint: + modules: [node] + inputs: ['src/**'] + steps: + - run: pnpm lint +``` + +| Parameter | Default | Meaning | +| ----------------- | ---------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------- | +| `version` | what `.nvmrc` or `.node-version` in `path` or the root says, else `package.json`'s `engines.node`, else an error | a Node version, or `preinstalled` for the Node the image or runner already has | +| `package_manager` | `package.json`'s `packageManager`, else the one lockfile present, else an error | `npm`, `pnpm` or `yarn` | +| `install` | `true` | run a frozen install (`npm ci`, `pnpm install --frozen-lockfile`, `yarn install --immutable`) | +| `cache` | `true` | cache the package manager's downloads | +| `path` | `.` | the directory holding `package.json` and the lockfile | + +On GitHub Actions it uses `pnpm/action-setup` for pnpm, Corepack for Yarn, and `actions/setup-node` (pinned to commits) +with its cache. On CircleCI, Node comes from the job's image: a `cimg/node` or `node` image whose tag starts with the +pinned version, or any image with `version: preinstalled`; pnpm and Yarn come through Corepack, and the cache through +`restore_cache` and `save_cache`. It adds every tracked `package.json` under `path`, and in `path` and each folder above +it the lockfiles, workspace and package manager config, the pnpmfile, Yarn's plugins, releases and cache, patches and +the version files, to the job's inputs, along with files the config names elsewhere (a `pnpmfile`, Yarn's `yarnPath`, +plugins, `cacheFolder` and `patchFolder`). A loose version (`22`, `lts/*`, an `engines.node` range) resolves when the job +runs, and only the spec is hashed, so a new Node release doesn't rerun a job that passed. Its full reference is +[`src/modules/node/README.md`](https://github.com/DocSpring/cigen/blob/main/src/modules/node/README.md). + ## More modules -`rust` is the first. Node with npm, pnpm or Yarn comes next, then Playwright, services (Postgres, an S3-compatible -store), a shared compile cache and Ruby with Bundler. The +Playwright, services (Postgres, an S3-compatible store), a shared compile cache and Ruby with Bundler come next. The [module catalogue](https://github.com/DocSpring/cigen/blob/main/src/modules/README.md) lists the ones that exist. diff --git a/docs/src/pages/index.astro b/docs/src/pages/index.astro index e52b2dc..aa5cc6c 100644 --- a/docs/src/pages/index.astro +++ b/docs/src/pages/index.astro @@ -164,7 +164,7 @@ const skipped = run.jobs.filter((job) => job.status === 'skipped').length;
-

Started · rust is built; node, Playwright and services are coming

+

Started · rust and node are built; Playwright and services are coming

Modules replace the setup you paste into every job

Toolchains, dependency caches, services and upload steps, pinned and tested once. Each module also adds the @@ -197,7 +197,7 @@ const skipped = run.jobs.filter((job) => job.status === 'skipped').length;

  • Skipping on GitHub Actions, with markers in its cache
  • Generated workflows install a checksum-checked cigen release
  • Byte-for-byte deterministic output
  • -
  • Modules, starting with rust
  • +
  • Modules for Rust and Node
  • @@ -205,7 +205,7 @@ const skipped = run.jobs.filter((job) => job.status === 'skipped').length;