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

Comments

Projects
None yet
@habdelra

habdelra commented Feb 12, 2015

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

This comment has been minimized.

Show comment
Hide comment
@BanzaiMan

BanzaiMan Feb 12, 2015

Member

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

Member

BanzaiMan commented Feb 12, 2015

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

@msridhar

This comment has been minimized.

Show comment
Hide comment
@msridhar

msridhar Feb 12, 2015

@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.

msridhar commented Feb 12, 2015

@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

This comment has been minimized.

Show comment
Hide comment
@BanzaiMan

BanzaiMan Feb 13, 2015

Member

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.

Member

BanzaiMan commented Feb 13, 2015

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

This comment has been minimized.

Show comment
Hide comment
@BanzaiMan

BanzaiMan Mar 2, 2015

Member

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.

Member

BanzaiMan commented Mar 2, 2015

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

This comment has been minimized.

Show comment
Hide comment
@parndt

parndt Mar 2, 2015

Contributor

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.

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

This comment has been minimized.

Show comment
Hide comment
@BanzaiMan

BanzaiMan Mar 2, 2015

Member

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

Member

BanzaiMan commented Mar 2, 2015

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

@parndt

This comment has been minimized.

Show comment
Hide comment
@parndt

parndt Mar 3, 2015

Contributor

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

Contributor

parndt commented Mar 3, 2015

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

@BanzaiMan

This comment has been minimized.

Show comment
Hide comment
@BanzaiMan

BanzaiMan Mar 3, 2015

Member

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

Member

BanzaiMan commented Mar 3, 2015

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

@esbanarango

This comment has been minimized.

Show comment
Hide comment
@esbanarango

esbanarango commented Mar 11, 2015

👍

@Thibaut

This comment has been minimized.

Show comment
Hide comment
@Thibaut

Thibaut Mar 28, 2015

I'm leaning towards offering both 1.9.8 and 2.0.0.

👍

Thibaut commented Mar 28, 2015

I'm leaning towards offering both 1.9.8 and 2.0.0.

👍

@BanzaiMan

This comment has been minimized.

Show comment
Hide comment
@BanzaiMan

BanzaiMan Apr 6, 2015

Member

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.

Member

BanzaiMan commented Apr 6, 2015

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

This comment has been minimized.

Show comment
Hide comment
@BanzaiMan

BanzaiMan Apr 28, 2015

Member

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.

Member

BanzaiMan commented Apr 28, 2015

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

This comment has been minimized.

Show comment
Hide comment
@robcolburn

robcolburn commented May 27, 2015

@BanzaiMan any update?

@BanzaiMan

This comment has been minimized.

Show comment
Hide comment
@BanzaiMan

BanzaiMan Jun 8, 2015

Member

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

Member

BanzaiMan commented Jun 8, 2015

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

@blimmer

This comment has been minimized.

Show comment
Hide comment
@blimmer

blimmer 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

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

This comment has been minimized.

Show comment
Hide comment
@armandocanals

armandocanals Jun 28, 2015

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.

armandocanals commented Jun 28, 2015

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.

amaia added a commit to medialab-prado/consul that referenced this issue Dec 6, 2016

amaia added a commit to medialab-prado/consul that referenced this issue Dec 6, 2016

dylanfprice added a commit to dylanfprice/angular-gm that referenced this issue Jan 4, 2017

tagliala added a commit to diowa/icare that referenced this issue Jan 10, 2017

tagliala added a commit to diowa/icare that referenced this issue Jan 10, 2017

amaia added a commit to medialab-prado/consul that referenced this issue Jan 12, 2017

amaia added a commit to medialab-prado/consul that referenced this issue Jan 19, 2017

amaia added a commit to medialab-prado/consul that referenced this issue Jan 19, 2017

amaia added a commit to medialab-prado/consul that referenced this issue Jan 19, 2017

amaia added a commit to medialab-prado/consul that referenced this issue Jan 20, 2017

@nathanl

This comment has been minimized.

Show comment
Hide comment
@nathanl

nathanl 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.

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.

@adriaanvanrossum

This comment has been minimized.

Show comment
Hide comment
@adriaanvanrossum

adriaanvanrossum Mar 8, 2017

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

adriaanvanrossum commented Mar 8, 2017

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

@nathanl

This comment has been minimized.

Show comment
Hide comment
@nathanl

nathanl 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 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

This comment has been minimized.

Show comment
Hide comment
@nathanl

nathanl 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 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

This comment has been minimized.

Show comment
Hide comment
@nathanl

nathanl 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

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

This comment has been minimized.

Show comment
Hide comment
@BBonifield

BBonifield Mar 24, 2017

@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.

BBonifield commented Mar 24, 2017

@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

This comment has been minimized.

Show comment
Hide comment
@chadwhitacre

chadwhitacre Mar 24, 2017

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.

chadwhitacre commented Mar 24, 2017

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.

ixti added a commit to sensortower/sidekiq-throttled that referenced this issue Apr 2, 2017

@waghanza waghanza referenced this issue May 2, 2017

Closed

Use phantomjs2 #2873

@BanzaiMan

This comment has been minimized.

Show comment
Hide comment
@BanzaiMan

BanzaiMan Oct 7, 2017

Member

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.

Member

BanzaiMan commented Oct 7, 2017

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.

@BanzaiMan BanzaiMan closed this Oct 7, 2017

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