Skip to content

Commit check ​

check-commits proves that each commit of a branch installs, passes its checks and builds by itself.

Run it ​

From the root of the repository, give the base and the head of the branch:

sh
node tools/pr-prep/check-commits.ts origin/main HEAD

The report gives one row for each commit and one column for each check. After the table, a line tells how many commits had a tree that already passed.

What it runs ​

For each commit, the check runs these steps:

  1. It checks that only a docs or instruction commit changes Markdown.
  2. It runs commitlint on the commit message, with the commitlint configuration of the checkout.
  3. In a new worktree of the commit, it runs npm ci and each of the test, lint, lint:markdown, lint:prose and build scripts.

Speed ​

Two features speed up the check:

  • The check keeps the result of each tree that passed every step, in pr-prep-cache in the Git directory. A commit can have the same tree, the same Node.js major version and the same scripts as a tree that passed. Then the check uses the old result and does not make a worktree. A new commit message does not change the tree, so a rebuilt stack reuses most results.
  • The check runs several worktrees at the same time. By default, it uses half of the processors of the machine.

Two environment variables change this behavior:

  • PR_PREP_JOBS sets the number of worktrees that run at the same time.
  • PR_PREP_NO_CACHE stops the check from reading or writing the cache.

CI starts with an empty cache, so CI checks each commit in full.