From bfb5c94e46888795ab328922252a305dfaf55849 Mon Sep 17 00:00:00 2001 From: Yury Semikhatsky Date: Mon, 16 Nov 2026 14:39:15 -0800 Subject: [PATCH] devops: pin exact Node.js version of the driver and roll it with the driver --- CONTRIBUTING.md | 2 +- scripts/NODE_VERSION | 2 +- scripts/download_driver.sh | 16 +++------------- scripts/roll_driver.sh | 4 ++-- scripts/roll_node.sh | 31 +++++++++++++++++++++++++++++++ 5 files changed, 38 insertions(+), 17 deletions(-) create mode 100755 scripts/roll_node.sh diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a1c38e94c..4622489f0 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -41,7 +41,7 @@ cd playwright-java scripts/download_driver.sh ``` -Each driver is assembled from the [`playwright-core`](https://www.npmjs.com/package/playwright-core) npm package (version pinned in [scripts/DRIVER_VERSION](scripts/DRIVER_VERSION)) and the latest Node.js binary of the major version pinned in [scripts/NODE_VERSION](scripts/NODE_VERSION) from https://nodejs.org, the same way the upstream Playwright build does it. +Each driver is assembled from the [`playwright-core`](https://www.npmjs.com/package/playwright-core) npm package (version pinned in [scripts/DRIVER_VERSION](scripts/DRIVER_VERSION)) and the Node.js binary of the version pinned in [scripts/NODE_VERSION](scripts/NODE_VERSION) from https://nodejs.org, the same way the upstream Playwright build does it. `scripts/roll_driver.sh` updates the pinned Node.js version to the latest release of the same major version on each roll. To update only Node.js, run `scripts/roll_node.sh` and then `scripts/download_driver.sh`. ### Building and running the tests with Maven diff --git a/scripts/NODE_VERSION b/scripts/NODE_VERSION index 6f4247a62..a2e8115a7 100644 --- a/scripts/NODE_VERSION +++ b/scripts/NODE_VERSION @@ -1 +1 @@ -26 +26.13.1 diff --git a/scripts/download_driver.sh b/scripts/download_driver.sh index 24a53de7f..935b8a306 100755 --- a/scripts/download_driver.sh +++ b/scripts/download_driver.sh @@ -11,7 +11,7 @@ if [[ ($1 == '-h') || ($1 == '--help') ]]; then echo "This script downloads and assembles the Playwright driver for all platforms." echo "The platform-independent 'playwright-core' npm package is assembled once into the driver" echo "module ('driver/src/main/resources/driver/package'), and the Node.js binary from" - echo "https://nodejs.org (major version pinned in scripts/NODE_VERSION) for each platform goes" + echo "https://nodejs.org (version pinned in scripts/NODE_VERSION) for each platform goes" echo "into the driver-bundle module ('driver-bundle/src/main/resources/driver/'), the" echo "same way the upstream Playwright build does it." echo "" @@ -49,18 +49,8 @@ npm_at_root() { TMP_DIR="$(mktemp -d)" trap 'rm -rf "$TMP_DIR"' EXIT -# scripts/NODE_VERSION pins the Node.js major version, like ARG NODE_VERSION in the upstream -# Docker images. Use the latest release of that major version. -NODE_MAJOR_VERSION=$(head -1 ./NODE_VERSION) -# The checksum list of the latest release names every file after the release, e.g. -# d38bd5e5... node-v26.13.0-darwin-arm64.tar.gz -SHASUMS="$TMP_DIR/SHASUMS256.txt" -download "https://nodejs.org/dist/latest-v$NODE_MAJOR_VERSION.x/SHASUMS256.txt" "$SHASUMS" -NODE_VERSION=$(sed -nE 's/.*node-v([0-9]+\.[0-9]+\.[0-9]+)-.*/\1/p' "$SHASUMS" | head -1) -if [[ -z "$NODE_VERSION" ]]; then - echo "Failed to determine the latest Node.js $NODE_MAJOR_VERSION.x version" - exit 1 -fi +# scripts/NODE_VERSION pins the exact Node.js version. scripts/roll_node.sh updates it. +NODE_VERSION=$(head -1 ./NODE_VERSION) echo "Driver version: $DRIVER_VERSION" echo "Node.js version: $NODE_VERSION" diff --git a/scripts/roll_driver.sh b/scripts/roll_driver.sh index 4b45e85a2..f4a3c3f03 100755 --- a/scripts/roll_driver.sh +++ b/scripts/roll_driver.sh @@ -25,8 +25,8 @@ CURRENT_VERSION=$(head -1 ./DRIVER_VERSION) echo "Rolling driver from $CURRENT_VERSION to $NEW_VERSION" echo $NEW_VERSION > ./DRIVER_VERSION -# Download even when the driver version is unchanged: the driver bundles the latest release -# of the Node.js major version pinned in NODE_VERSION. +# Each roll also moves the driver to the latest Node.js release of the pinned major version. +./roll_node.sh ./download_driver.sh ./generate_api.sh diff --git a/scripts/roll_node.sh b/scripts/roll_node.sh new file mode 100755 index 000000000..e101a911e --- /dev/null +++ b/scripts/roll_node.sh @@ -0,0 +1,31 @@ +#!/bin/bash + +set -e +set +x + +trap "cd $(pwd -P)" EXIT +cd "$(dirname $0)" + +if [ "$#" -gt 0 ]; then + echo "" + echo "Updates scripts/NODE_VERSION to the latest Node.js release of the same major version." + echo "Run scripts/download_driver.sh after that to download the new Node.js binaries." + echo "" + echo "Usage: scripts/roll_node.sh" + echo "" + exit 1 +fi + +CURRENT_VERSION=$(head -1 ./NODE_VERSION) +MAJOR_VERSION=${CURRENT_VERSION%%.*} +# The checksum list of the latest release names every file after the release, e.g. +# d38bd5e5... node-v26.13.0-darwin-arm64.tar.gz +NEW_VERSION=$(curl --retry 5 --retry-delay 2 -fsSL "https://nodejs.org/dist/latest-v$MAJOR_VERSION.x/SHASUMS256.txt" \ + | sed -nE 's/.*node-v([0-9]+\.[0-9]+\.[0-9]+)-.*/\1/p' | head -1) +if [[ -z "$NEW_VERSION" ]]; then + echo "Failed to determine the latest Node.js $MAJOR_VERSION.x version" + exit 1 +fi + +echo "Rolling Node.js from $CURRENT_VERSION to $NEW_VERSION" +echo $NEW_VERSION > ./NODE_VERSION