Skip to content

Add ESP-IDF runtime dependencies and gate publishing on a compile test - #162

Merged
ptr727 merged 6 commits into
developfrom
feature/espidf-runtime-dependencies
Jul 18, 2026
Merged

ptr727 merged 6 commits into
developfrom
feature/espidf-runtime-dependencies

Conversation

@ptr727

@ptr727 ptr727 commented Jul 18, 2026

Copy link
Copy Markdown
Owner

Why

ESPHome's ESP-IDF toolchain installer validates the openocd-esp32 tool by executing it, and that binary dynamically links libusb-1.0.so.0. The final image did not carry it, so every ESP-IDF build failed with an ESP-IDF framework installation failure (reported in #161 - the closing keyword is held for the develop -> main promotion, since a keyword in a PR targeting develop never fires).

What

The fix. libusb-1.0-0 for the openocd tool check, and ccache, which ESPHome enables automatically whenever the binary is on PATH and whose cache lands in the /cache volume.

Upstream's base image also adds build-essential, libcairo2, libmagic1t64, and patch. Those are deliberately not copied: this image splits builder from final, and cairosvg / magic are not installed. Verified rather than assumed - the Bluetooth proxy fixture (1429 build targets, BLE stack, TLS, esp_http_client) compiles with no missing-tool errors.

Compile test. A build-only smoke cannot see this class of break, because the toolchains that link against the missing library are downloaded on first compile. validate-task gains a compile-test job that builds the image and compiles the checked-in .github/compile-test/ configurations inside it as uid 1000. Fixtures span the distinct execution environments rather than enumerating boards:

Fixture Dimension it uniquely covers
esp32-bluetooth-proxy.yaml Xtensa ESP-IDF, widest component surface (BLE stack)
esp32c6-bluetooth-proxy.yaml RISC-V ESP-IDF - a separate compiler binary
esp32-ethernet.yaml wired Ethernet PHY drivers
esp8266-d1-mini.yaml PlatformIO + Arduino - a different build system

