ci: shard the CKEditor suite so coverage data cannot exhaust the browser

Two runs of this branch died at the same point: 100 of 121 spec files
completed, then the browser session either dropped mid-run or stopped
responding until the step timed out. Chromedriver and Chrome are
correctly paired (150.0.7871.124 / .128), and the DOM is clean at the
end of every file — no editors, math fields, balloons or previews are
left behind, so the tests themselves are not leaking.

What accumulates is v8 coverage data. Browser mode keeps one page for
the whole run, and coverage collects for every script loaded into it.
Measured locally over the same file order:

  file    without --coverage    with --coverage
     20             218 MB              235 MB
     60             291 MB              498 MB
    100             236 MB              847 MB
    106                  -              873 MB  (peak)

Without coverage the heap sawtooths and GC keeps up. With it, the heap
climbs to ~3.6x by the 100th file — exactly where CI gives out. Locally
there is enough headroom to survive it; a runner has less.

Run the suite as two shards of ~60 files, which peaks around 500MB, and
merge the blob reports afterwards. Thresholds are zeroed for the shard
runs (each only exercises half the tree, so they would fail on files the
other shard covers) and enforced on the merged report, which reproduces
the single-run numbers exactly and still writes the JUnit file Codecov
uploads.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Elian Doran 2026-08-01 20:36:12 +03:00
parent 591745e043
commit e256260ff4
No known key found for this signature in database
2 changed files with 13 additions and 1 deletions

View File

@ -147,7 +147,18 @@ jobs:
"$CHROMEDRIVER_PATH" --version || echo "could not read the chromedriver version"
(google-chrome --version || chromium --version || chromium-browser --version) 2>/dev/null \
|| echo "could not read the Chrome version"
pnpm run --filter=ckeditor5 test --coverage
# Browser mode keeps one page for the whole run, and v8 coverage data accumulates in it:
# measured locally, the heap reaches ~850MB by the 100th spec file with --coverage against
# ~240MB without it. That is where a CI runner's renderer gives out — the session either
# drops mid-run or stops responding. Run the suite in two shards (~60 files each, peaking
# around 500MB) and merge the blob reports afterwards, so the 100% gate is still evaluated
# over the whole suite rather than per shard.
SHARD_ARGS="--reporter=blob --coverage \
--coverage.thresholds.lines=0 --coverage.thresholds.functions=0 \
--coverage.thresholds.branches=0 --coverage.thresholds.statements=0"
pnpm run --filter=ckeditor5 test --shard=1/2 $SHARD_ARGS
pnpm run --filter=ckeditor5 test --shard=2/2 $SHARD_ARGS
pnpm run --filter=ckeditor5 test --mergeReports --coverage
- name: Upload ckeditor5 coverage to Codecov
uses: codecov/codecov-action@v7

1
.gitignore vendored
View File

@ -37,6 +37,7 @@ Thumbs.db
vite.config.*.timestamp*
vitest.config.*.timestamp*
test-output
.vitest-reports
__screenshots__
.vitest-attachments