Skip to content

Initialize the cache in the compile test the way a real run does - #167

Merged
ptr727 merged 1 commit into
developfrom
feature/compile-test-cache-init
Jul 18, 2026
Merged

ptr727 merged 1 commit into
developfrom
feature/compile-test-cache-init

Conversation

@ptr727

@ptr727 ptr727 commented Jul 18, 2026

Copy link
Copy Markdown
Owner

Why

The compile test runs bash /config/compile.sh, which takes the image entrypoint's exec "$@" branch, so entrypoint/cache.sh never runs and /cache/{pio,build,data,pip,home} are never created - including HOME.

Raised by the Copilot review on promotion #163.

What the review predicted, and what actually happens

The review expected the run to fail on a fresh cache mount. It does not, and that was checked rather than assumed: with a genuinely empty /cache, HOME=/cache/home and /cache/build do not exist and esphome config still succeeds. Every compile run so far, local and in CI, started from an empty cache and passed. The tools create their own trees because the mount is world-writable.

So the predicted failure is not real. The underlying observation is, and the change is worth making for three other reasons:

  1. Fidelity. The test should initialize the cache the way a container start does, rather than exercising a path no user takes.
  2. It removes an incidental dependency. "It works because every tool happens to create its own directories" is true today and guaranteed by nothing.
  3. Coverage. entrypoint/cache.sh is currently exercised by no test at all. This puts it under one.

Verification

  • cache.sh runs cleanly as uid 1000 and creates all five directories.
  • The modified step was extracted from the workflow and run end to end: Creating cache directories / Clearing temporary files / Pruning PIO cache all execute, then the fixture compiles. Real exit code 0.
  • Full lint gate green: actionlint, editorconfig-checker, markdownlint, cspell.

Note

Blocks promotion #163, which picks this up once merged.

Passing a command bypasses the image entrypoint, so cache.sh never ran and the
compile relied on each tool creating its own tree under the world-writable
mount. That works today but is incidental, tests a path no user takes, and left
cache.sh exercised by nothing.
Copilot AI review requested due to automatic review settings July 18, 2026 22:02

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 improves the fidelity of the compile-test workflow by initializing /cache the same way a real container start does, ensuring the cache directory layout (including HOME=/cache/home) is created and that the cache-initialization script is exercised during CI.

Changes:

  • Run /entrypoint/cache.sh at the start of the compile-test script before validating/compiling the fixture configs.
  • Document the rationale and behavior change in WORKFLOW.md (cache init + coverage of entrypoint/cache.sh).

Reviewed changes

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

File Description
WORKFLOW.md Updates the compile-test documentation to describe cache initialization via /entrypoint/cache.sh and the added coverage.
.github/workflows/validate-task.yml Adds a pre-step in the generated compile.sh to run /entrypoint/cache.sh before running esphome config/esphome compile.

@ptr727
ptr727 merged commit bd6eb43 into develop Jul 18, 2026
12 checks passed
@ptr727
ptr727 deleted the feature/compile-test-cache-init branch July 18, 2026 22:10
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