Skip to content

Instantly share code, notes, and snippets.

@pascalbaljet
Created March 24, 2024 13:53
Show Gist options
  • Save pascalbaljet/26784d28f5745b0cabd43268fd92e251 to your computer and use it in GitHub Desktop.
Save pascalbaljet/26784d28f5745b0cabd43268fd92e251 to your computer and use it in GitHub Desktop.
Run Dusk E2E Tests (GitHub Actions)
name: Run Dusk E2E Tests
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-22.04
env:
APP_URL: "http://127.0.0.1:8000"
services:
mysql:
image: mysql:8.0
env:
MYSQL_ALLOW_EMPTY_PASSWORD: yes
MYSQL_DATABASE: retailer
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
strategy:
fail-fast: true
matrix:
php: [8.3]
name: Test - P${{ matrix.php }}
steps:
- name: Check out repository code
uses: actions/checkout@v4
- name: Cache Dependencies
uses: actions/cache@v4
with:
path: ~/.composer/cache/files
key: dependencies-php-composer-${{ hashFiles('composer.lock') }}-${{ matrix.php }}
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: json, dom, curl, libxml, mbstring, zip
tools: composer:v2
coverage: none
- name: Copy .env
run: php -r "file_exists('.env') || copy('.env.example', '.env');"
- name: Install PHP dependencies
run: composer install --no-interaction --no-progress --ansi
- name: Upgrade Chrome Driver
run: php artisan dusk:chrome-driver --detect
- name: Set up Node & NPM
uses: actions/setup-node@v2
with:
node-version: "18.x"
- name: Setup Problem Matches
run: |
echo "::add-matcher::${{ runner.tool_cache }}/php.json"
echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
- name: Cache dependencies
id: cache-modules
uses: actions/cache@v4
with:
path: ./node_modules
key: modules-${{ hashFiles('package-lock.json') }}
- name: Install dependencies
if: steps.cache-modules.outputs.cache-hit != 'true'
run: npm install
- name: Build dependencies
run: npm run build
- name: Generate key
run: php artisan key:generate
- name: Directory Permissions
run: chmod -R 777 storage bootstrap/cache
- name: Run Laravel Server
run: php artisan serve --no-reload &
- name: Start Chrome Driver
run: vendor/laravel/dusk/bin/chromedriver-linux &
- name: Execute tests (Dusk tests) via PHPUnit
run: php artisan dusk --stop-on-error --stop-on-failure
- name: Upload Failed Screenshots
uses: actions/upload-artifact@v3
if: failure()
with:
name: "screenshots-php${{ matrix.php }}"
path: tests/Browser/screenshots/*
- name: Upload Console Errors
uses: actions/upload-artifact@v3
if: failure()
with:
name: "console-php${{ matrix.php }}"
path: tests/Browser/console/*
- name: Upload Laravel Logs
uses: actions/upload-artifact@v3
if: failure()
with:
name: "log-php${{ matrix.php }}"
path: storage/logs/*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment