Skip to content

Using Nadle in CI ​

This page shows a GitHub Actions workflow that installs dependencies, restores the Nadle task cache and runs nadle check, then lists the flags and exit codes that matter when a machine runs your build.

GitHub Actions ​

yaml
name: CI

on:
  pull_request:
  push:
    branches: [main]

jobs:
  check:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v7

      - uses: actions/setup-node@v6
        with:
          node-version: 24
          cache: npm

      - run: npm ci

      - name: Restore the Nadle task cache
        uses: actions/cache@v6
        with:
          path: node_modules/.cache/nadle
          key: nadle-cache-${{ runner.os }}-${{ github.sha }}
          restore-keys: |
            nadle-cache-${{ runner.os }}-

      - run: npx nadle check --reporter agent

Notes on the workflow:

  • Nadle needs Node.js 22 or later, so any node-version from 22 up works.
  • npx nadle is used because a local install does not put nadle on the PATH. With pnpm or yarn use pnpm nadle or yarn nadle.
  • The action versions are the majors that Nadle's own workflow pins. Pin them to whatever your organization requires.
  • restore-keys starts each run from the newest cache of the same operating system, and the unique key saves the updated cache afterwards.

The cache directory ​

Nadle stores task results in node_modules/.cache/nadle of the project root by default. A task that declares neither inputs nor outputs leaves nothing in the directory. Cache this directory between runs, as in the workflow above. Pass --cache-dir <path> to store it elsewhere and cache that path instead.

On a restored cache a task whose inputs did not change is reported as UP-TO-DATE and skipped. Use --no-cache for a run that must execute every task and store nothing.

Flags for CI ​

FlagWhat it does in CI
--reporter agentPlain output without colors, banner or spinners: one stable line per task.
--no-cacheRuns every task and stores no results.
--continueKeeps running tasks whose dependencies succeeded after a task fails, and reports all failures.
--max-workers <n>Caps worker threads; the default is the CPU count minus one.
--since <ref>Runs only the requested tasks whose workspace changed since the git ref. CI checkouts must contain the ref, for example by fetching full history.

The live footer is already off in CI: it defaults to enabled only outside CI and on a terminal.

Two behaviours to know before you script around Nadle:

  • A mistyped task name is autocorrected and still runs. With nadle chekc Nadle resolves it to check, prints Resolved tasks: followed by chekc → root:check and exits 0. Spell task names exactly in CI.
  • Running nadle with no task exits 0 after printing No tasks were specified. and no RUN SUCCESSFUL summary. A script that passes an empty variable as the task name therefore still exits 0 without running anything; check the output or the variable before calling Nadle.

Exit codes ​

CodeMeaning
0Every requested task succeeded.
1A task failed, or an unexpected error occurred.
2Invalid configuration: config file missing or unloadable, invalid task names or options.
3A requested task or workspace was not found.
4The task graph contains a dependency cycle.

Other CI systems ​

The steps are the same on any CI system:

  1. Check out the repository and install Node.js 22 or later.
  2. Install dependencies.
  3. Restore node_modules/.cache/nadle from your CI cache.
  4. Run npx nadle <tasks> --reporter agent.
  5. Save node_modules/.cache/nadle back to the cache.

The --reporter agent output of a cached run looks like this:

text
UP-TO-DATE build
DONE check 0ms
SUCCESS in 6s (done 1 up-to-date 1)