Skip to content

Commit a08ab2d

Browse files
authored
devops: roll_driver script (#1605)
1 parent 626050d commit a08ab2d

File tree

14 files changed

+104
-91
lines changed

14 files changed

+104
-91
lines changed

.azure-pipelines/publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ extends:
4747
GPG_PRIVATE_KEY_BASE64: $(GPG_PRIVATE_KEY_BASE64) # secret variable has to be mapped to an env variable
4848
displayName: "Import gpg key"
4949
50-
- bash: ./scripts/download_driver_for_all_platforms.sh
50+
- bash: ./scripts/download_driver.sh
5151
displayName: 'Download driver'
5252

5353
- bash: mvn -B deploy -D skipTests --no-transfer-progress --activate-profiles release -D gpg.passphrase=$GPG_PASSPHRASE -DaltDeploymentRepository=snapshot-repo::default::file:$(pwd)/local-build

.github/workflows/test.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
java-version: 8
2828
- name: Download drivers
2929
shell: bash
30-
run: scripts/download_driver_for_all_platforms.sh
30+
run: scripts/download_driver.sh
3131
- name: Build & Install
3232
run: mvn -B install -D skipTests --no-transfer-progress
3333
- name: Run tests
@@ -75,7 +75,7 @@ jobs:
7575
java-version: 8
7676
- name: Download drivers
7777
shell: bash
78-
run: scripts/download_driver_for_all_platforms.sh
78+
run: scripts/download_driver.sh
7979
- name: Build & Install
8080
run: mvn -B install -D skipTests --no-transfer-progress
8181
- name: Install MS Edge
@@ -105,7 +105,7 @@ jobs:
105105
java-version: 17
106106
- name: Download drivers
107107
shell: bash
108-
run: scripts/download_driver_for_all_platforms.sh
108+
run: scripts/download_driver.sh
109109
- name: Build & Install
110110
run: mvn -B install -D skipTests --no-transfer-progress
111111
- name: Run tests

.github/workflows/test_cli.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
2222
restore-keys: ${{ runner.os }}-m2
2323
- name: Download drivers
24-
run: scripts/download_driver_for_all_platforms.sh
24+
run: scripts/download_driver.sh
2525
- name: Intall Playwright
2626
run: mvn install -D skipTests --no-transfer-progress
2727
- name: Test CLI

.github/workflows/test_docker.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ on:
1111
paths:
1212
- .github/workflows/test_docker.yml
1313
- '**/Dockerfile*'
14-
- scripts/CLI_VERSION
14+
- scripts/DRIVER_VERSION
1515
- '**/pom.xml'
1616
branches:
1717
- main

.github/workflows/verify_api.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
- uses: actions/checkout@v2
2323
- uses: microsoft/playwright-github-action@v1
2424
- name: Download drivers
25-
run: scripts/download_driver_for_all_platforms.sh
25+
run: scripts/download_driver.sh
2626
- name: Regenerate APIs
2727
run: scripts/generate_api.sh
2828
- name: Update browser versions in README

CONTRIBUTING.md

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,12 @@ git clone https://github.com/microsoft/playwright-java
2020
cd playwright-java
2121
```
2222

23-
2. Run the following script to download playwright-cli binaries for all platforms into `driver-bundle/src/main/resources/driver/` directory (browser binaries for Chromium, Firefox and WebKit will be automatically downloaded later on first Playwright run).
23+
2. Run the following script to download Playwright driver for all platforms into `driver-bundle/src/main/resources/driver/` directory (browser binaries for Chromium, Firefox and WebKit will be automatically downloaded later on first Playwright run).
2424

2525
```bash
26-
scripts/download_driver_for_all_platforms.sh
26+
scripts/download_driver.sh
2727
```
2828

29-
Names of published driver archives can be found at https://github.com/microsoft/playwright-cli/actions
30-
3129
### Building and running the tests with Maven
3230

3331
```bash
@@ -41,25 +39,19 @@ BROWSER=chromium mvn test --projects=playwright -Dtest=TestPageNetworkSizes
4139

4240
### Generating API
4341

44-
Public Java API is generated from api.json which is produced by `playwright-cli print-api-json`. To regenerate
45-
Java interfaces for the current driver run the following commands:
42+
Public Java API is generated from api.json which is produced by `print-api-json` command of playwright CLI. To regenerate Java interfaces for the current driver run the following commands:
4643

4744
```bash
48-
./scripts/download_driver_for_all_platforms.sh
45+
./scripts/download_driver.sh
4946
./scripts/generate_api.sh
5047
```
5148

5249
#### Updating driver version
5350

54-
Driver version is read from [scripts/CLI_VERSION](https://github.com/microsoft/playwright-java/blob/main/scripts/CLI_VERSION) and can be found in the upstream [GHA build](https://github.com/microsoft/playwright/actions/workflows/publish_canary.yml) logs. To update the driver to a particular version run the following commands:
51+
Versions of published driver archives can be found in [publish canary](https://github.com/microsoft/playwright/actions/workflows/publish_canary.yml) and [publish release](https://github.com/microsoft/playwright/actions/workflows/publish_release_driver.yml) actions logs. To update the driver to a particular version run the following command:
5552

5653
```bash
57-
cat > scripts/CLI_VERSION
58-
<paste new version>
59-
^D
60-
./scripts/download_driver_for_all_platforms.sh -f
61-
./scripts/generate_api.sh
62-
./scripts/update_readme.sh
54+
scripts/roll_driver.sh [version]
6355
```
6456

6557
### Code Style

ROLLING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
* make sure to have at least Java 8 and Maven 3.6.3
44
* clone playwright for java: http://github.com/microsoft/playwright-java
5-
* set new driver version in `scripts/CLI_VERSION`
6-
* regenerate API: `./scripts/download_driver_for_all_platforms.sh -f && ./scripts/generate_api.sh && ./scripts/update_readme.sh`
5+
* set new driver version in `scripts/DRIVER_VERSION`
6+
* regenerate API: `./scripts/download_driver.sh -f && ./scripts/generate_api.sh && ./scripts/update_readme.sh`
77
* commit & send PR with the roll
88

99
### Finding driver version

scripts/download_driver.sh

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#!/bin/bash
2+
3+
set -e
4+
set +x
5+
6+
trap "cd $(pwd -P)" EXIT
7+
cd "$(dirname $0)"
8+
9+
if [[ ($1 == '-h') || ($1 == '--help') ]]; then
10+
echo ""
11+
echo "This script for downloading playwright driver for all platforms."
12+
echo "The downloaded files will be put under 'driver-bundle/src/main/resources/driver'."
13+
echo ""
14+
echo "Usage: scripts/download_driver.sh [option]"
15+
echo ""
16+
echo "Options:"
17+
echo " -h, --help display help information"
18+
echo ""
19+
exit 0
20+
fi
21+
22+
DRIVER_VERSION=$(head -1 ./DRIVER_VERSION)
23+
FILE_PREFIX=playwright-$DRIVER_VERSION
24+
25+
cd ../driver-bundle/src/main/resources
26+
27+
if [[ -d 'driver' ]]; then
28+
echo "Deleting existing drivers from $(pwd)"
29+
rm -rf driver
30+
fi
31+
32+
mkdir -p driver
33+
cd driver
34+
35+
for PLATFORM in mac mac-arm64 linux linux-arm64 win32_x64
36+
do
37+
FILE_NAME=$FILE_PREFIX-$PLATFORM.zip
38+
mkdir $PLATFORM
39+
cd $PLATFORM
40+
echo "Downloading driver for $PLATFORM to $(pwd)"
41+
42+
URL=https://playwright.azureedge.net/builds/driver
43+
if [[ "$DRIVER_VERSION" == *-alpha* || "$DRIVER_VERSION" == *-beta* || "$DRIVER_VERSION" == *-next* ]]; then
44+
URL=$URL/next
45+
fi
46+
URL=$URL/$FILE_NAME
47+
echo "Using url: $URL"
48+
curl -O $URL
49+
unzip $FILE_NAME -d .
50+
rm $FILE_NAME
51+
52+
cd -
53+
done
54+
55+
echo ""
56+
echo "All drivers have been successfully downloaded."
57+
echo ""

scripts/download_driver_for_all_platforms.sh

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

0 commit comments

Comments
 (0)