Skip to content

fix(warmup): weave the enumerated files in path order - #805

Merged
lisachenko merged 2 commits into
masterfrom
feature/elegant-maxwell-fhb92u
Nov 5, 2026
Merged

lisachenko merged 2 commits into
masterfrom
feature/elegant-maxwell-fhb92u

Conversation

@lisachenko

@lisachenko lisachenko commented Nov 5, 2026 •

Copy link
Copy Markdown
Member

What and why

Fixes the flaky CacheWarmerTest::testFailFastStopsAfterFirstError, reported in #788 (comment) (it failed the coverage job there with Total processed 2, 1 errors instead of 1).

Cause: in-process warm-up wove files in the order the file system lists them, which is not sorted (on ext4 it follows a per-file-system name hash, so it differs between CI runners). The test has the valid src/Some.php from setUp() plus Broken.php and AlsoBroken.php. When Some.php was listed first, the warmer processed it, failed on the next file and stopped, so it reported 2 processed files.

Fix: CacheWarmer::weaveApplication() sorts the collected files by path. Every run now weaves them in the same order on any machine, and fail-fast stops on the same file. The worker pool still orders by size; usort is stable, so files of the same size stay in path order. The test keeps all three files and asserts that AlsoBroken.php stopped the warm-up and Broken.php was never processed.

Verification:

  • Reproduced the CI failure locally by renaming the valid file to a name this file system lists first (OSome.php): the test fails against the old warmer and passes with the sort.
  • The fixed test passes 20 runs out of 20; all 14 tests in CacheWarmerTest pass; php-cs-fixer reports nothing on the changed files.

Checklist

  • The title follows Conventional Commits (type(scope): summary)
  • Tests cover the change
  • composer check passes — not run in full: PHPStan couldn't be downloaded in the sandbox, and 56 functional tests crash there with a segfault (signal 11) in child PHP processes, with and without this change; left to CI
  • User-facing or breaking changes are in CHANGELOG.md — not added: warm-up order is not user-facing; happy to add a line if you want one

🤖 Generated with Claude Code

https://claude.ai/code/session_01FxhC1F17fBJcmZzT44WKzi

…dependent

In-process warm-up walks the files in the order the file system lists them,
which is not sorted. With the valid src/Some.php from setUp() next to the two
broken files, a listing that put Some.php first made the warmer process it,
fail on the next file and stop: "Total processed 2" instead of 1. That is what
failed the coverage job in #788.

The test now removes the valid file, so only the two broken files remain and
the warmer processes exactly one of them, whichever is listed first. It also
asserts that only one file failed, i.e. the second broken file was skipped.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FxhC1F17fBJcmZzT44WKzi
@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 98.54%. Comparing base (d3078d1) to head (8653fb9).
⚠️ Report is 26 commits behind head on master.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@             Coverage Diff              @@
##             master     #805      +/-   ##
============================================
+ Coverage     98.49%   98.54%   +0.05%     
- Complexity     2090     2115      +25     
============================================
  Files           127      127              
  Lines          5441     5500      +59     
============================================
+ Hits           5359     5420      +61     
+ Misses           82       80       -2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

The file system lists a directory in any order, which differs between
machines, so in-process warm-up wove the files in a different order on each
CI runner. With fail-fast it then stopped on a different file:
CacheWarmerTest::testFailFastStopsAfterFirstError reported "Total processed 2"
whenever the valid Some.php was listed before the broken files.

The warmer now sorts the collected files by path, so every run weaves them in
the same order and fail-fast stops on the same file. The worker pool keeps
ordering by size; its sort is stable, so files of the same size stay in path
order.

The test keeps all three files (the previous commit removed the valid one)
and asserts which file stopped the warm-up.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FxhC1F17fBJcmZzT44WKzi
@lisachenko lisachenko changed the title test(warmup): make fail-fast test independent of file listing order fix(warmup): weave the enumerated files in path order Nov 5, 2026
@lisachenko
lisachenko marked this pull request as ready for review November 5, 2026 10:30
@lisachenko
lisachenko merged commit 4ee4842 into master Nov 5, 2026
14 checks passed
@lisachenko
lisachenko deleted the feature/elegant-maxwell-fhb92u branch November 5, 2026 10:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants