Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion scripts/NODE_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
26
26.13.1
16 changes: 3 additions & 13 deletions scripts/download_driver.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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/<platform>'), the"
echo "same way the upstream Playwright build does it."
echo ""
Expand Down Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions scripts/roll_driver.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
31 changes: 31 additions & 0 deletions scripts/roll_node.sh
Original file line number Diff line number Diff line change
@@ -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
Loading