[PR #5630] [MERGED] ci: shard the browser matrix, cache browsers, and gate unaffected PRs #6857

Closed
opened 2026-10-23 04:14:21 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/5630
Author: @kolacheee
Created: 8/29/2026
Status: ✅ Merged
Merged: 8/29/2026
Merged by: @kolacheee

Base: staging ← Head: feat/5622-fast-browser-matrix


📝 Commits (1)

  • 29867f3 ci: shard the browser matrix, cache browsers, and gate unaffected PRs

📊 Changes

2 files changed (+310 additions, -24 deletions)

View changed files

➕ .github/actions/playwright-shard/action.yml (+68 -0)
📝 .github/workflows/playwright.yml (+242 -24)

📄 Description

Closes #5622 — items 1–4. The smoke-subset policy variant is deliberately not included, per maintainer decision.

What changed

playwright.yml is restructured around a shared composite action (.github/actions/playwright-shard); the node lane is untouched.

1. Sharding (the big one). Each browser lane now runs as 3 parallel shard jobs (--shard=k/3), taking wall time from 15–21 min toward the length of one third of the suite. One discovery en route: with the config's fullyParallel: false, Playwright's shard unit is the file — and this suite is one 19,800-line file, so plain --shard put all 197 tests in shard 1 and zero elsewhere. The fix is --fully-parallel --workers=1 on the CI invocation only: --fully-parallel changes just the sharding granularity to individual tests, while --workers=1 keeps execution inside each shard strictly serial in file order — the no-concurrent-tests-against-one-server property that fullyParallel: false exists to protect. Each shard job is its own runner booting its own servers with a fresh data dir. Distribution verified: 66/66/65.

2. "Build once" — implemented as its honest version. The issue's premise that each job rebuilds the app turned out to overstate: the Playwright webServer builds only the shared package (~40s) and then runs dev servers; the client is never production-built in this workflow. A serial prebuild job would add more gate latency than nine parallel 40-second shared builds cost, so there is no artifact hand-off — the per-job work that actually dominated (browser downloads, suite runtime) is what items 1 and 3 remove. Prebuilding the client for tests would mean testing vite preview instead of the dev server the suite was written against — out of scope.

3. Playwright browser cache. ~/.cache/ms-playwright, keyed on OS + browser + the installed @playwright/test version. On a hit, playwright install skips the download (the WebKit bundle is the chunky one); --with-deps' OS packages still install, as they must.

4. Skip gate for unaffected PRs. A fast browser-lane-gate job diffs the PR's merge commit against its first parent (exactly the PR's change set) and skips the shard jobs when every changed file matches the narrow skip list: docs/**, **/*.md, .gitattributes, win/**, android/**, scripts/regressions/** — files the running app can never load. Anything else (server, client, e2e, workflows, lockfile, launcher scripts) runs the lanes; so does any push, workflow_dispatch, or a diff the gate can't determine (conservative fallback). This is an in-workflow gate, not a workflow-level paths: filter, for the required-checks reason documented in the issue.

Branch-protection compatibility: the shard jobs have new names (desktop-chromium 1/3, …), but three fan-in jobs carry the exact pre-existing check names — desktop-chromium, mobile-chromium, mobile-webkit. Each passes when its shards all passed, passes with a "skipped: cannot affect the browser lanes" note when the gate proved it, and fails otherwise — including when the gate job itself fails, so a broken gate can never green the matrix.

The honest risk, and how it was validated

Mid-file shards start against a fresh server with none of the earlier tests' accumulated state, so any test that silently depended on a predecessor's side effects would fail in shards 2/3. All three desktop-chromium shards were run locally from cold starts: shard 2 — 64/64 passed, shard 3 — 54/54 passed (remainder skipped by project gates), shard 1 — 63 passed with one failure of the pre-existing "Echo Chamber size persistence" pixel-tolerance flake, which passes 3/3 solo — an independent intermittent, not order coupling (worth its own #5618-style look if it recurs in CI). Two earlier local shard-2 runs failed en masse with ECONNREFUSED — that turned out to be this Windows machine's known consecutive-run server-startup artifact, not the sharding (the clean re-runs above are decisive). The mobile lanes run the same single file with the same ordering profile, and this PR's own CI run exercises all nine shard jobs end-to-end on the runners that matter.

Validation done

  • YAML parse-validated; gate pattern logic unit-tested against 10 change-set shapes (docs-only/installer/regressions-only skip; server/client/e2e/workflow/lockfile/launcher run)
  • Shard distribution verified 66/66/65 per project
  • All 3 desktop-chromium shards run locally to completion
  • This PR's CI run is itself the end-to-end proof: it exercises the gate (this PR touches workflows → lanes run), all nine shards, the cache (cold then warm on re-run), and the fan-ins

Manually verify

  • Confirm the fan-in checks (desktop-chromium, mobile-chromium, mobile-webkit) appear on this PR and match whatever branch protection requires
  • After merge, open a docs-only PR and confirm the shard jobs skip while the fan-ins report green with the skip note
  • Compare wall time of this PR's matrix against a recent pre-change run
  • Re-run a lane once to confirm the browser cache hits (the install step should skip the download)

Summary by CodeRabbit

  • New Features
    • Added parallelized browser testing across multiple shards for faster validation.
    • Added automatic browser setup, caching, and failure-evidence uploads.
    • Added change detection to skip browser checks for documentation-only and other non-impacting changes.
    • Preserved clear browser check results through consolidated success or failure reporting.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Engine/pull/5630 **Author:** [@kolacheee](https://github.com/kolacheee) **Created:** 8/29/2026 **Status:** ✅ Merged **Merged:** 8/29/2026 **Merged by:** [@kolacheee](https://github.com/kolacheee) **Base:** `staging` ← **Head:** `feat/5622-fast-browser-matrix` --- ### 📝 Commits (1) - [`29867f3`](https://github.com/Pasta-Devs/Marinara-Engine/commit/29867f360968263609fcf99ff7a0b2d26133febb) ci: shard the browser matrix, cache browsers, and gate unaffected PRs ### 📊 Changes **2 files changed** (+310 additions, -24 deletions) <details> <summary>View changed files</summary> ➕ `.github/actions/playwright-shard/action.yml` (+68 -0) 📝 `.github/workflows/playwright.yml` (+242 -24) </details> ### 📄 Description Closes #5622 — items 1–4. The smoke-subset policy variant is deliberately **not** included, per maintainer decision. ## What changed `playwright.yml` is restructured around a shared composite action (`.github/actions/playwright-shard`); the node lane is untouched. **1. Sharding (the big one).** Each browser lane now runs as 3 parallel shard jobs (`--shard=k/3`), taking wall time from 15–21 min toward the length of one third of the suite. One discovery en route: with the config's `fullyParallel: false`, Playwright's shard unit is the *file* — and this suite is one 19,800-line file, so plain `--shard` put all 197 tests in shard 1 and zero elsewhere. The fix is `--fully-parallel --workers=1` on the CI invocation only: `--fully-parallel` changes just the sharding granularity to individual tests, while `--workers=1` keeps execution inside each shard strictly serial in file order — the no-concurrent-tests-against-one-server property that `fullyParallel: false` exists to protect. Each shard job is its own runner booting its own servers with a fresh data dir. Distribution verified: 66/66/65. **2. "Build once" — implemented as its honest version.** The issue's premise that each job rebuilds the app turned out to overstate: the Playwright webServer builds only the shared package (~40s) and then runs *dev* servers; the client is never production-built in this workflow. A serial prebuild job would add more gate latency than nine parallel 40-second shared builds cost, so there is no artifact hand-off — the per-job work that actually dominated (browser downloads, suite runtime) is what items 1 and 3 remove. Prebuilding the client for tests would mean testing `vite preview` instead of the dev server the suite was written against — out of scope. **3. Playwright browser cache.** `~/.cache/ms-playwright`, keyed on OS + browser + the installed `@playwright/test` version. On a hit, `playwright install` skips the download (the WebKit bundle is the chunky one); `--with-deps`' OS packages still install, as they must. **4. Skip gate for unaffected PRs.** A fast `browser-lane-gate` job diffs the PR's merge commit against its first parent (exactly the PR's change set) and skips the shard jobs when **every** changed file matches the narrow skip list: `docs/**`, `**/*.md`, `.gitattributes`, `win/**`, `android/**`, `scripts/regressions/**` — files the running app can never load. Anything else (server, client, e2e, workflows, lockfile, launcher scripts) runs the lanes; so does any push, `workflow_dispatch`, or a diff the gate can't determine (conservative fallback). This is an in-workflow gate, **not** a workflow-level `paths:` filter, for the required-checks reason documented in the issue. **Branch-protection compatibility:** the shard jobs have new names (`desktop-chromium 1/3`, …), but three fan-in jobs carry the exact pre-existing check names — `desktop-chromium`, `mobile-chromium`, `mobile-webkit`. Each passes when its shards all passed, passes with a "skipped: cannot affect the browser lanes" note when the gate proved it, and fails otherwise — including when the gate job itself fails, so a broken gate can never green the matrix. ## The honest risk, and how it was validated Mid-file shards start against a fresh server with none of the earlier tests' accumulated state, so any test that silently depended on a predecessor's side effects would fail in shards 2/3. All three desktop-chromium shards were run locally from cold starts: **shard 2 — 64/64 passed, shard 3 — 54/54 passed** (remainder skipped by project gates), **shard 1 — 63 passed with one failure of the pre-existing "Echo Chamber size persistence" pixel-tolerance flake, which passes 3/3 solo** — an independent intermittent, not order coupling (worth its own #5618-style look if it recurs in CI). Two earlier local shard-2 runs failed en masse with `ECONNREFUSED` — that turned out to be this Windows machine's known consecutive-run server-startup artifact, not the sharding (the clean re-runs above are decisive). The mobile lanes run the same single file with the same ordering profile, and this PR's own CI run exercises all nine shard jobs end-to-end on the runners that matter. ## Validation done - YAML parse-validated; gate pattern logic unit-tested against 10 change-set shapes (docs-only/installer/regressions-only skip; server/client/e2e/workflow/lockfile/launcher run) - Shard distribution verified 66/66/65 per project - All 3 desktop-chromium shards run locally to completion - This PR's CI run is itself the end-to-end proof: it exercises the gate (this PR touches workflows → lanes run), all nine shards, the cache (cold then warm on re-run), and the fan-ins ## Manually verify - [ ] Confirm the fan-in checks (`desktop-chromium`, `mobile-chromium`, `mobile-webkit`) appear on this PR and match whatever branch protection requires - [ ] After merge, open a docs-only PR and confirm the shard jobs skip while the fan-ins report green with the skip note - [ ] Compare wall time of this PR's matrix against a recent pre-change run - [ ] Re-run a lane once to confirm the browser cache hits (the install step should skip the download) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added parallelized browser testing across multiple shards for faster validation. * Added automatic browser setup, caching, and failure-evidence uploads. * Added change detection to skip browser checks for documentation-only and other non-impacting changes. * Preserved clear browser check results through consolidated success or failure reporting. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-23 04:14:21 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#6857
No description provided.