CircleCI 2.0 Configuration for Laravel 5.5 with Laravel Dusk
September 11, 2017
Spent a day figuring this out. For anyone who needs help on how to configure it, here you go.
# PHP CircleCI 2.0 configuration file
# Check https://circleci.com/docs/2.0/language-php/ for more details
version: 2
jobs:
build:
docker:
- image: circleci/php:7.0-browsers
working_directory: ~/laravel
steps:
- checkout
#https://askubuntu.com/questions/594656/how-to-install-the-latest-versions-of-nodejs-and-npm
#We are using Node JS 6 because that's the current version on our local vagrant/homestead machines
- run:
name: Download NodeJS v6
command: curl -sL https://deb.nodesource.com/setup\_6.x | sudo -E bash -
#sqlite needed for laravel database
#nodejs6 needed to run \`npm run watch\` later
- run:
name: Install PHP sqlite and nodejs 6
command: sudo apt-get install -y libsqlite3-dev nodejs
# Leave this for future use if php-zip is ever required
# If you remove the flag 'composer install --ignore-platform-reqs\`
# composer will require php-zip to be installed. It appers that
# this isn't currently needed, so we are removing this from CircleCI
# to save 30 seconds of build time. The php-zip package isn't currently
# used by anything. If it ever does need to be used again, this can be
# uncommented.
#- run:
# name: Install PHP libzip-dev
# command: sudo apt-get install -y libzip-dev
#- run:
# name: Install zip package for PHP
# command: sudo docker-php-ext-install zip
- run:
name: Setup Laravel testing environment variables for CircleCI test
command: cp .env.testing .env
- run:
name: Update composer to latest version
command: composer self-update
- restore\_cache:
keys:
- composer-v1-{{ checksum "composer.json" }}
- composer-v1-
- run: composer install -n --prefer-dist --ignore-platform-reqs
- save\_cache:
key: composer-v1-{{ checksum "composer.json" }}
paths:
- vendor
- restore\_cache:
key: dependency-cache-{{ checksum "package.json" }}
- run:
name: Install NodeJS Packages
command: npm install
- save\_cache:
key: dependency-cache-{{ checksum "package.json" }}
paths:
- ./node\_modules
- run:
name: Create SQLite Database
command: touch database/database.sqlite
- run:
name: Migrate Laravel Database
command: php artisan migrate --env=testing --force
- run:
name: Compile Javascript & CSS for Browser Testing
command: npm run production
- run:
name: Start Chrome Driver
command: ./vendor/laravel/dusk/bin/chromedriver-linux
background: true
- run:
name: Run Laravel Server
command: php artisan serve
background: true
- run:
name: Test 1 - Run Phpunit for Server-Side HTTP Requests & PHP Unit Testing
command: vendor/bin/phpunit
- run:
name: Test 2 - Run Laravel Desk for Browser Testing
command: php artisan dusk