Skip to content
NorthernWidgetPublic

About

Compile matrix (Margay, Okapi) and host-side harness runner for the Northern Widget libraries

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

NW-Tests

Two checks over every Northern Widget library, run from one place.

Harnesses. Each library that has a desktop harness (extras/test/run.sh: the library's own source compiled with the host compiler against stub Arduino and Wire headers, output diffed against a recorded baseline) is run by ./harness.py, which needs no board and no arduino-cli.

Logger compiles. Does every sensor library still build inside a data-logger sketch? This repository holds one Margay sketch and one Okapi sketch per sensor library, in the shape of the hand-written logger examples (the logger owns the loop; update() returns the sensor's CSV row), and a runner that compiles all of them for the ATmega1284P that both loggers use.

The desktop harnesses in each library (extras/test/) prove a library's logic and output; this proves that the library, the logger library, and their dependencies still compile together for the real target.

Run

./harness.py                 # every library harness found in the workspace; exit 1 on any failure
./compile.py                 # every sketch; writes results.md and results.json; exit 1 on any failure
./compile.py --only Apis     # one sensor (both loggers)
./version_check.py           # one version per library: library.properties vs. source constants, CITATION.cff, .zenodo.json, latest tag
./style_check.py <repo>      # added code lines match the file they land in (run before every commit)

Versions. version_check.py reads every place a library states its version and fails when two disagree, or when library.properties is behind the latest v* tag. The version in the source matters most: Margay writes its LibVersion into every status file's boot row, so a release that bumps library.properties alone would sign files with the old number. In CI the checkouts are shallow clones and may carry no tags, so the tag comparison is a local check; the in-repository comparison runs everywhere.

The runner compiles against the libraries checked out beside this repository (NW_WORKSPACE, default the parent directory) and points the Arduino sketchbook at an empty directory, so a stale copy in ~/Arduino/libraries cannot hide a break. Third-party dependencies (Adafruit BME280, Unified Sensor, BusIO, ADS1X15) are taken from ~/Arduino/libraries/Adafruit_* or EXTRA_LIBS. ARDUINO_CLI names the binary; by default the one on PATH, else the one bundled with Arduino IDE 2.

Results are committed as a dated record: results.md.

Sketches

Generated by make_sketches.py from one table row per library (header, class, I2C address, begin() arguments, string call) and committed so they read as plain examples. To add a library, add a row and rerun the generator.

CI

.github/workflows/tests.yml checks out the library repositories beside this one, runs the harnesses, then installs arduino-cli with the Arduino AVR and Northern Widget cores and runs the compile matrix. It runs on push and weekly, so a change in any library that breaks a logger sketch shows up here.

KiCad

kicad/ holds the checks for a schematic edited as text and for an Eagle-to-KiCad conversion. Both run before any commit that touches a .kicad_sch or .kicad_pcb:

cd kicad
./check_conversion.sh <root.kicad_sch> <Eagle .sch> [ignored refs]   # Eagle nets vs. KiCad nets; the "Eagle nets:" line is the test
./roundtrip.sh <root.kicad_sch>                                       # KiCad re-saves a copy; every sheet must come back byte-identical
./render.sh <root.kicad_sch> <outdir>                                 # SVG and 600 dpi PNG per sheet
python3 kicad/crop.py <sheet.png> <x_mm> <y_mm> <w_mm> <h_mm> <out.png>
./erc_counts.sh <root.kicad_sch> <out.json>                          # ERC with every severity; the two endpoint counts and the total
python3 sch_walk.py <sheet.kicad_sch> <x_mm> <y_mm>                   # every pin, wire, label and junction touching a point
./roundtrip_pcb.sh <board.kicad_pcb>                                 # KiCad re-saves a copy of the board; must come back identical
./render_pcb.sh <board.kicad_pcb> <out.png> [layers] [dpi]           # board to PNG in sheet coordinates (1200 dpi: 47.24 px/mm)
python3 relink.py <root.kicad_sch> <board.kicad_pcb> <eagle.brd> <nickname> <library.pretty> [--strip SUF] [--alias OLD=NEW] [--write-table]
python3 rebody.py <board.kicad_pcb> <nickname> <library.pretty> [--report out.json]
python3 link_paths.py <netlist.xml> <board.kicad_pcb> [--values] [--fields]
python3 rename_nets.py <netlist.xml> <board.kicad_pcb>

The last four take a converted project onto a shared footprint library in the order given: relink rewrites every footprint reference by the element's Eagle package; rebody replaces every embedded footprint body with the library's, keeping placement, rotation, side and pad nets; link_paths and rename_nets write what Update PCB from Schematic would (symbol paths, values, fields, the schematic's net names), from a kicad-cli sch export netlist --format kicadxml file. After each: kicad-cli pcb upgrade --force on the board (twice the first time), roundtrip_pcb.sh, and pcb_stats.py before and after, whose pad-net table must be identical by (reference, pad), names aside for rename_nets.

To change a sheet, import sch_edit.Editor (move a symbol with its fields, move or add or delete a wire, move a junction or a label, set one property anchor) and run the three checks above on the result. Each operation asserts that what it edits exists exactly once, and a move followed by the reverse move returns the file byte for byte. sch_walk.Sheet is the geometry reader behind the point query.

For Okapi the conversion check expects 209 of 209 Eagle nets reproduced with 0 differences, and the round trip returns Okapi_2 to Okapi_6 identical (the root sheet carries two differences left by the import). ERC on Okapi reports 0 unconnected wire endpoints and 0 off-grid endpoints; its JSON files every violation under the first sheet and gives a dangling wire's connected end, so diagnose with the point query, not from it. Needs kicad-cli (10.0.7), inkscape, and ImageMagick.

About

Compile matrix (Margay, Okapi) and host-side harness runner for the Northern Widget libraries

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages