Skip to content

Commit 2ebe482

Browse files
ci: pin Chrome and Firefox to the builds puppeteer-core names (#22703)
* ci: pin Chrome and Firefox to the builds puppeteer-core names The syntax-equivalence job ran the runner's own Chrome and whatever Firefox was `stable` that day, so a new engine reached every pull request at once and an engine-quirk probe failing there said nothing about the change. Install the builds puppeteer-core pins (PUPPETEER_REVISIONS) instead, cached by build id, through `yarn setup:browsers`; the browser helper prefers them. WebKit was already pinned by playwright-core. Dependabot bumps the three packages in a `browsers` group of their own, so a new engine lands in one pull request. * ci: pin Firefox 158 through puppeteer-core 25.14.0 puppeteer-core 25.13.0 pinned Firefox 157.0.1, a release behind the stable main tests against, which still prints one filed-free font-family value apart. 25.14.0 pins 158.0 and Chrome 155.0.8059.79.
1 parent ed18fa1 commit 2ebe482

9 files changed

Lines changed: 172 additions & 81 deletions

File tree

‎.github/dependabot.yml‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,22 @@ updates:
99
- dependencies
1010
versioning-strategy: widen
1111
groups:
12+
# The engines the browser suites compare against: puppeteer-core pins the
13+
# Chrome and Firefox builds CI installs, playwright-core the WebKit one.
14+
# Their own pull request, so a new engine reds only the bump that brought
15+
# it, and an engine-quirk probe failing there says which workaround can go.
16+
browsers:
17+
patterns:
18+
- "puppeteer-core"
19+
- "@puppeteer/browsers"
20+
- "playwright-core"
1221
dependencies:
1322
patterns:
1423
- "*"
24+
exclude-patterns:
25+
- "puppeteer-core"
26+
- "@puppeteer/browsers"
27+
- "playwright-core"
1528
update-types:
1629
- "minor"
1730
- "patch"
@@ -22,6 +35,9 @@ updates:
2235
- "major"
2336
exclude-patterns:
2437
- "rimraf"
38+
- "puppeteer-core"
39+
- "@puppeteer/browsers"
40+
- "playwright-core"
2541
# The corpora the comparison scripts measure against, one manifest each. They
2642
# reach no webpack build, so a bump is only ever a wider corpus to sweep — and
2743
# a bump that breaks a printer invariant reds its own pull request, where it

‎.github/workflows/test.yml‎

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -442,15 +442,28 @@ jobs:
442442
continue-on-error: true
443443
run: yarn benchmark:html-tools:setup
444444

445-
# Chrome comes with the runner. Firefox is fetched, and deliberately not
446-
# cached: the build id resolves to whatever `stable` is today, so a cache
447-
# key that never moves would pin the engine this suite exists to track.
448-
- name: Install Firefox
449-
if: matrix.browser == 'firefox'
450-
run: node tooling/retry.js yarn setup:firefox
451-
452-
# `--with-deps` because a runner carries none of WebKit's shared
453-
# libraries, where it already carries Chrome's.
445+
# Chrome and Firefox are the builds puppeteer-core pins, not the runner's
446+
# Chrome or today's `stable`: an engine then moves only in the pull request
447+
# bumping puppeteer-core, where an engine-quirk probe failing is the news,
448+
# rather than under every pull request at once. Cached by that build id.
449+
- name: Read the pinned browser build
450+
id: browser-build
451+
if: matrix.browser != 'webkit'
452+
run: node --input-type=module -e "const { PUPPETEER_REVISIONS } = await import('puppeteer-core'); console.log('id=' + PUPPETEER_REVISIONS[process.argv[1]])" ${{ matrix.browser }} >> "$GITHUB_OUTPUT"
453+
454+
- name: Cache the pinned browser
455+
if: matrix.browser != 'webkit'
456+
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
457+
with:
458+
path: ~/.cache/puppeteer
459+
key: puppeteer-${{ matrix.browser }}-${{ steps.browser-build.outputs.id }}-${{ runner.os }}
460+
461+
- name: Install the pinned browser
462+
if: matrix.browser != 'webkit'
463+
run: node tooling/retry.js yarn setup:browsers ${{ matrix.browser }}
464+
465+
# Pinned by playwright-core already. `--with-deps` because a runner carries
466+
# none of WebKit's shared libraries, where it already carries Chrome's.
454467
- name: Install WebKit
455468
if: matrix.browser == 'webkit'
456469
run: node tooling/retry.js node node_modules/playwright-core/cli.js install --with-deps webkit

‎TESTING_DOCS.md‎

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -200,16 +200,17 @@ During the test run, webpack compiles this project and compares the result with
200200
`WebpackDevServer.longtest.js` launch a browser through `test/helpers/launchBrowser.js`.
201201
**A browser that will not launch fails the suite — it is never skipped**, so no
202202
environment can report these checks as passing without having run them. The
203-
helper uses the installed Chrome channel; set `PUPPETEER_EXECUTABLE_PATH` to
204-
point at another binary.
203+
helper uses the Chrome build puppeteer-core pins when `yarn setup:browsers` has
204+
fetched it, and the installed Chrome channel otherwise; set
205+
`PUPPETEER_EXECUTABLE_PATH` to point at another binary.
205206

206207
`syntaxEquivalence.spectest.js` is the one that reads more than one engine:
207208
`EQUIVALENCE_BROWSER` takes `chrome`, `firefox` or `webkit`, and CI runs all
208209
three as one matrix. Chrome and Firefox go through puppeteer; WebKit goes
209210
through playwright, which is what reaches it, under a shim in
210211
`test/helpers/launchBrowser.js` that answers to the puppeteer names the suites
211-
call. Fetch the browser first — `yarn setup:firefox`, `yarn setup:webkit` —
212-
which installs into puppeteer's own cache (`PUPPETEER_CACHE_DIR`, defaulting to
212+
call. Fetch the browser first — `yarn setup:browsers` (Chrome and Firefox, or
213+
name one), `yarn setup:webkit` — which installs into puppeteer's own cache (`PUPPETEER_CACHE_DIR`, defaulting to
213214
`~/.cache/puppeteer`) or playwright's; `FIREFOX_EXECUTABLE_PATH` and
214215
`WEBKIT_EXECUTABLE_PATH` point at one already on the machine. It compares
215216
effects, never CSSOM text: a stylesheet by the styles elements built from its
@@ -222,6 +223,12 @@ than tolerated in all three, and each list must match exactly, so a defect the
222223
engine fixes fails until its entry goes. A workaround in the suite's own code
223224
gets the same treatment through a probe in `ENGINE_QUIRKS`.
224225

