Skip to content

Commit 02153b8

Browse files
jpolitzclaude
andcommitted
Fix code.pyret.org CI: use chrome-for-testing chromedriver directly
Joe says: npm finally updated enough that we got bit by a configuration warning I should have fixed a while ago Claude says: The Selenium tests were all failing with "Server terminated early with status 1". The cause was the chromedriver binary install, not Selenium: selenium-webdriver 3.6.0 launches chromedriver 149 and creates a W3C session fine. That error is what Selenium reports when the `chromedrive npm package's launcher shim can't start its real binary. The binary wasn't installing correctly because the install relied on `npm install chromedriver --chromedriver_filepath=...`, which npm 11 no flags as an unknown config that "will stop working", and because the `chromedriver` npm package is pinned to 146 while Chrome is auto-fetche at latest-stable (149). chrome-for-testing already ships a chromedriver matching the Chrome we download, so use it directly: - Workflow: unzip the chromedriver from the same release and export CHROMEDRIVER_BINARY; drop the npm chromedriver-install step entirely. - util.js: CHROMEDRIVER_BINARY and GOOGLE_CHROME_BINARY were mutually exclusive (if/else if), so selecting a driver binary left Chrome's location unset. Make them independent. Driver and browser now always come from the same release, with no deprecated npm flag. Verified locally with Chrome+chromedriver 149 and selenium-webdriver 3.6.0: a real headless session loads a page. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 6f77135 commit 02153b8

2 files changed

Lines changed: 16 additions & 12 deletions

File tree

.github/workflows/code.pyret.org-test.yml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,24 +35,24 @@ jobs:
3535
export CHROME_VERSION=$(curl -s https://googlechromelabs.github.io/chrome-for-testing/LATEST_RELEASE_STABLE)
3636
echo "Chrome version: $CHROME_VERSION"
3737
38-
# Download Chrome and ChromeDriver
38+
# Download Chrome and the exactly-matching ChromeDriver from the same release
3939
curl -L https://storage.googleapis.com/chrome-for-testing-public/$CHROME_VERSION/linux64/chrome-linux64.zip -o chrome-linux64.zip
4040
curl -L https://storage.googleapis.com/chrome-for-testing-public/$CHROME_VERSION/linux64/chromedriver-linux64.zip -o chromedriver-linux64.zip
41-
42-
# Extract Chrome
41+
42+
# Extract Chrome and ChromeDriver
4343
unzip chrome-linux64.zip
44-
45-
# Set Chrome binary path for tests
46-
echo "GOOGLE_CHROME_BINARY=./chrome-linux64/chrome" >> $GITHUB_ENV
44+
unzip chromedriver-linux64.zip
45+
46+
# Point the tests at both binaries. We use the chrome-for-testing
47+
# chromedriver directly (via CHROMEDRIVER_BINARY) instead of the
48+
# `chromedriver` npm package so the driver always matches Chrome and we
49+
# don't depend on npm's deprecated --chromedriver_filepath config.
50+
echo "GOOGLE_CHROME_BINARY=$PWD/chrome-linux64/chrome" >> $GITHUB_ENV
51+
echo "CHROMEDRIVER_BINARY=$PWD/chromedriver-linux64/chromedriver" >> $GITHUB_ENV
4752
4853
- name: Install dependencies
4954
run: npm ci --ignore-scripts
5055

51-
- name: Install ChromeDriver with specific binary
52-
run: |
53-
npm install chromedriver --chromedriver_filepath=$PWD/chromedriver-linux64.zip
54-
npm install -g chromedriver --chromedriver_filepath=$PWD/chromedriver-linux64.zip
55-
5656
- name: Add node_modules/.bin to PATH
5757
run: echo "$PWD/node_modules/.bin" >> $GITHUB_PATH
5858

code.pyret.org/test-util/util.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,12 @@ let PATH_TO_CHROME;
1010
if (process.env.CHROMEDRIVER_BINARY) {
1111
// Note(Ben): Use `env CHROMDRIVER_BINARY=/snap/bin/chromium.chromedriver npm run mocha`
1212
// Based on https://stackoverflow.com/a/53971573
13+
// This selects the ChromeDriver binary; it is independent of which Chrome
14+
// browser binary we use (GOOGLE_CHROME_BINARY), so it must not be an else-if.
1315
chrome.setDefaultService(new chrome.ServiceBuilder(process.env.CHROMEDRIVER_BINARY).build());
14-
} else if (process.env.GOOGLE_CHROME_BINARY) {
16+
}
17+
18+
if (process.env.GOOGLE_CHROME_BINARY) {
1519
// Used by Travis
1620
PATH_TO_CHROME = process.env.GOOGLE_CHROME_BINARY;
1721
}

0 commit comments

Comments
 (0)