This reusable GitHub Actions workflow runs quality control checks on a Node.js project: it checks out, installs Node, installs dependencies from the lockfile, and runs your QC script.
⚠️ @v3requires rman 2.x if yourqc_scriptcalls rman. See Migrating to v3.
jobs:
quality-check:
uses: panates/github-actions/.github/workflows/node-qc.yaml@v3For a monorepo (managed with rman), point qc_script at
rman run so QC only touches packages that actually changed:
jobs:
quality-check:
uses: panates/github-actions/.github/workflows/node-qc.yaml@v3
with:
qc_script: "rman run qc --changed-since origin/main"
fetch-depth: "0" # --changed-since compares against a ref a shallow clone does not haverman is installed globally at the version this workflow pins, so qc_script can call it by name.
| Name | Type | Default | Description |
|---|---|---|---|
qc_script |
string | "npm run qc" |
Command to run for QC - e.g. "rman run qc --changed-since <ref>" for a monorepo. |
node-version |
string | "" |
Node.js version. |
fetch-depth |
string | "1" |
Commits to fetch. --changed-since needs "0". |
install |
string | "ci" |
"ci" (from the lockfile), "install" (resolve fresh), or "false" (skip). |
github-registries |
string | - | Scopes to route to npm.pkg.github.com, or "auto" - needed only to install a dependency hosted there. |
package-manager |
string | "" |
"npm" or "pnpm". Empty detects it from the committed lockfile. A pnpm repository usually sets qc_script too - its default, npm run qc, runs npm. |
cache |
string | "true" |
Caches the package manager's download cache (~/.npm, or pnpm's store), keyed by the lockfile. Set "false" in a repository that commits no lockfile: setup-node has nothing to hash and fails with Dependencies lock file is not found before anything installs. Such a repository also needs install: "install" or "false". |
| Name | Required | Description |
|---|---|---|
PERSONAL_ACCESS_TOKEN |
Optional | Only for npm.pkg.github.com. The checkout uses the job's own GITHUB_TOKEN. |
- Setup Environment —
panates/gh-setup-node@v2: checkout, Node, npm auth,npm ci, and the pinnedrman. - Run QC Tests —
qc_script.
| v2 | v3 |
|---|---|
rman-ci: "true" |
install: "ci" (now the default) |
rman-ci: "false" → npm install --only=dev --no-save |
install: "ci", or install: "install" to resolve fresh |
PERSONAL_ACCESS_TOKEN required |
optional |
qc_script: "npx --yes rman@1 run qc ..." |
qc_script: "rman run qc ..." |
Three behaviours changed, and each was a defect rather than a preference:
rman-ciis gone. It chose betweennpm install --only=dev --no-saveandnpx rman ci, and neither is what a QC run wants.--only=devis npm's deprecated spelling of--omit=prodand leaves out the runtime dependencies a test actually imports;rman ciwipesnode_modulesacross every workspace to reinstall from scratch, which is a repair tool.npm ciinstalls exactly the lockfile, which is what CI is for.- The lockfile is no longer deleted before installing.
panates/gh-setup-node@v1ranrm -f package-lock.json && npm install --no-save, so QC checked a dependency set nobody had pinned or seen. Ifnpm cinow fails with apackage.json/package-lock.jsonmismatch, that drift is real and committed — regenerate withnpm install --package-lock-onlyand commit it.install: "install"is the way down if you cannot today. - The repository was being checked out twice, once by
actions/checkoutand once inside the setup action. Now once, withfetch-depthunder your control — which is what makes--changed-sinceusable at all.
- The
qc_scriptshould be defined in yourpackage.json(or be a directrman run ...call) and can include linters, formatters, or test runners. - Caching is npm's download cache (
~/.npm), keyed by the lockfile — notnode_modules, which is not portable across Node versions.
This workflow is provided under the MIT License.