Skip to content

Re-stamp boards before the component sync and sort platform defaults - #3017

Merged
J. Nick Koston (bdraco) merged 1 commit into
mainfrom
sync-order-determinism
Nov 5, 2026
Merged

J. Nick Koston (bdraco) merged 1 commit into
mainfrom
sync-order-determinism

Conversation

@bdraco

Copy link
Copy Markdown
Member

What does this implement/fix?

Stop the nightly component sync from opening a follow-up PR after every board restamp or rerun: new boards now reach the platform board dropdowns in the same sync, and platform_defaults keys come out in a stable order.

# before
- Run sync_components          # reads the old boards.index.json
- Re-stamp board catalog       # adds nrf52840dongle, generic-rtl8710bx-1mb-468k
# after
- Re-stamp board catalog
- Run sync_components          # dropdowns list the restamped boards
- Regenerate board catalog     # board bodies read the fresh component catalog
Verification

Ran the new step order locally against esphome 2026.11.0b1 (sync_boards.py --restamp, sync_components.py, sync_boards.py, validate_definitions.py): all passed, the second board sync changed no board files, and the component diff against main was the two board options from #3016 plus order-only platform_defaults changes in the seven files above. The board sync reads component bodies for pin and reference keys, which is why it runs again after the component sync instead of only moving the restamp.

Related issue or feature (if applicable):

Types of changes

  • Bugfix (non-breaking change which fixes an issue) — bugfix
  • New feature (non-breaking change which adds functionality) — new-feature
  • Enhancement to an existing feature — enhancement
  • Breaking change (fix or feature that would cause existing functionality to not work as expected) — breaking-change
  • Refactor (no behaviour change) — refactor
  • Documentation only — docs
  • Maintenance / chore — maintenance
  • CI / workflow change — ci
  • Dependencies bump — dependencies

Frontend coordination

  • No frontend change needed
  • Companion frontend PR: esphome/device-builder-frontend#

Checklist

  • The code change is tested and works locally.
  • Pre-commit hooks pass (ruff, codespell, yaml/json/python checks).
  • Tests have been added or updated under tests/ where applicable.
  • components.index.json / definitions/components/*.json have not been hand-edited (regenerate via script/sync_components.py if a sync is needed).
  • Architecture-level changes are reflected in docs/ARCHITECTURE.md and/or docs/API.md.

@bdraco

Copy link
Copy Markdown
Member Author

ESPHome Bot (@esphbot) review

@github-actions github-actions Bot added the maintenance Maintenance / chores label Nov 5, 2026
@codspeed

codspeed Bot commented Nov 5, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 28 untouched benchmarks
⏩ 1 skipped benchmark1


Comparing sync-order-determinism (d26709c) with main (ce8bcaa)

Open in CodSpeed

Footnotes

  1. 1 benchmark was skipped, so the baseline result was used instead. If it was deleted from the codebase, click here and archive it to remove it from the performance reports. ↩

@esphbot

Copy link
Copy Markdown
Contributor

PR Review — Re-stamp boards before the component sync and sort platform defaults

Merge-ready. This fixes the cause of the follow-up sync PRs with no runtime change, and I found nothing to fix.

What the PR does well:

  • Board sync runs before and after the component sync. The restamp now runs before sync_components, so new boards reach the board dropdowns from _load_board_index in the same run. The unflagged sync_boards.py runs again after sync_components, so board bodies use the catalog that run just wrote.
  • The second board sync can't hit a version mismatch. I checked script/sync_boards.py:1445: once --restamp has written the installed version into boards.index.json, the second plain run passes the stamp check. So it can't fail on a mismatch and doesn't need --restamp again.
  • The first board sync can't crash on a stale catalog. It still reads the old component catalog, but _component_body (script/sync_boards.py:961) returns {} for missing or unreadable files. A component removed upstream can't crash the restamp; at worst it gives stale pin or reference keys, and the second run corrects those.
  • Sorting platform_defaults is safe. It runs on the result of normalize_platform, which is always a str. Lookups read keys by name, so order doesn't matter to them. The JSON output becomes deterministic even when upstream builds a SplitDefault from a set (VARIANTS_NO_RMT). The new test declares SplitDefault keys out of order (rp2, esp32_c61, esp32_c2) and asserts the sorted output.
  • Docs and description match the change. The _load_board_index docstring now describes the new step order and dropped the outdated "trails by one cycle" note. The PR description matches the diff and correctly flags the one-time key reorder in seven component files.

No issues found.



Checklist

  • Workflow step order matches stated goal
  • Second sync_boards run passes the version-stamp guard
  • platform_defaults ordering deterministic and covered by test
  • No hardcoded secrets / injection in workflow

Automated review by Kōan (Claude) HEAD=d26709c 19s

@esphbot ESPHome Bot (esphbot) left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tip

No blocking issues found — ready to merge.

@codecov

codecov Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.76%. Comparing base (cbc3c99) to head (d26709c).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #3017   +/-   ##
=======================================
  Coverage   99.76%   99.76%           
=======================================
  Files         300      300           
  Lines       26403    26403           
=======================================
  Hits        26341    26341           
  Misses         62       62           
Flag Coverage Δ
py3.12 99.73% <ø> (ø)
py3.14 99.61% <ø> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@bdraco
J. Nick Koston (bdraco) marked this pull request as ready for review November 5, 2026 03:58
Copilot AI balanced review requested due to automatic review settings November 5, 2026 03:58

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are reported for the catalog-generation consistency changes.

No open issues 🎉

What changed in this PR

This PR makes catalog generation more consistent, preventing follow-up refresh PRs caused by stale board options or unstable platform-default ordering. It does not change runtime behavior.

Changes:

  • Re-stamps boards before component sync, then regenerates board bodies against the refreshed component catalog.
  • Sorts platform_defaults keys for deterministic output.
  • Adds a regression test for platform-key ordering and updates the board-index loading documentation.
File Description
tests/​test_sync_components_platform_defaults.py Tests deterministic platform-key ordering.
script/​sync_components.py Sorts platform defaults and clarifies board-index loading.
.github/​workflows/​sync-component-catalog.yml Orders catalog generation so board options and bodies use refreshed data.

Review effort: Balanced

@bdraco
J. Nick Koston (bdraco) merged commit bd7f016 into main Nov 5, 2026
28 checks passed
@bdraco
J. Nick Koston (bdraco) deleted the sync-order-determinism branch November 5, 2026 04:01
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 7, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

maintenance Maintenance / chores

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants