Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for PhantomJS 2.0 #3225

Closed
habdelra opened this issue Feb 12, 2015 · 72 comments
Closed

Add support for PhantomJS 2.0 #3225

habdelra opened this issue Feb 12, 2015 · 72 comments
Assignees

Comments

@habdelra
Copy link

For our build environment we want to start using PhantomJS 2.0 to address stability problems we are encountering with PhantomJS 1.9.7 randomly crashing. Currently only phantomjs 1.9.7 is available in the build environment. Building phantomjs manually as part of our build is not feasible as it requires us running apt-get for the necessarily dependencies, and the build takes multiple hours to run in order to compile phantom JS.

It would be great if the PhantomJS 2.0 binary was available in the build environment. I think it would make sense to have multiple ver of phantomjs available, where we could set a property in our .travis.yml to select the version we want to use.

thanks!

@BanzaiMan
Copy link
Contributor

We should have PhantomJS 1.9.8 at the moment. What breaking changes does 2.0 bring?

@msridhar
Copy link

@BanzaiMan see the release notes; removal of CoffeeScript support is one breaking change listed there. A big plus for 2.0 is that it is based on a much more recent version of WebKit, which I imagine makes it applicable in more scenarios.

@BanzaiMan
Copy link
Contributor

There is no official binary available yet. (ariya/phantomjs#12948) The process is a major resource hog, and it is not feasible to compile it on the fly. If it's still not available for the next update (1st week of April), we can compile a binary separately for our purposes.

@BanzaiMan BanzaiMan self-assigned this Feb 28, 2015
@BanzaiMan
Copy link
Contributor

For those brave souls who want to try PhantomJS 2.0.0 now, you can use https://s3.amazonaws.com/travis-phantomjs/phantomjs-2.0.0-ubuntu-12.04.tar.bz2. The archive expands to the binary phantomjs for Ubuntu 12.04 64-bit, and the license file to comply with PhantomJS's BSD license.

@parndt
Copy link
Contributor

parndt commented Mar 2, 2015

PhantomJS fails many tests that pass on PhantomJS 1.9.8 for me, due to the reasons outlined in teampoltergeist/poltergeist#574 / ariya/phantomjs#12506 / teampoltergeist/poltergeist#585

File upload doesn't seem to work consistently.

@BanzaiMan
Copy link
Contributor

@parndt In a way, then, these are expected failures with PhantomJS 2.0.0, correct?

@parndt
Copy link
Contributor

parndt commented Mar 3, 2015

@BanzaiMan yes, I'm just vocalising objection to upgrading the default version until they're worked out.

@BanzaiMan
Copy link
Contributor

@parndt Got it. I'm leaning towards offering both 1.9.8 and 2.0.0.

@esbanarango
Copy link

👍

@Thibaut
Copy link

Thibaut commented Mar 28, 2015

I'm leaning towards offering both 1.9.8 and 2.0.0.

👍

@BanzaiMan
Copy link
Contributor

See travis-ci/travis-cookbooks@e38732d. It will be available as /usr/local/phantomjs-2.0.0/bin/phantomjs. 1.9.8 remains the default.

@BanzaiMan
Copy link
Contributor

Sorry about the high hopes, but we have decided to cancel the 2015-04 updates, due to issues unrelated to PhantomJS 2.0.

If you want to use it now, you can grab it from S3 as indicated above.

@robcolburn
Copy link

@BanzaiMan any update?

@BanzaiMan
Copy link
Contributor

@robcolburn I miss this comment. We are working on the next updates, but we don't have the concrete date for them yet.

@blimmer
Copy link

blimmer commented Jun 9, 2015

Our test suite fails without Phantom 2. To work around this, we do the following:

install:
  - mkdir travis-phantomjs
  - wget https://s3.amazonaws.com/travis-phantomjs/phantomjs-2.0.0-ubuntu-12.04.tar.bz2 -O $PWD/travis-phantomjs/phantomjs-2.0.0-ubuntu-12.04.tar.bz2
  - tar -xvf $PWD/travis-phantomjs/phantomjs-2.0.0-ubuntu-12.04.tar.bz2 -C $PWD/travis-phantomjs
  - export PATH=$PWD/travis-phantomjs:$PATH

@armandocanals
Copy link

I ended up packaging PhantomJS 2.0 from source into a debian file (deb package) to make my life easier.

Ubuntu 12.04 64-bit (precise)
https://packagecloud.io/armando/phantomjs/packages/ubuntu/precise/phantomjs_2.0.0_amd64.deb

Ubuntu 14.04 64-bit (trusty)
https://packagecloud.io/armando/phantomjs/packages/ubuntu/trusty/phantomjs_2.0.0_amd64.deb

Ubuntu 14.10 64-bit (utopic)
https://packagecloud.io/armando/phantomjs/packages/ubuntu/utopic/phantomjs_2.0.0_amd64.deb

I hope this helps someone along the way.

@Jell
Copy link

Jell commented Jul 13, 2015

any update on this?

@nathanl
Copy link

nathanl commented Mar 8, 2017

@BigAB I updated the script above and tested it with clearing the Travis cache. The first time you run this script you will see the output of the last phantomjs --version as the wrong version, but the right one is installed.

@harianus I observed this, too. I even saw that $(which phantomjs) --version was different from phantomjs --version, which I couldn't understand because they should both consult $PATH.

Then I remembered that the shell has a cache for where it finds commands. hash -d phantomjs says "forget where you found it before; look for it in $PATH again", and made it find the right one for me.

@adriaandotcom
Copy link

Thanks, @nathanl, I updated the script to include hash -d phantomjs.

@nathanl
Copy link

nathanl commented Mar 8, 2017

@harianus Whoops, I had used hash -d in debug mode but not in .travis.yml as you show. That made my build fail. The line - "hash -d phantomjs || true" works though - it's like, "clear the cache if you can, and if not, don't worry about it."

@nathanl
Copy link

nathanl commented Mar 9, 2017

If anybody is worried about downloading the phantomjs binary from an unfamiliar site, you could compare the file hash with the original one. Running sha512sum phantomjs-2.1.1-linux-x86_64.tar.bz2 on the copy I get from wget https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-linux-x86_64.tar.bz2 -O phantomjs-2.1.1-linux-x86_64.tar.bz2 gives me 039b62ecf2fa4196357e129727871a53b046948e17b21900c78a1af4d0b523e41b9d4137e7454b0a638333d7fc27e65d14f4af8c665e982a504c12f828525419 officialphantomjs.tar.bz. Running this on the content I get from https://assets.membergetmember.co/software/phantomjs-2.1.1-linux-x86_64.tar.bz2 gives me the same hash, currently.

If anyone else can attest that this is the correct hash value for the original, please do.

@nathanl
Copy link

nathanl commented Mar 9, 2017

Here's an installation method that automatically checks the downloaded binary's SHA512 against the one of the official package (as seen by me - others can confirm/deny that it's the correct SHA512).

sudo: false

cache:
  directories:
    - "travis_phantomjs"

before_install:
  # Ensure we have newer version of PhantomJS to fix weird test failures from 1.9.8
  - export TRAVIS_PHANTOMJS_INSTALL_PATH="$PWD/travis_phantomjs"
  - export TRAVIS_PHANTOMJS_VERSION_NAME="phantomjs-2.1.1-linux-x86_64"
  - export PATH="$TRAVIS_PHANTOMJS_INSTALL_PATH/$TRAVIS_PHANTOMJS_VERSION_NAME/bin:$PATH"
  - hash -d phantomjs || true
  - echo "phantomjs version is $(phantomjs --version)"
  - if [ $(phantomjs --version) != '2.1.1' ]; then $PWD/bin/travis_get_updated_phantomjs; hash -d phantomjs || true; echo "updated phantomjs version is $(phantomjs --version)"; fi

It relies on the presence of $PWD/bin/travis_get_updated_phantomjs, which is this shell script, adapted from the solution @harianus provided:

#!/usr/bin/env bash
# Script to ensure we're using an updated version of PhantomJS when testing on Travis
set -e

if [ -z "$TRAVIS_PHANTOMJS_INSTALL_PATH" ]; then
  echo "must set env var TRAVIS_PHANTOMJS_INSTALL_PATH"
  exit 1
fi
if [ -z "$TRAVIS_PHANTOMJS_VERSION_NAME" ]; then
  echo "must set env var TRAVIS_PHANTOMJS_VERSION_NAME"
  exit 1
fi

BINARY_FILENAME="$TRAVIS_PHANTOMJS_VERSION_NAME.tar.bz2"
DOWNLOAD_FILENAME="$TRAVIS_PHANTOMJS_INSTALL_PATH/$BINARY_FILENAME"
BIN_PATH="$TRAVIS_PHANTOMJS_INSTALL_PATH/$TRAVIS_PHANTOMJS_VERSION_NAME/bin"
EXPECTED_SHA512="039b62ecf2fa4196357e129727871a53b046948e17b21900c78a1af4d0b523e41b9d4137e7454b0a638333d7fc27e65d14f4af8c665e982a504c12f828525419"

rm -rf $TRAVIS_PHANTOMJS_INSTALL_PATH
mkdir -p $TRAVIS_PHANTOMJS_INSTALL_PATH

echo "downloading requested phantomjs binary '$BINARY_FILENAME'"

# download from official location, or failing that, a mirror
# wget is availabile on MacOS via `brew install wget`
wget "https://bitbucket.org/ariya/phantomjs/downloads/$BINARY_FILENAME" -O $DOWNLOAD_FILENAME || wget "https://assets.membergetmember.co/software/$BINARY_FILENAME" -O $DOWNLOAD_FILENAME

# gsha512sum is available on MacOS via `brew install coreutils`
DOWNLOADED_SHA512=$((sha512sum $DOWNLOAD_FILENAME || gsha512sum $DOWNLOAD_FILENAME) | cut -d ' ' -f 1)

if [ "$DOWNLOADED_SHA512" == "$EXPECTED_SHA512" ]; then
  echo "download SHA confirmed - unpacking"
  tar -xvf "$DOWNLOAD_FILENAME" -C $TRAVIS_PHANTOMJS_INSTALL_PATH
  echo "sucessfully installed phantomjs in $TRAVIS_PHANTOMJS_INSTALL_PATH"
else
  echo "downloaded file had unexpected SHA512 $DOWNLOADED_SHA512"
  exit 1
fi

set +e

@BBonifield
Copy link

@nathanl It looks like Travis is already using 2.1.1 by default on the dist: trusty instances. I'm having the intermittent PhantomJS crashes with 2.1.1 as well.

@chadwhitacre
Copy link

It looks like Travis is already using 2.1.1 by default on the dist: trusty instances.

Really? I believe I am seeing 2.0.0 with dist: trusty.

@BanzaiMan
Copy link
Contributor

As this issue calls for PhantomJS 2.0, I'm closing this.

Please note that 2.1.1 can also be downloaded from bitbucket.org (http://phantomjs.org/download.html), but this is subject to the rate limiting by bitbucket.org, as previously mentioned.

For the base image installation of PhantomJS, see travis-ci/travis-cookbooks#910. When it is generally available, it should be announced in https://docs.travis-ci.com/user/build-environment-updates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests