Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions .github/workflows/hardware-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: hardware-check

on:
push:
branches: [main]
paths:
- "hardware/**"
- ".github/workflows/hardware-check.yml"
pull_request:
paths:
- "hardware/**"
- ".github/workflows/hardware-check.yml"
workflow_dispatch:

# Headless KiCad: ERC on the rev2 schematic, DRC on every board that has an
# outline, and SVG/PDF exports of the rev2 sheets as a downloadable artifact.
# Mirrors hardware/rev2/tools/kicad-check.sh — keep the two in step.
# Image pinned by digest (constitution III): kicad/kicad:10.0 @ 2026-09-02.
env:
KICAD_IMAGE: kicad/kicad:10.0@sha256:fdcfa0e8d41f640d16edfb28e027fe8862ab31af9e45dcacbc662cec5c916e4c

jobs:
kicad:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: ERC + DRC + exports (kicad-cli in container)
run: |
docker run --rm --user root -v "$PWD":/work -w /work \
-e KICAD_CLI=kicad-cli -e HOME=/tmp "$KICAD_IMAGE" \
bash hardware/rev2/tools/kicad-check.sh

- name: Upload reports and schematic exports
if: always()
uses: actions/upload-artifact@v4
with:
name: kicad-rev2-exports
path: |
hardware/rev2/export/*.rpt
hardware/rev2/export/*.pdf
hardware/rev2/export/svg/*.svg
if-no-files-found: warn
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,4 @@ docs/user-guide.md
docs/safety.md
.playwright-mcp/
*.lck
hardware/rev2/export/
8 changes: 8 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,14 @@ docker run --rm -v "$PWD/firmware":/project -w /project espressif/idf:v6.0.1 idf

Board selection (Kconfig: `BOARD_REV1_DEVKIT` / `BOARD_REV2`), flashing, host tests, and all other build details are documented in `firmware/CLAUDE.md`.

### Hardware checks (KiCad, headless)

```bash
hardware/rev2/tools/kicad-check.sh # ERC (rev2 schematic) + DRC (boards with an outline) + SVG/PDF exports → hardware/rev2/export/ (gitignored)
```

CI runs the same script in the pinned `kicad/kicad:10.0` image on every `hardware/**` change (`.github/workflows/hardware-check.yml`) and uploads the schematic exports as a workflow artifact. Rendered sheets are the way to *look* at the schematic from a session — never redraw a sheet by hand.

### Arduino legacy (frozen)

Built by CI only, on the `arduino-maintenance` branch (pinned PlatformIO platform + library versions). Do not build it from `main`.
Expand Down
42 changes: 42 additions & 0 deletions hardware/rev2/tools/kicad-check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/usr/bin/env bash
# KiCad headless checks + exports for the rev2 hardware (and rev1 DRC).
# Same commands CI runs (.github/workflows/hardware-check.yml) — run locally
# before pushing. Output lands in hardware/rev2/export/ (gitignored).
#
# hardware/rev2/tools/kicad-check.sh # erc + drc + exports
# hardware/rev2/tools/kicad-check.sh erc # one step only
#
# Uses kicad-cli from PATH, else the macOS KiCad 10 bundle.
set -euo pipefail
HW="$(cd "$(dirname "$0")/../.." && pwd)"
REV2="$HW/rev2"; OUT="$REV2/export"; mkdir -p "$OUT"
KC="${KICAD_CLI:-$(command -v kicad-cli || echo /Applications/KiCad/Kicad10.app/Contents/MacOS/kicad-cli)}"
step="${1:-all}"; rc=0
run() { echo "== $*"; "$@" 2>&1 | grep -v '^Fontconfig' || true; }

has_outline() { grep -qE '\(gr_(line|rect|poly|arc|circle)' "$1" && grep -q 'Edge.Cuts' "$1"; }

if [[ $step == all || $step == erc ]]; then
echo "### ERC rev2 schematic"
"$KC" sch erc -o "$OUT/rev2-erc.rpt" --severity-error --exit-code-violations \
"$REV2/WateringSystem-rev2.kicad_sch" 2>&1 | grep -v '^Fontconfig' || rc=1
fi
if [[ $step == all || $step == drc ]]; then
echo "### DRC rev1 board"
"$KC" pcb drc -o "$OUT/rev1-drc.rpt" --severity-error --exit-code-violations \
"$HW/WateringSystem.kicad_pcb" 2>&1 | grep -v '^Fontconfig' || rc=1
if has_outline "$REV2/WateringSystem-rev2.kicad_pcb"; then
echo "### DRC rev2 board"
"$KC" pcb drc -o "$OUT/rev2-drc.rpt" --severity-error --exit-code-violations \
"$REV2/WateringSystem-rev2.kicad_pcb" 2>&1 | grep -v '^Fontconfig' || rc=1
else
echo "### DRC rev2 board: SKIPPED — no board outline yet (stage-A modules / stage-B layout pending)"
fi
fi
if [[ $step == all || $step == export ]]; then
echo "### Export rev2 schematic → SVG + PDF"
run "$KC" sch export svg -o "$OUT/svg" --no-background-color "$REV2/WateringSystem-rev2.kicad_sch"
run "$KC" sch export pdf -o "$OUT/WateringSystem-rev2.pdf" "$REV2/WateringSystem-rev2.kicad_sch"
fi
echo "### done (rc=$rc) — reports and exports in $OUT"
exit $rc
Loading