Skip to content

Instantly share code, notes, and snippets.

@zaratedev
Created August 31, 2020 18:55
Show Gist options
  • Save zaratedev/e385c948d0344fc69c5ecc275df9d34a to your computer and use it in GitHub Desktop.
Save zaratedev/e385c948d0344fc69c5ecc275df9d34a to your computer and use it in GitHub Desktop.
Github actions for Laravel dusk
APP_NAME=Laravel
APP_ENV=local
APP_KEY=
APP_DEBUG=true
APP_URL=http://127.0.0.1:8000
BCRYPT_ROUNDS=4
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=dusk
DB_USERNAME=root
DB_PASSWORD=
BROADCAST_DRIVER=pusher
PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=us2
ANALYTICS_DRIVER=array
CACHE_DRIVER=array
FILESYSTEM_CLOUD=local
LOG_CHANNEL=single
MAIL_DRIVER=array
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
name: Continuos Integration for Laravel Dusk
on: [push]
jobs:
dusk-php:
runs-on: ubuntu-latest
services:
mysql:
image: mariadb:10.2
env:
MYSQL_ALLOW_EMPTY_PASSWORD: yes
MYSQL_DATABASE: dusk
ports:
- 3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
timeout-minutes: 30
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 1
- name: Prepare The Environment
run: cp .env.ci .env
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.2'
- name: Setup Node.js
uses: actions/setup-node@v1
with:
node-version: '12.x'
- name: Install Composer Dependencies
run: |
composer install --no-progress --no-suggest --prefer-dist --optimize-autoloader
chmod -R 777 storage bootstrap/cache
npm install
npm run production
- name: Generate Application Key
run: |
php artisan key:generate
php artisan passport:keys
- name: Upgrade Chrome Driver
run: php artisan dusk:chrome-driver
- name: Start Chrome Driver
run: ./vendor/laravel/dusk/bin/chromedriver-linux > /dev/null 2>&1 &
- name: Run Laravel Server
run: php artisan serve > /dev/null 2>&1 &
- name: Run Dusk Tests
run: |
chmod -R 0755 vendor/laravel/dusk/bin/
php artisan dusk
env:
APP_ENV: local
APP_URL: "http://127.0.0.1:8000"
DB_CONNECTION: mysql
DB_DATABASE: dusk
DB_PORT: ${{ job.services.mysql.ports[3306] }}
DB_USER: root
@u01jmg3
Copy link

u01jmg3 commented Sep 24, 2022

Thanks for this - it helped me to get started.

I'm not sure the Chrome driver needs to be started though as Dusk comes with the SupportsChrome trait which does this for you.

I also found I needed to setup Chrome (alongside Chrome driver).

- name: Setup Chrome
run: |
  sudo apt-get update
  sudo apt-get -y install libgtk2.0-0
  sudo apt-get install chromium-browser
  sudo apt-get -y install gtk2-engines-pixbuf
  Xvfb -ac :0 -screen 0 1280x1024x16 &

@adgower
Copy link

adgower commented Sep 29, 2022

I can’t get this to work:
php artisan serve —host=api.example.test

any tips?

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