CI integration
One command generates a PR workflow — advisory by default, never blocking:
mjolnir ci installOr wire it into GitHub Code Scanning natively via SARIF:
jobs:
verify:
runs-on: ubuntu-latest
permissions:
contents: read
security-events: write
steps:
- uses: actions/checkout@v4
- run: npx mjolnir-qa@6.1.0 --format sarif > mjolnir.sarif
# The scan exits 1 when it finds something, which is exactly when the
# upload has to run.
- uses: github/codeql-action/upload-sarif@v3
if: always()
with:
sarif_file: mjolnir.sarifOn GitLab, the Code Quality report renders as the MR widget and inline diff annotations:
mjolnir:
image: node:22
script: npx --yes mjolnir-qa@6.1.0 . --scope changed --format codequality
> gl-code-quality-report.json
artifacts:
reports:
codequality: gl-code-quality-report.jsonFull recipe (gate step, scheduled audit, self-hosted notes): GitLab CI. Editor and pipeline setup for SARIF: SARIF integration.
- 1Real failureA test fails. The exit code says so.
- 2Masked by CIA workflow pragma swallows the failure before anyone sees it.
- 3Green checkThe Checks API reports success — the branch looks mergeable.
- 4False trustThe team merges on green. The bug ships with a clean record.
Changed-scope coverage
--scope changed attributes findings to lines added in your branch vs the merge-base with main. It covers test files (*.spec.*, *.test.*) plus GitHub workflow files and Playwright configs in the diff. When the merge-base can't be resolved — shallow clone, detached HEAD, non-git target, different default branch — it degrades honestly: findings fall back to full-file attribution and the report says so. Override the base ref with --base <ref>.
Choosing the gate
ci install writes an advisory workflow by default: it reports, it never blocks. That is the right starting point — a gate that fails on day one gets disabled on day two.
mjolnir ci install --gate advisory # report only (default)
mjolnir ci install --gate warning # fail on warnings and errors
mjolnir ci install --gate error # fail on errors onlyPass --force to overwrite a workflow you have already customised; without it, ci install refuses rather than clobbering your edits.
Exit codes
The gate is the exit code, so any CI system can consume it — no plugin needed.
| Code | Meaning |
|---|---|
0 | Clean — nothing at or above the gate |
1 | Findings at or above the gate |
2 | Partial scan (for example, --max-duration ran out) |
10 | Usage error — a bad flag or a missing argument |
20 | Internal error |
Full contract: exit codes and frozen contracts.
Turning it on in a repo that already has debt
A first scan of a mature suite will find plenty. Rather than fixing all of it before the gate goes on, snapshot what exists and gate only on what is new:
mjolnir --save-baseline # once: snapshot existing debt to .mjolnir/baseline.json
mjolnir ci verify # from now on: gate only on findings the baseline lacks--scope changed does the same job per-branch, and the two compose: the baseline holds the line on the repo, --scope changed holds it on the diff.
Reporting into the pull request
mjolnir --format pr-comment # the whole tree, as a PR comment
mjolnir --scope changed --format pr-comment # only what this branch changedBoth write Markdown to stdout, so posting them is your CI's job — pipe the output into gh pr comment --body-file - or the equivalent.