Skip to content

Commit 81221d4

Browse files
authored
devops: cache downloaded drivers (microsoft#122)
1 parent e8ff2bc commit 81221d4

File tree

3 files changed

+31
-15
lines changed

3 files changed

+31
-15
lines changed

.github/workflows/test.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,13 @@ jobs:
2626
path: ~/.m2
2727
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
2828
restore-keys: ${{ runner.os }}-m2
29-
- name: Install driver
29+
- name: Cache Downloaded Drivers
30+
uses: actions/cache@v2
31+
with:
32+
path: driver-bundle/src/main/resources/driver
33+
key: ${{ runner.os }}-drivers-${{ hashFiles('scripts/*') }}
34+
restore-keys: ${{ runner.os }}-drivers
35+
- name: Download drivers
3036
shell: bash
3137
run: scripts/download_driver_for_all_platforms.sh
3238
- name: Build with Maven

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ git clone https://github.com/microsoft/playwright-java
1111
cd playwright-java
1212
```
1313

14-
2. Run the following script to download playwright-cli binary for your platform into `driver/src/main/resources/driver/` directory. It will also install Playwright and download browser binaries for Chromium, Firefox and WebKit.
14+
2. Run the following script to download playwright-cli binaries for all platforms into `driver-bundle/src/main/resources/driver/` directory. It will also install Playwright and download browser binaries for Chromium, Firefox and WebKit.
1515

1616
```bash
17-
scripts/install_local_driver.sh
17+
scripts/download_driver_for_all_platforms.sh
1818
```
1919

2020
Names of published driver archives can be found at https://github.com/microsoft/playwright-cli/actions

scripts/install_local_driver.sh

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,39 +9,49 @@ cd "$(dirname $0)"
99
CLI_VERSION=$(head -1 ./CLI_VERSION)
1010
FILE_PREFIX=playwright-cli-$CLI_VERSION
1111

12-
cd ../driver/src/main/resources
12+
cd ../driver-bundle/src/main/resources
13+
1314
if [[ -d local-driver ]]; then
1415
echo "$(pwd)/driver already exists, delete it first"
1516
exit 1;
1617
fi
1718

18-
mkdir local-driver
19-
cd local-driver
20-
echo "Created directory: $(pwd)"
21-
22-
FILE_NAME="unknown"
19+
PLATFORM="unknown"
2320
case $(uname) in
2421
Darwin)
25-
FILE_NAME=${FILE_PREFIX}-mac.zip
22+
PLATFORM=mac
2623
echo "Downloading driver for macOS"
2724
;;
2825
Linux)
29-
FILE_NAME=${FILE_PREFIX}-linux.zip
26+
PLATFORM=linux
3027
echo "Downloading driver for Linux"
3128
;;
3229
MINGW32*)
33-
FILE_NAME=${FILE_PREFIX}-win32.zip
34-
echo "Downloading driver for Windows"
30+
PLATFORM=win32
31+
echo "Downloading driver for Win32"
3532
;;
3633
MINGW64*)
37-
FILE_NAME=${FILE_PREFIX}-win32_x64.zip
38-
echo "Downloading driver for Windows"
34+
PLATFORM=win32_x64
35+
echo "Downloading driver for Win64"
36+
;;
3937
*)
4038
echo "Unknown platform '$(uname)'"
4139
exit 1;
4240
;;
4341
esac
4442

43+
mkdir -p driver
44+
cd driver
45+
if [[ -d $PLATFORM ]]; then
46+
echo "$(pwd)/$PLATFORM already exists, delete it first"
47+
exit 1
48+
fi
49+
mkdir $PLATFORM
50+
cd $PLATFORM
51+
52+
FILE_NAME=$FILE_PREFIX-$PLATFORM.zip
53+
echo "Downloading driver for $PLATFORM to $(pwd)"
54+
4555
curl -O https://playwright.azureedge.net/builds/cli/next/${FILE_NAME}
4656
unzip ${FILE_NAME} -d .
4757
rm $FILE_NAME

0 commit comments

Comments
 (0)