Skip to content

CI integration ​

One command generates a PR workflow — advisory by default, never blocking:

bash
mjolnir ci install

Or wire it into GitHub Code Scanning natively via SARIF:

yaml
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.sarif

On GitLab, the Code Quality report renders as the MR widget and inline diff annotations:

yaml
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.json

Full recipe (gate step, scheduled audit, self-hosted notes): GitLab CI. Editor and pipeline setup for SARIF: SARIF integration.

  1. 1Real failureA test fails. The exit code says so.
  2. 2Masked by CIA workflow pragma swallows the failure before anyone sees it.
  3. 3Green checkThe Checks API reports success — the branch looks mergeable.
  4. 4False trustThe team merges on green. The bug ships with a clean record.

The masks — and the rule that strips each:

  • continue-on-error: trueQA-CI-001continue-on-error masks a failing verification gate
  • || trueQA-CI-002Ignored exit code (|| true)
  • missing pipefailQA-CI-009Test command does not propagate exit code
  • if: skip-on-PRQA-CI-010Tests skipped where they must block

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.

bash
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 only

Pass --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.

CodeMeaning
0Clean — nothing at or above the gate
1Findings at or above the gate
2Partial scan (for example, --max-duration ran out)
10Usage error — a bad flag or a missing argument
20Internal 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:

bash
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 ​

bash
mjolnir --format pr-comment                  # the whole tree, as a PR comment
mjolnir --scope changed --format pr-comment  # only what this branch changed

Both write Markdown to stdout, so posting them is your CI's job — pipe the output into gh pr comment --body-file - or the equivalent.

Released under the MIT License.