226+
Every engine is the build the lockfile pins: Chrome and Firefox are the ones
227+
`puppeteer-core` names in `PUPPETEER_REVISIONS`, WebKit the one `playwright-core`
228+
ships. Dependabot bumps the two packages in a `browsers` group of their own, so
229+
a new engine arrives in one pull request, and a defect or quirk it fixes fails
230+
there rather than under unrelated changes.
231+
225232
They are excluded from `test:bun` / `test:deno` (see the `--testPathIgnorePatterns`
226233
in those scripts): under Jest on Bun, loading the ESM-only `puppeteer-core` fails
227234
outright with "Provided module is not an instance of Module", and Jest's

‎eslint.config.mjs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -354,9 +354,9 @@ export default defineConfig([
354354
}
355355
},
356356
{
357-
// Fetches a browser for the suites that compare against one, from a package
357+
// Fetches the browsers for the suites that compare against one, from a package
358358
// that is ESM-only — so it runs on modern Node rather than the baseline.
359-
files: ["tooling/install-firefox.js"],
359+
files: ["tooling/install-browsers.js"],
360360
languageOptions: {
361361
ecmaVersion: 2022
362362
},

‎package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
"find-deep-imports": "node tooling/find-deep-webpack-imports.js",
7575
"find-deep-imports:check": "node tooling/find-deep-webpack-imports.js --check",
7676
"measure:color-agreement": "node tooling/measure-color-agreement.js",
77-
"setup:firefox": "node tooling/install-firefox.js",
77+
"setup:browsers": "node tooling/install-browsers.js",
7878
"setup:webkit": "node node_modules/playwright-core/cli.js install webkit",
7979
"pretest": "yarn lint",
8080
"test": "yarn test:base",

‎test/helpers/launchBrowser.js‎

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,41 @@
33
const os = require("os");
44
const path = require("path");
55

6-
// The same cache `yarn setup:firefox` installs into, and the one puppeteer's
6+
// The same cache `yarn setup:browsers` installs into, and the one puppeteer's
77
// own tooling reads, so the two agree wherever it has been pointed elsewhere.
88
const CACHE_DIR =
99
process.env.PUPPETEER_CACHE_DIR ||
1010
path.join(os.homedir(), ".cache", "puppeteer");
1111

1212
/**
13-
* Where an already-downloaded Firefox sits, or `undefined` when none is. The
13+
* Where the build of `engine` puppeteer-core pins sits once downloaded, or
14+
* `undefined` when it is not. Only that build counts: an older one left in the
15+
* cache would hold the suites to an engine the lockfile no longer names. The
1416
* suites do not download one themselves: a cold fetch is tens of megabytes and
1517
* would expire the callers' hook budget rather than report a browser problem.
18+
* @param {"chrome" | "firefox"} engine the engine
1619
* @returns {Promise<string | undefined>} the executable path
1720
*/
18-
const installedFirefox = async () => {
21+
const installedBrowser = async (engine) => {
1922
// ESM-only, like puppeteer-core itself, so it is loaded the same way.
2023
const { Browser, detectBrowserPlatform, getInstalledBrowsers } =
2124
await import("@puppeteer/browsers");
25+
// Exported at runtime, but kept out of puppeteer-core's types as internal.
26+
const { PUPPETEER_REVISIONS } =
27+
/** @type {{ PUPPETEER_REVISIONS: Readonly<Record<"chrome" | "firefox", string>> }} */ (
28+
/** @type {unknown} */ (await import("puppeteer-core"))
29+
);
2230

2331
const platform = detectBrowserPlatform();
2432
if (platform === undefined) return undefined;
33+
const browser = engine === "chrome" ? Browser.CHROME : Browser.FIREFOX;
34+
const buildId = PUPPETEER_REVISIONS[engine];
2535
for (const one of await getInstalledBrowsers({ cacheDir: CACHE_DIR })) {
26-
if (one.browser === Browser.FIREFOX && one.platform === platform) {
36+
if (
37+
one.browser === browser &&
38+
one.platform === platform &&
39+
one.buildId === buildId
40+
) {
2741
return one.executablePath;
2842
}
2943
}
@@ -143,17 +157,23 @@ module.exports = async (options) => {
143157
const executablePath =
144158
launchOptions.executablePath ||
145159
process.env.FIREFOX_EXECUTABLE_PATH ||
146-
(await installedFirefox());
160+
(await installedBrowser("firefox"));
147161
if (executablePath === undefined) {
148162
throw new Error(
149-
"no Firefox to launch: run `yarn setup:firefox`, or point FIREFOX_EXECUTABLE_PATH at one"
163+
"no Firefox to launch: run `yarn setup:browsers firefox`, or point FIREFOX_EXECUTABLE_PATH at one"
150164
);
151165
}
152166
launchOptions.executablePath = executablePath;
153167
} else if (!launchOptions.executablePath) {
154-
if (process.env.PUPPETEER_EXECUTABLE_PATH) {
155-
launchOptions.executablePath = process.env.PUPPETEER_EXECUTABLE_PATH;
168+
const executablePath =
169+
process.env.PUPPETEER_EXECUTABLE_PATH ||
170+
(await installedBrowser("chrome"));
171+
if (executablePath !== undefined) {
172+
launchOptions.executablePath = executablePath;
156173
} else {
174+
// The system Chrome moves with the machine rather than the lockfile,
175+
// which is fine for a suite that only needs a Chrome, but not for one
176+
// holding output to an engine: CI installs the pinned build for those.
157177
launchOptions.channel = "chrome";
158178
}
159179
}

‎tooling/install-browsers.js‎

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/*
2+
MIT License http://www.opensource.org/licenses/mit-license.php
3+
Author Raj Aryan @aryanraj45
4+
*/
5+
6+
"use strict";
7+
8+
// Downloads the Chrome and Firefox the browser suites compare against, into
9+
// puppeteer's own cache rather than into webpack's dependencies. Each is the
10+
// build puppeteer-core pins, so the engine moves only when the lockfile does
11+
// and a Dependabot bump of puppeteer-core is the one pull request that sees a
12+
// new engine. Safe to re-run: an install that is already there is reported and
13+
// nothing is fetched. `node tooling/install-browsers.js firefox` fetches one.
14+
15+
const os = require("os");
16+
const path = require("path");
17+
18+
// puppeteer's own cache, which `test/helpers/launchBrowser.js` looks in.
19+
const CACHE_DIR =
20+
process.env.PUPPETEER_CACHE_DIR ||
21+
path.join(os.homedir(), ".cache", "puppeteer");
22+
23+
const ENGINES = ["chrome", "firefox"];
24+
25+
(async () => {
26+
// Both are ESM-only, so they are loaded the way puppeteer itself is rather
27+
// than with `require`.
28+
const { Browser, detectBrowserPlatform, install } =
29+
await import("@puppeteer/browsers");
30+
// Exported at runtime, but kept out of puppeteer-core's types as internal.
31+
const { PUPPETEER_REVISIONS } =
32+
/** @type {{ PUPPETEER_REVISIONS: Readonly<Record<"chrome" | "firefox", string>> }} */ (
33+
/** @type {unknown} */ (await import("puppeteer-core"))
34+
);
35+
const platform = detectBrowserPlatform();
36+
if (platform === undefined) throw new Error("no browser platform detected");
37+
const wanted = process.argv.slice(2);
38+
for (const engine of wanted.length > 0 ? wanted : ENGINES) {
39+
if (!ENGINES.includes(engine)) {
40+
throw new Error(`no pinned build for ${engine}: ${ENGINES.join(", ")}`);
41+
}
42+
const buildId =
43+
PUPPETEER_REVISIONS[/** @type {"chrome" | "firefox"} */ (engine)];
44+
const installed = await install({
45+
browser: engine === "chrome" ? Browser.CHROME : Browser.FIREFOX,
46+
buildId,
47+
cacheDir: CACHE_DIR
48+
});
49+
console.log(`${engine} ${buildId}: ${installed.executablePath}`);
50+
}
51+
})().catch((error) => {
52+
console.error(error);
53+
process.exitCode = 1;
54+
});

‎tooling/install-firefox.js‎

Lines changed: 0 additions & 37 deletions
This file was deleted.

0 commit comments

Comments
 (0)