The publisher always runs it, so build-docker (which already needs validate) blocks the push and the release on a firmware break. Push CI runs it only when an inline change-gate sees Docker/**, .github/compile-test/**, or upstream-version.json move - so the tracker's daily pin bump is compile-tested before the merge-bot auto-merges it, while a doc-only push pays nothing.

Upstream-dependency watcher. A daily job snapshots the apt package list ESPHome's own base image installs into upstream-dependency.json and opens a PR when it changes. Its head ref is outside the merge-bot's upstream-version-* pattern, so it waits for triage - deciding whether a package upstream adds belongs here is a judgement call. The file is not a shipped input, so committing it never fires the publisher.

Also included. version.json floor to 1.9 with README and HISTORY release notes, and removal of the abandoned template-lineage references from AGENTS.md and .github/copilot-instructions.md.

Verification

Executed, not inspected:

  • All four fixtures compile cold in 318s; the Bluetooth proxy alone in 200s.
  • The change-gate was exercised against real git history: 9/9 cases correct, including fail-open on a new branch, force-push, dispatch, and empty before-commit.
  • esphome config caught a genuine defect in a fixture during development (api requires a network component), which is why it runs as a distinct step before compile.
  • Full lint gate green: actionlint, editorconfig-checker, markdownlint, cspell.

Notes for review

  • WORKFLOW.md gains D11 plus scenarios S13-S17 and the matching 5A audit rows.
  • .editorconfig has a one-word comment change ("every derived repo" -> "every repo"). It is a converged file, so the same edit is needed in the other repos to avoid drift.

ESPHome's ESP-IDF toolchain installer validates the openocd-esp32 tool by
executing it, and that binary dynamically links libusb-1.0.so.0, which the final
image did not carry, so every ESP-IDF build failed. Add libusb-1.0-0, plus
ccache, which ESPHome enables automatically whenever the binary is on PATH.

A build-only smoke cannot see this class of break: the toolchains that link
against the missing library are downloaded on first compile, so nothing fails
until firmware is actually built. Add a compile-test job to the validation gate
that builds the image and compiles checked-in configurations inside it as a
non-root user, covering the Xtensa ESP-IDF, RISC-V ESP-IDF, wired Ethernet, and
PlatformIO build paths. The publisher always runs it, so a firmware break blocks
the push and the release; push CI runs it only when an inline change-gate sees
the image or the upstream pin move, so the tracker's daily bump is verified
before it auto-merges.

Add a daily upstream-dependency watcher that snapshots the package list
ESPHome's own base image installs and opens a review pull request when that list
changes, so the next dependency addition is caught before a user reports it.
Copilot AI review requested due to automatic review settings July 18, 2026 18:00
ptr727 added 2 commits July 18, 2026 11:01
validate-task was lint-only and needed no secrets, so neither caller inherited
them. Its compile-test job logs in to Docker Hub for higher pull and cache-read
limits, which failed the gate on the first run.
Diffing only the push let a later docs-only commit skip the compile test on a
branch that had already changed the image, so a pull request could pass its gate
without ever compiling its own change. Diff a feature branch against its
merge-base with develop instead; main and develop keep push-diff semantics,
which is what catches the change after a squash-merge.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes ESP-IDF firmware compile failures in the published Docker image by adding required runtime packages, and strengthens the release gate by compiling real firmware configs inside the built image before pushing/publishing. It also adds an automated watcher to track upstream base-image apt package changes and bumps the repo version/doc release notes to 1.9.

Changes:

  • Add libusb-1.0-0 (for openocd-esp32 validation) and ccache to the runtime image.
  • Add an opt-in compile-test job to the validation gate, enabled for publishing and change-gated on CI pushes.
  • Add a daily upstream dependency snapshot workflow and introduce upstream-dependency.json as a review signal.

Reviewed changes

Copilot reviewed 18 out of 18 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
WORKFLOW.md Documents the new compile-test gate and upstream dependency watcher; updates CI/publish contract text and diagrams.
version.json Bumps version floor from 1.8 to 1.9.
upstream-dependency.json Introduces the tracked snapshot of upstream base-image apt package names.
README.md Updates release notes to 1.9 and refreshes related links.
HISTORY.md Adds 1.9 release notes and supporting link references.
Docker/Dockerfile Adds libusb-1.0-0 and ccache to final-stage runtime dependencies.
cspell.json Adds new domain words (libusb, openocd, Xtensa) to spelling allowlist.
AGENTS.md Updates repo structure docs and removes template-lineage wording in favor of shared-contract phrasing.
.github/workflows/validate-task.yml Adds reusable, opt-in compile-test job (build image + run esphome config/compile in-container).
.github/workflows/test-pull-request.yml Adds a change-detection job to gate whether compile-test runs on push CI.
.github/workflows/check-upstream-dependency.yml Adds daily workflow to snapshot upstream base-image apt package names and open a PR when they change.
.github/workflows/build-release-task.yml Ensures publishing runs validation with compile-test enabled.
.github/copilot-instructions.md Updates shared-contract guidance wording.
.github/compile-test/esp8266-d1-mini.yaml Adds PlatformIO/Arduino fixture for compile testing.
.github/compile-test/esp32c6-bluetooth-proxy.yaml Adds RISC-V ESP-IDF fixture for compile testing.
.github/compile-test/esp32-ethernet.yaml Adds Ethernet (LAN8720) ESP-IDF fixture for compile testing.
.github/compile-test/esp32-bluetooth-proxy.yaml Adds Xtensa ESP-IDF + BLE fixture for compile testing.
.editorconfig Minor comment wording tweak in the shared config section.

Comment thread .github/workflows/test-pull-request.yml Resolved
Comment thread WORKFLOW.md Resolved
Comment thread WORKFLOW.md Resolved
Comment thread WORKFLOW.md Resolved
Copilot AI review requested due to automatic review settings July 18, 2026 18:04

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 18 out of 18 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (1)

WORKFLOW.md:663

  • The scenario table numbering is out of order (S17 appears before S16 and S15), which makes it harder to scan and reference scenarios consistently.
| S17 | the tracker opens an upstream pin bump PR that breaks compiles | the change-gate sees `upstream-version.json`, the compile test runs and fails, the required check blocks auto-merge before the pin reaches `main` | D1.1, D8.3, D11.1 |
| S16 | a runtime dependency is missing for RISC-V but not Xtensa | the Xtensa fixtures pass and `esp32c6-bluetooth-proxy.yaml` fails, isolating it to that toolchain | D11.3 |
| S15 | an ESPHome release changes a schema a fixture uses | `esphome config` fails before `esphome compile`, naming the fixture to update | D11.2 |

Copilot AI review requested due to automatic review settings July 18, 2026 18:33

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 18 out of 18 changed files in this pull request and generated 1 comment.

Comment thread WORKFLOW.md Resolved
Copilot AI review requested due to automatic review settings July 18, 2026 18:40

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 18 out of 18 changed files in this pull request and generated 1 comment.

Copilot AI review requested due to automatic review settings July 18, 2026 18:51

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 18 out of 18 changed files in this pull request and generated no new comments.

@ptr727
ptr727 merged commit 10f6404 into develop Jul 18, 2026
12 checks passed
@ptr727
ptr727 deleted the feature/espidf-runtime-dependencies branch July 18, 2026 19:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants