mirror of
https://github.com/microsoft/playwright-java.git
synced 2025-12-26 17:33:37 +00:00
devops: roll_driver script (#1605)
This commit is contained in:
parent
626050d988
commit
a08ab2dcae
@ -47,7 +47,7 @@ extends:
|
||||
GPG_PRIVATE_KEY_BASE64: $(GPG_PRIVATE_KEY_BASE64) # secret variable has to be mapped to an env variable
|
||||
displayName: "Import gpg key"
|
||||
|
||||
- bash: ./scripts/download_driver_for_all_platforms.sh
|
||||
- bash: ./scripts/download_driver.sh
|
||||
displayName: 'Download driver'
|
||||
|
||||
- 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
|
||||
|
||||
6
.github/workflows/test.yml
vendored
6
.github/workflows/test.yml
vendored
@ -27,7 +27,7 @@ jobs:
|
||||
java-version: 8
|
||||
- name: Download drivers
|
||||
shell: bash
|
||||
run: scripts/download_driver_for_all_platforms.sh
|
||||
run: scripts/download_driver.sh
|
||||
- name: Build & Install
|
||||
run: mvn -B install -D skipTests --no-transfer-progress
|
||||
- name: Run tests
|
||||
@ -75,7 +75,7 @@ jobs:
|
||||
java-version: 8
|
||||
- name: Download drivers
|
||||
shell: bash
|
||||
run: scripts/download_driver_for_all_platforms.sh
|
||||
run: scripts/download_driver.sh
|
||||
- name: Build & Install
|
||||
run: mvn -B install -D skipTests --no-transfer-progress
|
||||
- name: Install MS Edge
|
||||
@ -105,7 +105,7 @@ jobs:
|
||||
java-version: 17
|
||||
- name: Download drivers
|
||||
shell: bash
|
||||
run: scripts/download_driver_for_all_platforms.sh
|
||||
run: scripts/download_driver.sh
|
||||
- name: Build & Install
|
||||
run: mvn -B install -D skipTests --no-transfer-progress
|
||||
- name: Run tests
|
||||
|
||||
2
.github/workflows/test_cli.yml
vendored
2
.github/workflows/test_cli.yml
vendored
@ -21,7 +21,7 @@ jobs:
|
||||
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
|
||||
restore-keys: ${{ runner.os }}-m2
|
||||
- name: Download drivers
|
||||
run: scripts/download_driver_for_all_platforms.sh
|
||||
run: scripts/download_driver.sh
|
||||
- name: Intall Playwright
|
||||
run: mvn install -D skipTests --no-transfer-progress
|
||||
- name: Test CLI
|
||||
|
||||
2
.github/workflows/test_docker.yml
vendored
2
.github/workflows/test_docker.yml
vendored
@ -11,7 +11,7 @@ on:
|
||||
paths:
|
||||
- .github/workflows/test_docker.yml
|
||||
- '**/Dockerfile*'
|
||||
- scripts/CLI_VERSION
|
||||
- scripts/DRIVER_VERSION
|
||||
- '**/pom.xml'
|
||||
branches:
|
||||
- main
|
||||
|
||||
2
.github/workflows/verify_api.yml
vendored
2
.github/workflows/verify_api.yml
vendored
@ -22,7 +22,7 @@ jobs:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: microsoft/playwright-github-action@v1
|
||||
- name: Download drivers
|
||||
run: scripts/download_driver_for_all_platforms.sh
|
||||
run: scripts/download_driver.sh
|
||||
- name: Regenerate APIs
|
||||
run: scripts/generate_api.sh
|
||||
- name: Update browser versions in README
|
||||
|
||||
@ -20,14 +20,12 @@ git clone https://github.com/microsoft/playwright-java
|
||||
cd playwright-java
|
||||
```
|
||||
|
||||
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).
|
||||
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).
|
||||
|
||||
```bash
|
||||
scripts/download_driver_for_all_platforms.sh
|
||||
scripts/download_driver.sh
|
||||
```
|
||||
|
||||
Names of published driver archives can be found at https://github.com/microsoft/playwright-cli/actions
|
||||
|
||||
### Building and running the tests with Maven
|
||||
|
||||
```bash
|
||||
@ -41,25 +39,19 @@ BROWSER=chromium mvn test --projects=playwright -Dtest=TestPageNetworkSizes
|
||||
|
||||
### Generating API
|
||||
|
||||
Public Java API is generated from api.json which is produced by `playwright-cli print-api-json`. To regenerate
|
||||
Java interfaces for the current driver run the following commands:
|
||||
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:
|
||||
|
||||
```bash
|
||||
./scripts/download_driver_for_all_platforms.sh
|
||||
./scripts/download_driver.sh
|
||||
./scripts/generate_api.sh
|
||||
```
|
||||
|
||||
#### Updating driver version
|
||||
|
||||
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:
|
||||
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:
|
||||
|
||||
```bash
|
||||
cat > scripts/CLI_VERSION
|
||||
<paste new version>
|
||||
^D
|
||||
./scripts/download_driver_for_all_platforms.sh -f
|
||||
./scripts/generate_api.sh
|
||||
./scripts/update_readme.sh
|
||||
scripts/roll_driver.sh [version]
|
||||
```
|
||||
|
||||
### Code Style
|
||||
|
||||
@ -2,8 +2,8 @@
|
||||
|
||||
* make sure to have at least Java 8 and Maven 3.6.3
|
||||
* clone playwright for java: http://github.com/microsoft/playwright-java
|
||||
* set new driver version in `scripts/CLI_VERSION`
|
||||
* regenerate API: `./scripts/download_driver_for_all_platforms.sh -f && ./scripts/generate_api.sh && ./scripts/update_readme.sh`
|
||||
* set new driver version in `scripts/DRIVER_VERSION`
|
||||
* regenerate API: `./scripts/download_driver.sh -f && ./scripts/generate_api.sh && ./scripts/update_readme.sh`
|
||||
* commit & send PR with the roll
|
||||
|
||||
### Finding driver version
|
||||
|
||||
57
scripts/download_driver.sh
Executable file
57
scripts/download_driver.sh
Executable file
@ -0,0 +1,57 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
set +x
|
||||
|
||||
trap "cd $(pwd -P)" EXIT
|
||||
cd "$(dirname $0)"
|
||||
|
||||
if [[ ($1 == '-h') || ($1 == '--help') ]]; then
|
||||
echo ""
|
||||
echo "This script for downloading playwright driver for all platforms."
|
||||
echo "The downloaded files will be put under 'driver-bundle/src/main/resources/driver'."
|
||||
echo ""
|
||||
echo "Usage: scripts/download_driver.sh [option]"
|
||||
echo ""
|
||||
echo "Options:"
|
||||
echo " -h, --help display help information"
|
||||
echo ""
|
||||
exit 0
|
||||
fi
|
||||
|
||||
DRIVER_VERSION=$(head -1 ./DRIVER_VERSION)
|
||||
FILE_PREFIX=playwright-$DRIVER_VERSION
|
||||
|
||||
cd ../driver-bundle/src/main/resources
|
||||
|
||||
if [[ -d 'driver' ]]; then
|
||||
echo "Deleting existing drivers from $(pwd)"
|
||||
rm -rf driver
|
||||
fi
|
||||
|
||||
mkdir -p driver
|
||||
cd driver
|
||||
|
||||
for PLATFORM in mac mac-arm64 linux linux-arm64 win32_x64
|
||||
do
|
||||
FILE_NAME=$FILE_PREFIX-$PLATFORM.zip
|
||||
mkdir $PLATFORM
|
||||
cd $PLATFORM
|
||||
echo "Downloading driver for $PLATFORM to $(pwd)"
|
||||
|
||||
URL=https://playwright.azureedge.net/builds/driver
|
||||
if [[ "$DRIVER_VERSION" == *-alpha* || "$DRIVER_VERSION" == *-beta* || "$DRIVER_VERSION" == *-next* ]]; then
|
||||
URL=$URL/next
|
||||
fi
|
||||
URL=$URL/$FILE_NAME
|
||||
echo "Using url: $URL"
|
||||
curl -O $URL
|
||||
unzip $FILE_NAME -d .
|
||||
rm $FILE_NAME
|
||||
|
||||
cd -
|
||||
done
|
||||
|
||||
echo ""
|
||||
echo "All drivers have been successfully downloaded."
|
||||
echo ""
|
||||
@ -1,63 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
set +x
|
||||
|
||||
trap "cd $(pwd -P)" EXIT
|
||||
cd "$(dirname $0)"
|
||||
|
||||
if [[ ($1 == '-h') || ($1 == '--help') ]]; then
|
||||
echo ""
|
||||
echo "This script for downloading playwright-cli binaries for all platforms."
|
||||
echo "The downloaded files will be put into directory 'driver-bundle/src/main/resources/driver'."
|
||||
echo ""
|
||||
echo "Usage: scripts/download_driver_for_all_platforms.sh [option]"
|
||||
echo ""
|
||||
echo "Options:"
|
||||
echo " -h, --help display help information"
|
||||
echo " -f, --force delete existing drivers and download them again"
|
||||
echo ""
|
||||
exit 0
|
||||
fi
|
||||
|
||||
CLI_VERSION=$(head -1 ./CLI_VERSION)
|
||||
FILE_PREFIX=playwright-$CLI_VERSION
|
||||
|
||||
cd ../driver-bundle/src/main/resources
|
||||
|
||||
if [[ ($1 == '-f') || ($1 == '--force') ]]; then
|
||||
echo "Deleting existing drivers from $(pwd)"
|
||||
rm -rf driver
|
||||
fi
|
||||
|
||||
mkdir -p driver
|
||||
cd driver
|
||||
|
||||
for PLATFORM in mac mac-arm64 linux linux-arm64 win32_x64
|
||||
do
|
||||
FILE_NAME=$FILE_PREFIX-$PLATFORM.zip
|
||||
if [[ -d $PLATFORM ]]; then
|
||||
echo "Skipping driver download for $PLATFORM ($(pwd)/$PLATFORM already exists)"
|
||||
continue
|
||||
fi
|
||||
mkdir $PLATFORM
|
||||
cd $PLATFORM
|
||||
echo "Downloading driver for $PLATFORM to $(pwd)"
|
||||
|
||||
URL=https://playwright.azureedge.net/builds/driver
|
||||
if [[ "$CLI_VERSION" == *-alpha* || "$CLI_VERSION" == *-beta* || "$CLI_VERSION" == *-next* ]]; then
|
||||
URL=$URL/next
|
||||
fi
|
||||
URL=$URL/$FILE_NAME
|
||||
echo "Using url: $URL"
|
||||
curl -O $URL
|
||||
unzip $FILE_NAME -d .
|
||||
rm $FILE_NAME
|
||||
|
||||
cd -
|
||||
done
|
||||
|
||||
echo ""
|
||||
echo "All drivers have been downloaded successfully, use '-f' or '--force' option to delete and download them again if you want."
|
||||
echo "For more details, you can use '-h' or '--help' option, or read the CONTRIBUTING.md for reference."
|
||||
echo ""
|
||||
27
scripts/roll_driver.sh
Executable file
27
scripts/roll_driver.sh
Executable file
@ -0,0 +1,27 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
set +x
|
||||
|
||||
trap "cd $(pwd -P)" EXIT
|
||||
cd "$(dirname $0)"
|
||||
|
||||
if [ "$#" -ne 1 ]; then
|
||||
echo ""
|
||||
echo "Usage: scripts/roll_driver.sh [new version]"
|
||||
echo ""
|
||||
exit 1
|
||||
fi
|
||||
|
||||
NEW_VERSION=$1
|
||||
CURRENT_VERSION=$(head -1 ./DRIVER_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;
|
||||
|
||||
./generate_api.sh
|
||||
./update_readme.sh
|
||||
@ -15,14 +15,14 @@ mvn exec:java -e -Dexec.mainClass=com.microsoft.playwright.CLI -Dexec.args="--ve
|
||||
echo "Running TestApp..."
|
||||
mvn compile exec:java -e -Dexec.mainClass=com.microsoft.playwright.testcliversion.TestApp 2>&1 | tee ${TMP_DIR}/app.txt
|
||||
|
||||
CLI_VERSION=$(cat ${TMP_DIR}/cli.txt | tail -n 1 | cut -d\ -f2)
|
||||
DRIVER_VERSION=$(cat ${TMP_DIR}/cli.txt | tail -n 1 | cut -d\ -f2)
|
||||
PACKAGE_VERSION=$(cat ${TMP_DIR}/app.txt | grep ImplementationVersion | cut -d\ -f2)
|
||||
|
||||
rm -rf $TMP_DIR
|
||||
|
||||
echo "Comparing versions: ${CLI_VERSION} and ${PACKAGE_VERSION}"
|
||||
echo "Comparing versions: ${DRIVER_VERSION} and ${PACKAGE_VERSION}"
|
||||
|
||||
if [[ "$CLI_VERSION" == "$PACKAGE_VERSION" ]];
|
||||
if [[ "$DRIVER_VERSION" == "$PACKAGE_VERSION" ]];
|
||||
then
|
||||
echo "SUCCESS.";
|
||||
else
|
||||
|
||||
@ -41,7 +41,7 @@ RUN mkdir /ms-playwright && \
|
||||
COPY . /tmp/pw-java
|
||||
|
||||
RUN cd /tmp/pw-java && \
|
||||
./scripts/download_driver_for_all_platforms.sh && \
|
||||
./scripts/download_driver.sh && \
|
||||
mvn install -D skipTests --no-transfer-progress && \
|
||||
DEBIAN_FRONTEND=noninteractive mvn exec:java -e -D exec.mainClass=com.microsoft.playwright.CLI \
|
||||
-D exec.args="install-deps" -f playwright/pom.xml --no-transfer-progress && \
|
||||
|
||||
@ -41,7 +41,7 @@ RUN mkdir /ms-playwright && \
|
||||
COPY . /tmp/pw-java
|
||||
|
||||
RUN cd /tmp/pw-java && \
|
||||
./scripts/download_driver_for_all_platforms.sh && \
|
||||
./scripts/download_driver.sh && \
|
||||
mvn install -D skipTests --no-transfer-progress && \
|
||||
DEBIAN_FRONTEND=noninteractive mvn exec:java -e -D exec.mainClass=com.microsoft.playwright.CLI \
|
||||
-D exec.args="install-deps" -f playwright/pom.xml --no-transfer-progress && \
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user