Skip to content

ci: cache Playwright browsers for pull request browser tests - #343387

Merged
Bryan Chen (bryanchen-d) merged 4 commits into
mainfrom
copilot/vscode/gh-playwright-cache
Nov 2, 2026
Merged

Bryan Chen (bryanchen-d) merged 4 commits into
mainfrom
copilot/vscode/gh-playwright-cache

Conversation

@bryanchen-d

@bryanchen-d Bryan Chen (bryanchen-d) commented Oct 22, 2026 •

Copy link
Copy Markdown
Collaborator

Caches Playwright's browsers for the GitHub browser-test jobs, so a CDN incident no longer fails them. This is the GitHub half of B11. An ADO PR follows once #343325 lands.

Why

Over the last 14 days, out of 15,508 GitHub workflow runs, 4 jobs failed only in a Playwright browser-download step. That's 2 in component-fixtures today with ERR_TLS_CERT_ALTNAME_INVALID from cdn.playwright.dev, 1 in monaco-editor today, and 1 in pr.yml (macOS) on Oct 13. The existing 3-attempt retry loops can't outlast a CDN problem that lasts minutes.

What

  • New .github/actions/restore-playwright, modeled on restore-wsl-installer.
    • It sets PLAYWRIGHT_BROWSERS_PATH to .build/ms-playwright for the rest of the job.
    • It restores that directory from a cache keyed on runner.os, runner.arch, the pinned playwright version from package-lock.json, and the install arguments.
    • With save-cache: 'true', it downloads the browsers with npx playwright@<version> install … on a miss and saves them, the same way the other warm-on-main caches work.
  • pr-{linux,darwin,win32}-test.yml restore it right before the existing install step, which is unchanged. On a hit, playwright install finds the browsers and downloads nothing. On a miss, it downloads exactly as today, retry loop included.
  • pr-node-modules.yml warms the cache on main in the Linux, macOS and Windows jobs. The step is continue-on-error, like the WSL one. detect-missing-caches computes these keys, and detectMissingCaches.test.ts checks that the jobs, keys, versions and the action stay in sync.
  • component-fixtures.yml restores in both jobs. It saves on pushes to main, where that workflow already runs. The fixture-tests job uses its own test/componentFixtures/playwright/package-lock.json.
  • monaco-editor.yml is left out. It runs only on pull requests and installs every browser, and it had one hit in 14 days.

Validation

  • node --test build/lib/test/detectMissingCaches.test.ts passes 4/4 with the new cache.
  • I ran the action's prepare script locally against both lockfiles. It resolves 1.61.1 and sets keys such as playwright-v1-macOS-ARM64-1.61.1-only-shell-chromium-webkit.
  • All touched YAML parses, eslint is clean, and tsc -p build reports nothing in the touched files.
  • Cold and warm, on this PR: a temporary commit makes the Linux job save the cache, so one run populates it (cold) and the next restores it (warm). That commit will be dropped before review. Evidence will be posted here.

Overlap with in-flight CI changes (rebased Nov 2, on pnpm)

Authored with Copilot

Copilot AI balanced review requested due to automatic review settings October 22, 2026 00:04
@bryanchen-d
Bryan Chen (bryanchen-d) force-pushed the copilot/vscode/gh-playwright-cache branch from b731e36 to f324fcf Compare October 22, 2026 00:17

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Copilot review overview

2 open issues
What changed in this PR

Adds a reusable GitHub composite action to cache Playwright browser binaries and wires it into PR browser-test workflows plus main-branch cache warming, reducing failures due to intermittent Playwright CDN download issues.

Changes:

  • Introduces .github/actions/restore-playwright to restore/download/cache Playwright browsers under .build/ms-playwright and set PLAYWRIGHT_BROWSERS_PATH.
  • Updates PR test workflows and cache-warming workflows to restore/warm the Playwright browser cache.
  • Extends detect-missing-caches logic/tests and updates documentation to account for the new Playwright cache.
File Description
build/​lib/​test/​detectMissingCaches.test.ts Updates cache-detection tests to include the new Playwright cache and runner.arch handling.
.github/​workflows/​pr-win32-test.yml Restores Playwright browsers cache before installing browsers on Windows PR tests.
.github/​workflows/​pr-node-modules.yml Warms Playwright browsers cache on main for Linux/macOS/Windows.
.github/​workflows/​pr-linux-test.yml Restores Playwright browsers cache before installing browsers on Linux PR tests.
.github/​workflows/​pr-darwin-test.yml Restores Playwright browsers cache before installing browsers on macOS PR tests.
.github/​workflows/​node_modules_cache/​README.md Documents that Playwright browsers are now part of the warmed caches.
.github/​workflows/​component-fixtures.yml Restores/saves Playwright browsers cache for component fixtures workflows.
.github/​actions/​restore-playwright/​action.yml New composite action that prepares env, restores cache, downloads on miss (optional), and saves cache.
.github/​actions/​detect-missing-caches/​detect.ts Adds Playwright cache key computation to the cache-warming detection logic.

Review effort: Lite

@bryanchen-d

Copy link
Copy Markdown
Collaborator Author

Cold and warm evidence on this PR, from Linux (unit) / Browser:

  • Cold, job 119558216391, on the temporary commit that saved from this PR: Cache not found for input keys: playwright-v1-Linux-X64-1.61.1-only-shell-chromium. It downloaded Chrome Headless Shell into .build/ms-playwright in about 5 s, and the cache (108 MB) was saved under this PR's ref. The existing install step then reported Install successful on attempt 1 in about 1 s without downloading, and Run unit tests (Browser, Chromium) passed.
  • Warm, job 119563321514, after dropping the temporary commit: Cache hit for: playwright-v1-Linux-X64-1.61.1-only-shell-chromium, restored in about 1 s. Install Playwright Chromium took 2 s with no Downloading lines, and the browser unit tests passed with PLAYWRIGHT_BROWSERS_PATH=…/.build/ms-playwright.

The temporary commit is gone from the branch. Both Copilot threads are addressed: the restore no longer depends on save-cache (fixed in 6086173), and the cache action pins match the repo's existing actions.

Co-authored with Copilot

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@bryanchen-d

Copy link
Copy Markdown
Collaborator Author

Heads-up on file overlap, with no action needed now. Logan Ramos (@lramos15)'s sharding drafts (#343812 to #343816) and Michael Lively (@Yoyokrazy)'s #343094 also edit pr-node-modules.yml, pr-{linux,darwin,win32}-test.yml and detect-missing-caches/detect.ts. None of them changes Playwright installs or caching, so they don't duplicate this PR. Whichever PR lands second will need a rebase. If a sharded or new-runner job runs playwright-install, it should also call ./.github/actions/restore-playwright. And if the runner OS or arch labels change, the playwright-v1-* warm step in pr-node-modules.yml and detect.ts need to keep their keys in sync. detectMissingCaches.test.ts will catch a key mismatch.

Co-authored with Copilot

@bryanchen-d

Copy link
Copy Markdown
Collaborator Author

Heads-up on overlap with Alexandru Dima (@alexdima)'s draft #344218 ("ci: report the PR test checks as <OS> / <job>"). The two PRs merge without textual conflicts (git merge-tree is clean), but they don't fit together semantically.

  • This PR's three Restore Playwright browsers steps (pr-{darwin,linux,win32}-test.yml) use if: ${{ inputs.browser_tests }}.
  • ci: report the PR test checks as "<OS> / <job>" #344218 removes the browser_tests workflow input and changes the matching Install Playwright … steps to if: ${{ env.BROWSER_TESTS == 'true' }}.

If both land as they are, inputs.browser_tests would be undefined, so the restore step would silently stop running, and the browser jobs would go back to downloading from the Playwright CDN. Whichever PR lands second should give the restore steps the same condition as the install steps right after them. I'll update this PR if #344218 merges first.

Co-authored with Copilot

@bryanchen-d

Copy link
Copy Markdown
Collaborator Author

I've temporarily stacked this PR on Ladislau Szomoru (@lszomoru)'s #344400 (head ea07b750db), which has auto-merge on and is likely to land first. Until #344400 merges, this PR's diff includes its changes too.

  • ci: report the PR test checks as "<OS> / <job>" #344400 removes the browser_tests workflow input. Without a change here, the three Restore Playwright browsers steps would silently stop running. The new commit d1ced1a5a2 gates them on env.BROWSER_TESTS == 'true', the same condition as the Install Playwright … step that follows each one.
  • I also resolved a separate conflict with main in detectMissingCaches.test.ts (the Windows runner moved to vscode-large-runners-windows-8-core and electronCachePath was added). detectMissingCaches.test.ts passes 5/5, and detectChanges with agentHostTestSelection passes 23/23.

Once #344400 merges, I'll rebase onto main so only this PR's commits remain, and then request a fresh Copilot review.

