Validate that a board's featured bus dependencies are satisfied - #1755
Conversation
8d96faa to
17e7c53
Compare
|
|
esphbot
left a comment
There was a problem hiding this comment.
No blocking issues found.
There was a problem hiding this comment.
Pull request overview
Adds a static validation step to script/validate_definitions.py to ensure that imported boards’ featured component sets are compilable with respect to bus dependencies (i2c/spi/uart/modbus/one_wire/canbus), plus targeted unit tests for the new validation helper.
Changes:
- Introduce
_validate_featured_dependencies()to flag featured components whose bus dependencies are missing from the same featured set (imported boards only, with an explicit allow-list). - Wire the new dependency validation into
_validate_featured()so it runs alongside existing structural and cross-reference checks. - Add unit tests exercising the new dependency validation behavior.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
script/validate_definitions.py |
Adds bus-category constants, an allow-list for known-unsatisfied imports, and the new _validate_featured_dependencies() check integrated into featured validation. |
tests/test_validate_featured.py |
Adds a small helper to construct minimal featured entries and new tests covering dependency validation outcomes. |
| present = {e.get("component_id") for e in featured if isinstance(e, dict)} | ||
| present_domains = {cid.split(".")[0] for cid in present if isinstance(cid, str)} |
| cid = entry.get("component_id") | ||
| if not isinstance(cid, str) or "." not in cid: | ||
| continue |
| def test_featured_dep_satisfied_by_featured_bus(_index: dict | None) -> None: | ||
| """The board passes once the i2c bus is also featured.""" | ||
| featured = [_leaf("i2c", "bus"), _leaf("sensor.sht3xd", "t")] | ||
| assert _validate_featured_dependencies("demo", featured, _index, True) == [] | ||
|
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1755 +/- ##
=======================================
Coverage 99.54% 99.54%
=======================================
Files 228 228
Lines 18202 18203 +1
=======================================
+ Hits 18120 18121 +1
Misses 82 82
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
17e7c53 to
1a38fcd
Compare
|
Thanks @esphbot — all three applied in
Full suite 5623 passed; |
Nothing checked that an imported board's featured components form a compilable set, so a featured leaf binding a bus that was never lifted into the catalog (the bug #1752 and #1753 fixed by hand) passed validation. Add _validate_featured_dependencies: flag any featured leaf whose catalog bus dependency no component on the board provides (featured or default). The allow list is keyed on (board, bus) so a different unsatisfied bus on an allow-listed board still fails, and BUS_CATEGORIES is shared through the stdlib-only constants module so the importer (which lifts buses) and the validator (which checks they were lifted) can't drift. A cheap static graph check, no esphome config compile.
1a38fcd to
ae5b398
Compare
|
Thanks @copilot — addressed in 1. 2. 3. Regression test for the top-level case — added
|
PR Review — Validate that a board's featured bus dependencies are satisfiedMerge-ready. A cheap, correct static guard that closes a real gap, with all prior-review and Copilot findings already addressed in-branch. What's solid:
What's left:
Checklist
Automated review by Kōan (Claude) |
esphbot
left a comment
There was a problem hiding this comment.
No blocking issues found.
What does this implement/fix?
Follow-up to #1752 and #1753 (both merged; this is rebased onto
main). Those PRsfixed boards whose imported full-setup config
wouldn't compile because a featured leaf's bus dependency was never lifted into
the catalog. We only found those by hand, because nothing validated that a
board's featured components form a compilable set:
validate_definitions.pychecks each piece structurally (schema, cross-references, pins) but never that a
featured leaf's bus dependency is actually present.
This adds that check.
_validate_featured_dependenciesflags any featured leaf(on an imported board) whose catalog
dependenciesinclude a bus(i2c/spi/uart/modbus/one_wire/canbus) that no featured component on the board
provides, with a message pointing at the sync-script lift. It is a cheap static
graph check, no
esphome configcompile and noesphome.componentsimport, so itfits the existing pre-commit / CI hook.
Five kincony boards remain knowingly unsatisfied for a different, source-level
reason (the source has no top-level bus block, or a
one_wire:block with noplatform:); they are tracked in an explicit_UNSATISFIED_BUS_ALLOW_LISTwiththe per-board reason rather than silently skipped, so removing one must be paired
with a fix. Run against the current catalog this passes; drop a board from the
allow list (or regress the sync script) and it fails with the offending leaf.
Related issue or feature (if applicable):
Types of changes
maintenanceFrontend coordination
Checklist
ruff,codespell, yaml/json/python checks).tests/where applicable.components.index.json/definitions/components/*.jsonhave not been hand-edited.docs/ARCHITECTURE.mdand/ordocs/API.md.