diff --git a/.github/workflows/test_docker.yml b/.github/workflows/test_docker.yml index 36b07f466..cd8f86606 100644 --- a/.github/workflows/test_docker.yml +++ b/.github/workflows/test_docker.yml @@ -12,6 +12,7 @@ on: - .github/workflows/test_docker.yml - '**/Dockerfile*' - scripts/DRIVER_VERSION + - scripts/NODE_VERSION - '**/pom.xml' branches: - main diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 30eb6d9b4..a1c38e94c 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 matching Node.js binary 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 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. ### Building and running the tests with Maven diff --git a/scripts/NODE_VERSION b/scripts/NODE_VERSION new file mode 100644 index 000000000..6f4247a62 --- /dev/null +++ b/scripts/NODE_VERSION @@ -0,0 +1 @@ +26 diff --git a/scripts/download_driver.sh b/scripts/download_driver.sh index 5e36f91e3..24a53de7f 100755 --- a/scripts/download_driver.sh +++ b/scripts/download_driver.sh @@ -10,10 +10,10 @@ if [[ ($1 == '-h') || ($1 == '--help') ]]; then echo "" 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 matching Node.js binary from" - echo "https://nodejs.org for each platform goes into the driver-bundle module" - echo "('driver-bundle/src/main/resources/driver/'), the same way the upstream" - echo "Playwright build does it." + 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 "into the driver-bundle module ('driver-bundle/src/main/resources/driver/'), the" + echo "same way the upstream Playwright build does it." echo "" echo "Usage: scripts/download_driver.sh [option]" echo "" @@ -46,13 +46,19 @@ npm_at_root() { (cd "$ROOT" && npm "$@") } -# The Node.js version used to be pinned in the upstream driver build script. The script was -# removed in microsoft/playwright#41518, so we follow the same policy it had: the latest -# Node.js LTS (see upstream utils/build/update-playwright-node.mjs). -NODE_VERSION=$(curl -fsSL "https://nodejs.org/dist/index.json" \ - | node -e "let s='';process.stdin.on('data',d=>s+=d).on('end',()=>console.log(JSON.parse(s).find(r=>r.lts).version.slice(1)))") +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 LTS version" + echo "Failed to determine the latest Node.js $NODE_MAJOR_VERSION.x version" exit 1 fi @@ -64,9 +70,6 @@ echo "Node.js version: $NODE_VERSION" CORE_DEST="$ROOT/driver/src/main/resources/driver" NODE_DEST="$ROOT/driver-bundle/src/main/resources/driver" -TMP_DIR="$(mktemp -d)" -trap 'rm -rf "$TMP_DIR"' EXIT - # 1. playwright-core package -> driver module (once, shared by every platform). echo "Assembling playwright-core package to $CORE_DEST/package" rm -rf "$CORE_DEST/package" diff --git a/scripts/roll_driver.sh b/scripts/roll_driver.sh index f8535e57f..4b45e85a2 100755 --- a/scripts/roll_driver.sh +++ b/scripts/roll_driver.sh @@ -24,12 +24,10 @@ fi CURRENT_VERSION=$(head -1 ./DRIVER_VERSION) echo "Rolling driver from $CURRENT_VERSION to $NEW_VERSION" -if [[ "$CURRENT_VERSION" == "$NEW_VERSION" ]]; then - echo "Current version is up to date. Skipping driver download."; -else - echo $NEW_VERSION > ./DRIVER_VERSION - ./download_driver.sh -fi; +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. +./download_driver.sh ./generate_api.sh ./update_readme.sh diff --git a/utils/docker/Dockerfile.jammy b/utils/docker/Dockerfile.jammy index 4440772ea..316a95d4f 100644 --- a/utils/docker/Dockerfile.jammy +++ b/utils/docker/Dockerfile.jammy @@ -19,6 +19,8 @@ RUN find /etc/apt -type f \( -name '*.list' -o -name '*.sources' \) \ wget \ # Install utilities required for downloading driver unzip \ + # The Node.js binary of the driver links against libatomic (since Node.js 25) + libatomic1 \ # For the MSEdge install script gpg && \ rm -rf /var/lib/apt/lists/* && \ diff --git a/utils/docker/Dockerfile.noble b/utils/docker/Dockerfile.noble index 52779ce15..5ccd4d7bf 100644 --- a/utils/docker/Dockerfile.noble +++ b/utils/docker/Dockerfile.noble @@ -19,6 +19,8 @@ RUN find /etc/apt -type f \( -name '*.list' -o -name '*.sources' \) \ wget \ # Install utilities required for downloading driver unzip \ + # The Node.js binary of the driver links against libatomic (since Node.js 25) + libatomic1 \ # For the MSEdge install script gpg && \ rm -rf /var/lib/apt/lists/* && \ diff --git a/utils/docker/Dockerfile.resolute b/utils/docker/Dockerfile.resolute index 905962beb..7dabf1f96 100644 --- a/utils/docker/Dockerfile.resolute +++ b/utils/docker/Dockerfile.resolute @@ -21,6 +21,8 @@ RUN find /etc/apt -type f \( -name '*.list' -o -name '*.sources' \) \ wget \ # Install utilities required for downloading driver unzip \ + # The Node.js binary of the driver links against libatomic (since Node.js 25) + libatomic1 \ # For the MSEdge install script gpg && \ rm -rf /var/lib/apt/lists/* && \