Co-authored with Copilot

@bryanchen-d
Bryan Chen (bryanchen-d) force-pushed the copilot/vscode/gh-playwright-cache branch 2 times, most recently from d1ced1a to 6eae9d4 Compare October 26, 2026 21:32
@bryanchen-d
Bryan Chen (bryanchen-d) requested a balanced review from Copilot October 26, 2026 21:32

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

Cold/warm GitHub Actions evidence is still needed across Linux, macOS, and Windows to confirm restored caches eliminate browser downloads.

No open issues 🎉

Review effort: Balanced

@bryanchen-d

Copy link
Copy Markdown
Collaborator Author

Ladislau Szomoru (@lszomoru), since you own the GitHub Actions PR workflows: this PR caches Playwright browsers in PR CI, so the browser jobs stop depending on the Playwright CDN. It adds a restore-playwright action before each Install Playwright … step in pr-{darwin,linux,win32}-test.yml and component-fixtures.yml, warms the cache on main in pr-node-modules.yml, and keeps detect-missing-caches in sync. After your #344400 it's gated on env.BROWSER_TESTS == 'true', like the install steps. I checked that the restore runs in all 6 browser jobs.

Co-authored with Copilot

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues are reported for the Playwright browser-cache changes.

No open issues 🎉

Review effort: Balanced

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues were identified for the Playwright browser-caching changes.

No open issues 🎉

Review effort: Balanced

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The Playwright browser-caching changes have no active review issues.

No open issues 🎉

Review effort: Balanced

Browser tests download Playwright's browsers from its CDN on every run.
In the last 14 days 4 GitHub jobs failed only because that download did:
`ERR_TLS_CERT_ALTNAME_INVALID` from `cdn.playwright.dev` and DNS misses
on its mirror.

Add `.github/actions/restore-playwright`, modeled on
`restore-wsl-installer`. It points PLAYWRIGHT_BROWSERS_PATH at
`.build/ms-playwright` and restores the browsers of the pinned Playwright
version from a cache keyed on OS, arch, version and the install
arguments. The existing install steps stay unchanged: on a hit they find
the browsers and download nothing, on a miss they download as before.

`pr-node-modules.yml` warms the caches on main for the Linux, macOS and
Windows jobs, and `detect-missing-caches` computes their keys.
`component-fixtures.yml` saves its own cache on pushes to main.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Component fixture runs on main save the cache and then install the browsers, so they need a restore on a hit instead of a lookup.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The PR test workflows now pick the test runner through job-level env (BROWSER_TESTS) rather than the browser_tests input, so restore the browsers under the same condition as the Install Playwright step that uses them.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The pnpm migration (#344791) removed the root package-lock.json. Read the version of the root @playwright/test dependency from the pnpm-lock.yaml importer instead, in both the restore action and the missing-cache detection, so their cache keys still match.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues are reported for the shared Playwright browser-cache changes.

No open issues 🎉

Review effort: Balanced

@bryanchen-d
Bryan Chen (bryanchen-d) marked this pull request as ready for review November 2, 2026 18:23
@bryanchen-d
Bryan Chen (bryanchen-d) enabled auto-merge (squash) November 2, 2026 18:23
@bryanchen-d
Bryan Chen (bryanchen-d) merged commit 135e3a1 into main Nov 2, 2026
56 checks passed
@bryanchen-d
Bryan Chen (bryanchen-d) deleted the copilot/vscode/gh-playwright-cache branch November 2, 2026 21:22
@vs-code-engineering vs-code-engineering Bot added this to the 1.146.0 milestone Nov 2, 2026
Ladislau Szomoru (lszomoru) added a commit that referenced this pull request Nov 4, 2026
…s caches

#345839 moved the native build targets from the .npmrc files to the
nativeBuild field of package.json, so a job now compares the inputs of
computeNodeModulesBaseCacheKey (#345840) between its commit and the commit
of a workspace image: the salt, the pnpmfiles, the Node.js versions, the
pnpm settings of every install root, and the nativeBuild and packageManager
fields of package.json, which the restore reads in the same GraphQL
request. workspaceImage.test.ts derives these inputs from the base key, so
that they can't drift apart.

- The producer also builds the images when package.json,
  remote/package.json or extensions/copilot/.nvmrc change.
- The test jobs that use an image skip the Playwright browsers cache
  (#343387), as the image holds the browsers.
- The Electron stamp no longer hashes the deleted .npmrc.
- The temporary validation runs every test job.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.

3 participants