name: Testing
on: [push, pull_request]
jobs:
tests:
name: Test Application
runs-on: ubuntu-latest
services:
mysql:
image: mysql:8.0
env:
MYSQL_ALLOW_EMPTY_PASSWORD: true
MYSQL_ROOT_PASSWORD:
MYSQL_DATABASE: test
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
strategy:
fail-fast: false
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v2
with:
php-version: 8.3
extensions: mbstring, dom, fileinfo, pdo, mysql
- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache composer dependencies
uses: actions/cache@v2
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: Install Composer dependencies
run: composer install -n --prefer-dist
- name: Prepare the application
run: |
php -r "file_exists('.env') || copy('.env.testing', '.env');"
- name: clear config
run: php artisan config:clear
- name: clear views
run: php artisan view:clear
- name: Run Migration
run: php artisan migrate -v
- name: Test with phpunit
run: php artisan test