# Checks in CI

Run the Summonmade checks on every push and pull request, with a job summary, a JUnit report and a failed build when a part cannot be made.


Hardware changes like software: a new board revision, a thinner wall, a smaller hole. Run the Summonmade checks in continuous integration (CI), and each push and pull request tells you if every part can still be made. The checks use the rules of the factory profile. See [Checks and factory rules](/docs/guides/make/checks).

## The command

In CI, run the checks with `--ci`:

```sh
fab check --ci --junit reports/summonmade.xml
```

With `--ci`, the command does these steps:

1. The command runs every check of the product. The checks that need the internet run too; add `--offline` to skip them.
2. The command prints a short Markdown summary: the result, the counts, and one row for each failure and warning with the rule ids.
3. The command adds the summary to the file in the environment variable `GITHUB_STEP_SUMMARY`. GitHub Actions sets this variable, so the summary shows on the page of the job.
4. The command stops with an exit code: 0 when no check fails, 1 when a check fails, 2 when the product folder cannot be read.

| Option | What it does |
| --- | --- |
| `--junit FILE` | Writes the results as JUnit XML. A failed check is a failed test; a warning is a passed test with a note. |
| `--summary FILE` | Adds the Markdown summary to this file. |
| `--fail-on warn` | Warnings also fail the run. |
| `--offline` | Skips the checks that need the internet (parts stock, catalog). |
| `--only ID` | Runs only this check or group, for example `--only pcb`. |
| `--part ID` | Runs only the checks of this part. |
| `--product FOLDER` | The product folder. The default is the folder with `product.toml` from here up. |

## GitHub Actions

The Summonmade repository has an action that installs the Workbench, installs KiCad when the product has a KiCad board, and runs the checks. Add this file to your product repository as `.github/workflows/summonmade-checks.yml`:

```yaml
name: Hardware checks

on:
  push:
  pull_request:

jobs:
  checks:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: T-R3x3r/summonmade/.github/actions/summonmade-check@main
        with:
          product: .
```

| Input | Default | What it does |
| --- | --- | --- |
| `product` | `.` | The product folder, with `product.toml`. |
| `fail-on` | `fail` | `warn` makes warnings fail the job too. |
| `kicad` | `auto` | `auto` installs KiCad when the product has a `.kicad_pcb` file. `true` always installs KiCad; `false` never does, and the KiCad checks report skip. |
| `extras` | `mesh,cad` | The extras of the Workbench: `mesh` for wall thickness and fit, `cad` for STEP models. |
| `offline` | `false` | `true` skips the checks that need the internet. |
| `junit` | `summonmade-checks.xml` | The file for the JUnit report. The action uploads the file as an artifact. |
| `python-version` | `3.12` | The Python version for the Workbench. |

The action gives the output `result`: `pass`, `warn` or `fail`.

:::callout{type="tip"}
KiCad takes 2 to 3 minutes to install. The KiCad checks (electrical rules, design rules, factory rules in KiCad) need it. The other board checks read the board file directly and run without KiCad.
:::

## Other CI services

Install Python 3.11 or later and the Workbench, then run the command:

```sh
pip install "fab[mesh,cad] @ git+https://github.com/T-R3x3r/summonmade"
fab check --ci --junit reports/summonmade.xml
```

Most CI services read JUnit XML and show each check as a test.

## Check on your computer first

Run the same checks before you push:

```sh
fab check --fail-on warn
```

Or keep `fab watch` open while you design, and the checks run each time that you save a file.
