Checks in CI¶
berc check PROJECT [--variant V] [--only CAT,ID] [--format text|json|sarif|md]
[--baseline report.json] [--fail-on error|warning|suggestion] [--require NEED]
[--set NAME=VALUE] [--theme THEME.json] [--units mm|mil|in]
PROJECT is a directory with one design in it (its .kicad_pro) or a design file. --units writes positions and lengths in messages in mm (default), mil or in, to match the editor's coordinate display; it wins over the project file's [report] units = "mil". Item names and the JSON report's positions stay in mm. Exit codes:
| code | meaning |
|---|---|
| 0 | no finding at or above --fail-on (default error) |
| 1 | findings at or above --fail-on; with --baseline, only findings that are not in the baseline count |
| 2 | usage or import error: no such path, several designs in the directory, an unreadable file, an unknown variant or check, a baseline of another schema |
| 3 | a --required need is not available on a board (--require layout without a .kicad_pcb); wins over 1 |
--format json writes the report with its versioned schema; that file is also what --baseline takes: findings are matched by board and fingerprint (check id and the names of the nets and parts involved), marked new or unchanged, and the fixed ones listed. --format sarif writes SARIF 2.1.0: one rule per catalogue check, error → error, warning → warning, suggestion → note, each finding located at the schematic file and the line of its symbol (the file alone where no line is known). --format md is a summary for a pull request comment. --state is reserved for power states and refused until they exist.
A GitHub Actions job that fails on errors, shows the findings in code scanning on the schematic files and puts the Markdown summary on the run page:
name: schematic checks
on: [push, pull_request]
jobs:
berc:
runs-on: ubuntu-latest
permissions:
contents: read
security-events: write # upload SARIF to code scanning
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- run: cargo install --locked --git https://github.com/romixlab/better_erc berc
- name: berc check
run: berc check hw/board --format sarif > berc.sarif
- name: Summary
if: always()
run: berc check hw/board --format md >> "$GITHUB_STEP_SUMMARY" || true
- name: Upload to code scanning
if: always()
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: berc.sarif
category: better_erc
Run it from the repository root with a relative project path: the SARIF file names the schematic files relative to the current directory, which is what code scanning expects. To adopt better_erc on a board with known findings, commit a baseline (berc check hw/board --format json > hw/board/berc-baseline.json) and add --baseline hw/board/berc-baseline.json: from then on only new findings fail the job.
Facts the schematic cannot state live in the project file next to the design, <name>.berc.toml (else berc.toml): net voltages, derating factors, check settings, and waivers for findings accepted on this design. berc waive hw/board I2C-1 R5 --reason "..." appends a waiver; a waived finding stays in the report, marked, and no longer fails the run. See docs/project-file.md.
Some checks read files kept with the board. --set drawing.notes=../doc/notes.md names the board's notes file, a Markdown file with one ## N13 · title heading per note, relative to the project directory; DRAW-50 then reports each See N13 on a sheet that points at a note the file lacks. Without the setting that check does not run. The project file sets it too, as notes under [drawing].
In this repository just check runs berc check on the test schematics against the committed test_schematics/berc-baseline.json (they have findings on purpose), and just check-baseline rewrites it.