Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Running Laravel Dusk in BitBucket Pipelines

Rachel Lee August 9, 2017

I am trying to setup a Laravel 5.4 project in BitBucket Pipelines, with Laravel Dusk test scripts. However, I can't seem to get a successful build. After fixing several issues and finally getting my build to run my test scripts, I am not stuck at :

Screen Shot 2017-08-09 at 5.00.04 PM.png

 

How do I get the Chrome Wed Driver to launch and run the test?

3 answers

1 accepted

0 votes
Answer accepted
Angelo Maragna August 17, 2017

There are a couple of issue to address. I faced the same but finally got it working.

The main issue are the chrome drivers and the options to use to fire chrome.

The linux driver is a binary, so it may not be compatible with all the distros. And chrome has to be run in headless mode without gpu.

 

Have a look at the documentation of this docker image:

https://hub.docker.com/r/angelomaragna/networld-dusk/

I built it from Alpine, and with it (395MB unfortunately) I can finally run dusk tests in pipelines.

 

Angelo

Rachel Lee August 17, 2017

Hi @Angelo Maragna, I tried to create a new container for testing using the container link you gave but it was returning me the following error:

Unable to find image 'networld-dusk:latest' locally
docker: Error response from daemon: repository networld-dusk not found: does not exist or no pull access.

So instead, I tried by using the steps described in the link with my existing container that is set up with php7-fpm and is still unable to get my test to run successfully.

Angelo Maragna August 18, 2017

Error in my documentation. "networld-dusk" is available on my local becasue I compiled it.

Please use "angelomaragna/networld-dusk" like in

docker run --privileged --name dusk -ti angelomaragna/networld-dusk /bin/sh

Angelo Maragna August 18, 2017

This is my bitbucket-pipelines.yml file (you can check that file also inside the docker container)

image: angelomaragna/networld-dusk

pipelines:
  default:
    - step:
        script:
          - rm vendor/laravel/dusk/bin/chromedriver-linux
          # Laravel Dusk driver is not compatible so we replace it with the Alpine one
          - ln -s /usr/lib/chromium/chromedriver vendor/laravel/dusk/bin/chromedriver-linux
          - vendor/laravel/dusk/bin/chromedriver-linux &
          - cp .env.example .env
          - php artisan dusk 

Rachel Lee August 30, 2017

Hi @Angelo Maragna

I finally had the time to give this another try and after many rounds of trial and error, I finally got my first successful build!

Using your image and bitbucket-pipelines.yml as a guide, I had to install a few additional packages in order for things to fully work. Here's the final version of my bitbucket-pipelines.yml file:

image: angelomaragna/networld-dusk

pipelines:
  branches:
    develop:
    - step:
        caches:
            - composer
        script:
          - apk update && apk add php7-xmlwriter php7-pdo_mysql php7-session php7-ctype
          - curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
          - cp .env.example .env
          - composer install
          - rm vendor/laravel/dusk/bin/chromedriver-linux
          # Replace Laravel Dusk driver Alpine's
          - ln -s /usr/lib/chromium/chromedriver vendor/laravel/dusk/bin/chromedriver-linux
          - vendor/laravel/dusk/bin/chromedriver-linux &
          - export DB_CONNECTION=mysql
          - php artisan key:generate
          - php artisan migrate
          - php artisan dusk
          - vendor/bin/phpunit
services:
          - mysq

Thanks for the help!

Like Monica Gordillo likes this
Paul Cable May 21, 2018

Thanks for posting this. I tried to get it going but ran into some issues. For anyone else who's following along you'll need to change the apk repository from edge to v3.7

FROM angelomaragna/networld-dusk:latest
RUN echo http://dl-cdn.alpinelinux.org/alpine/v3.7/main > /etc/apk/repositories &&\
echo http://dl-cdn.alpinelinux.org/alpine/v3.7/community >> /etc/apk/repositories &&\
apk update &&\
apk add php7-xmlwriter php7-pdo_mysql php7-session php7-ctype php7-fileinfo &&\
curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
0 votes
Gary Corcoran February 15, 2022

Also looking for a pipeline for dusk, may have to move to other CI applications.

Anyone have a solution?

0 votes
Ramesh Mhetre August 20, 2019

Do we still have to try with this solution or is there a better version now?

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events