Monk CIMonk CI home

20 Nov, 2026Mahesh Kale

Node.js CI on Monk CI: Build and Test


Build and test Node.js on Monk CI with a practical GitHub Actions workflow, npm dependency caching, a committed lockfile, and clear job steps.

A useful Node.js pipeline answers three questions: can we install the locked dependencies, do the tests pass, and does the app build? Keep those steps clear and a failed run is much easier to read.

On Monk CI, you can express that pipeline in the GitHub Actions workflow your team already uses. Here's a small starting point, with package caching included.

Start with a repeatable local build

This example assumes your repository is connected to Monk CI, uses npm, and has a committed package-lock.json at its root. Its package.json must provide test and build scripts.

Run these commands locally first :

npm ci
npm test
npm run build

Use a test command that finishes once, rather than entering watch mode. A pipeline waiting for file changes will keep running until it times out.

The included example uses Node's built-in test runner and a small build script. Replace those scripts with your app's tools as needed.

Give each step one job

Save this as .github/workflows/ci.yml:

name: Node CI
on:
  push:
  pull_request:

permissions:
  contents: read

jobs:
  build-test:
    runs-on: monkci-ubuntu-24.04-4
    timeout-minutes: 15
    steps:
      - uses: actions/checkout@v7
      - uses: actions/setup-node@v7
        with:
          node-version: '24'
          cache: npm
          cache-dependency-path: package-lock.json
      - run: npm ci
      - run: npm test
      - run: npm run build

The explicit Monk CI label selects a documented four-vCPU Ubuntu tier. Keep the size fixed while you learn where the job spends its time.

The action versions above require a maintained Actions runner with support for their Node 24 runtime. Confirm that requirement for the target runner; the app's node-version setting is a separate choice. For production, pin reviewed action commits if your team's policy requires it.

A cache hit still needs an install

With cache: npm, setup-node caches npm's package data. It does not restore node_modules as a ready-to-run dependency tree. Keep npm ci on every run.

That command installs from the lockfile, recreates the dependency directory, and fails if the manifest and lockfile disagree. This catches a common local mistake: adding a package but forgetting to commit the updated lockfile.

Monk CI documents an Actions-compatible cache backend for this path. The benefit is a chance to reuse package downloads across jobs; install scripts and native compilation may still take time. A missing cache must not break the build.

In a monorepo, point cache-dependency-path at the relevant lockfile and set the run steps' working directory to the package folder. Those settings do different jobs: one selects cache inputs, the other decides where commands run.

Read the timings before changing the machine

Separate install, test, and build durations. If downloads dominate, inspect cache hits and registry access. If tests dominate, check slow cases and the test runner's worker settings before adding more CPU.

Keep the first run's logs as a baseline before changing caching settings, test workers, or runner size.

Private dependencies need registry configuration and a suitable token. Add those through the registry's documented setup and GitHub secrets; the public-package example above needs neither.

This workflow changes the execution target while keeping the familiar GitHub Actions structure. It gives you a small, readable baseline for judging Monk CI against your existing runner on your own workload.

Takeaway: Pin the runtime, commit the lockfile, and keep install, test, and build as distinct steps. Then use the job's timings to decide what to improve next.

Sources

Try Monk CI for free

Continue with GitHub