Skip to Content
Xeonr Developer Docs
Pipelines

Test a Node.js project

Install, lint, test and build a Node.js project with pnpm, keeping the package store between runs.

Available in repositories branchd reads pipeline files for. It is switching repositories on one at a time: until yours is, it keeps running its .forge-ci.yaml or .xeonr-ci.yaml. See What is available.

.branchd/pipelines/ci.yaml
# .branchd/pipelines/ci.yaml
# Install, lint, test and build a Node.js project with pnpm, keeping the
# package store between runs.
name: CI
on: [push, pull_request]
jobs:
  test:
    image: node:24
    env:
      PNPM_STORE_DIR: .pnpm-store
    cache:
      key: pnpm
      files: [pnpm-lock.yaml]
      paths: [.pnpm-store]
    steps:
      - run: corepack enable
      - run: pnpm config set store-dir "$PNPM_STORE_DIR"
      - run: pnpm install --frozen-lockfile
      - run: pnpm lint
      - run: pnpm test
      - run: pnpm build
    artifacts:
      paths: [dist]
      expire-in: 7 days
  • cache: keeps .pnpm-store between runs. files: [pnpm-lock.yaml] keys the cache on the lock file's contents, with key as the prefix, so a new lock file starts a new cache. Cache paths are relative to the working directory.
  • Steps share one shell, so corepack enable in the first step holds for the rest.
  • artifacts: keeps dist for 7 days. A job that needs: [test] would find it in its own working directory.

For npm, replace the pnpm steps with npm ci and cache ~/.npm by setting npm_config_cache to a path inside the working directory.