Skip to content

Commit

Permalink
Bundle all ChromeDrivers when publishing
Browse files Browse the repository at this point in the history
  • Loading branch information
imurchie committed Feb 14, 2014
1 parent 68135c3 commit d266d4b
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 18 deletions.
2 changes: 1 addition & 1 deletion bin/publish.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ fi

set -e
git pull upstream master
./reset.sh --hardcore --real-safari
./reset.sh --hardcore --real-safari --chromedriver-install-all --chromedriver-version 2.8
npm publish
version=$(cat package.json | underscore extract version | sed 's/\"//g')
git tag -a "v$version" -m "tag appium@$version for npm publish"
Expand Down
11 changes: 11 additions & 0 deletions lib/devices/android/chrome.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ var Android = require('./android.js')
, async = require('async')
, through = require('through')
, isWindows = require('../../helpers.js').isWindows()
, isMac = require('../../helpers.js').isMac()
, isLinux = require('../../helpers.js').isLinux()
, ADB = require('./adb.js')
, path = require('path')
, fs = require('fs');
Expand Down Expand Up @@ -53,6 +55,15 @@ ChromeAndroid.prototype.unlock = function (cb) {

ChromeAndroid.prototype.ensureChromedriverExists = function (cb) {
logger.info("Ensuring Chromedriver exists");
var executable = isWindows ? "chromedriver.exe" : "chromedriver";
var platform = "mac";
if (isWindows) {
platform = "windows";
} else if (isLinux) {
platform = "linux";
}
this.chromedriver = path.resolve(__dirname, "..", "..", "..", "build", "chromedriver", platform, executable);

fs.exists(this.chromedriver, function (exists) {
if (!exists) return cb(new Error("Could not find chromedriver. Need to run reset script?"));
cb();
Expand Down
14 changes: 10 additions & 4 deletions reset.bat
Original file line number Diff line number Diff line change
Expand Up @@ -91,18 +91,24 @@ if %doAndroid% == 1 (

:: Reset ChromeDriver
echo =====Resetting ChromeDriver=====
SET "chromedriver_build_directory=.\build\chromedriver\windows"
echo Building directory structure
IF NOT EXIST .\build CALL :runCmd "mkdir %chromedriver_build_directory%"
IF NOT EXIST .\build\chromedriver CALL :runCmd "mkdir %chromedriver_build_directory%"
IF NOT EXIST .\build\chromedriver\windows CALL :runCmd "mkdir %chromedriver_build_directory%"

echo Removing old files
IF EXIST .\build\chromedriver.zip CALL :runCmd "del .\build\chromedriver.zip"
IF EXIST .\build\chromedriver.exe CALL :runCmd "del .\build\chromedriver.exe"
IF EXIST %chromedriver_build_directory%\chromedriver.zip CALL :runCmd "del %chromedriver_build_directory%\chromedriver.zip"
IF EXIST %chromedriver_build_directory%\chromedriver.exe CALL :runCmd "del %chromedriver_build_directory%\chromedriver.exe"

IF NOT DEFINED chromedriver_version (
echo Finding latest version
for /f "delims=" %%a in ('curl -L http://chromedriver.storage.googleapis.com/LATEST_RELEASE') do SET "chromedriver_version=%%a"
)

echo Downloading and installing version %chromedriver_version%
CALL :runCmd "curl -L http://chromedriver.storage.googleapis.com/%chromedriver_version%/chromedriver_win32.zip -o .\build\chromedriver.zip"
CALL :runCmd "PUSHD .\build"
CALL :runCmd "curl -L http://chromedriver.storage.googleapis.com/%chromedriver_version%/chromedriver_win32.zip -o %chromedriver_build_directory%\chromedriver.zip"
CALL :runCmd "PUSHD %chromedriver_build_directory%"
CALL :runCmd "unzip chromedriver.zip"
CALL :runCmd "del chromedriver.zip"
CALL :runCmd "POPD"
Expand Down
52 changes: 39 additions & 13 deletions reset.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ hardcore=false
grunt="$(npm bin)/grunt" # might not have grunt-cli installed with -g
verbose=false
chromedriver_version=false
chromedriver_install_all=false

while test $# != 0
do
Expand All @@ -42,6 +43,7 @@ do
"--verbose") verbose=true;;
"--hardcore") hardcore=true;;
"--chromedriver-version") chromedriver_version=$2;;
"--chromedriver-install-all") chromedriver_install_all=true;;
esac

if [[ -n "$2" ]] && [[ "$2" != --* ]]; then
Expand Down Expand Up @@ -385,26 +387,50 @@ reset_gappium() {

reset_chromedriver() {
echo "RESETTING CHROMEDRIVER"
if [ -f $appium_home/build/chromedriver ]; then
echo "* Clearing old program"
run_cmd rm $appium_home/build/chromedriver
if [ -d $appium_home/build/chromedriver ]; then
echo "* Clearing old ChromeDriver(s)"
run_cmd rm -rf $appium_home/build/chromedriver/*
else
run_cmd mkdir $appium_home/build/chromedriver
fi
if [ "$chromedriver_version" == false ]; then
echo "* Finding latest version"
chromedriver_version=$(run_cmd_output curl -L http://chromedriver.storage.googleapis.com/LATEST_RELEASE)
fi
echo "* Determining platform"
platform=$(run_cmd_output uname -s)
if [ "$platform" == "Darwin" ]; then
platform="Mac"
chromedriver_file="chromedriver_mac32.zip"
if ! $chromedriver_install_all ; then
echo "* Determining platform"
platform=$(run_cmd_output uname -s)
if [ "$platform" == "Darwin" ]; then
platform="mac"
chromedriver_file="chromedriver_mac32.zip"
run_cmd mkdir $appium_home/build/chromedriver/mac
else
platform="linux"
chromedriver_file="chromedriver_linux32.zip"
run_cmd mkdir $appium_home/build/chromedriver/linux
fi
install_chromedriver $platform $chromedriver_version $chromedriver_file
else
platform="Linux"
chromedriver_file="chromedriver_linux32.zip"
echo "* Building directory structure"
run_cmd mkdir $appium_home/build/chromedriver/mac
run_cmd mkdir $appium_home/build/chromedriver/linux
run_cmd mkdir $appium_home/build/chromedriver/windows

install_chromedriver "mac" $chromedriver_version "chromedriver_mac32.zip"
install_chromedriver "linux" $chromedriver_version "chromedriver_linux32.zip"
install_chromedriver "windows" $chromedriver_version "chromedriver_win32.zip"
fi
echo "* Downloading ChromeDriver version $chromedriver_version for $platform"
run_cmd curl -L http://chromedriver.storage.googleapis.com/$chromedriver_version/$chromedriver_file -o ./build/chromedriver.zip
run_cmd pushd ./build
}

install_chromedriver() {
platform=$1
version=$2
file=$3

echo "* Downloading ChromeDriver version $version for $platform"
run_cmd curl -L http://chromedriver.storage.googleapis.com/$version/$file -o $appium_home/build/chromedriver/$platform/chromedriver.zip
run_cmd pushd $appium_home/build/chromedriver/$platform

echo "* Unzipping ChromeDriver"
run_cmd unzip chromedriver.zip
run_cmd rm chromedriver.zip
Expand Down

0 comments on commit d266d4b

Please sign in to comment.