2024-06-18 16:18:27 -04:00
|
|
|
name: Tests
|
|
|
|
|
|
|
|
on: [ push, pull_request ]
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
laravel-tests:
|
2024-09-11 16:43:53 -04:00
|
|
|
runs-on: ubuntu-latest
|
2024-06-18 16:18:27 -04:00
|
|
|
services:
|
|
|
|
mysql:
|
|
|
|
image: mysql:8.3
|
|
|
|
env:
|
|
|
|
MYSQL_DATABASE: testing
|
|
|
|
MYSQL_USER: user
|
|
|
|
MYSQL_PASSWORD: password
|
|
|
|
MYSQL_ROOT_PASSWORD: password
|
2024-09-11 17:10:26 -04:00
|
|
|
options: --health-cmd="mysql -u user -D testing -ppassword -h mysql -e ''" --health-interval=10s --health-timeout=5s --health-retries=3
|
2024-09-11 16:01:07 -04:00
|
|
|
|
2024-06-18 16:18:27 -04:00
|
|
|
steps:
|
|
|
|
- name: Checkout
|
|
|
|
uses: actions/checkout@v4
|
2024-09-11 16:01:07 -04:00
|
|
|
|
2024-06-18 16:18:27 -04:00
|
|
|
- name: Setup PHP
|
|
|
|
uses: shivammathur/setup-php@v2
|
|
|
|
with:
|
|
|
|
php-version: '8.3'
|
|
|
|
extensions: mbstring, dom, fileinfo
|
|
|
|
coverage: none
|
2024-09-11 16:01:07 -04:00
|
|
|
|
2024-06-18 16:18:27 -04:00
|
|
|
- name: Get Composer Cache Directory
|
|
|
|
id: composer-cache
|
|
|
|
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
|
2024-09-11 16:01:07 -04:00
|
|
|
|
2024-06-18 16:18:27 -04:00
|
|
|
- name: Cache composer dependencies
|
|
|
|
uses: actions/cache@v4
|
|
|
|
with:
|
|
|
|
path: ${{ steps.composer-cache.outputs.dir }}
|
|
|
|
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
|
|
|
|
restore-keys: ${{ runner.os }}-composer-
|
2024-09-11 16:01:07 -04:00
|
|
|
|
2024-06-18 16:18:27 -04:00
|
|
|
- name: Install Composer Dependencies
|
|
|
|
run: composer install --no-progress --prefer-dist --optimize-autoloader
|
2024-09-11 16:01:07 -04:00
|
|
|
|
2024-06-18 16:18:27 -04:00
|
|
|
- name: Get NPM Cache Directory
|
|
|
|
id: npm-cache
|
2024-06-18 17:36:41 -04:00
|
|
|
run: echo "NPM_CACHE_DIR=$(npm config get cache)" >> $GITHUB_ENV
|
2024-09-11 16:01:07 -04:00
|
|
|
|
2024-06-18 16:18:27 -04:00
|
|
|
- name: Cache NPM Dependencies
|
|
|
|
uses: actions/cache@v4
|
|
|
|
with:
|
2024-06-18 17:36:41 -04:00
|
|
|
path: ${{ env.NPM_CACHE_DIR }}
|
2024-06-18 16:18:27 -04:00
|
|
|
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
|
|
|
|
restore-keys: ${{ runner.os }}-node-
|
2024-09-11 16:01:07 -04:00
|
|
|
|
2024-06-18 16:18:27 -04:00
|
|
|
- name: Install npm dependencies
|
|
|
|
run: npm ci
|
2024-09-11 16:01:07 -04:00
|
|
|
|
2024-06-18 19:31:35 -04:00
|
|
|
- name: Build Front-end Assets
|
|
|
|
run: npm run build
|
2024-09-11 16:01:07 -04:00
|
|
|
|
2024-06-18 16:18:27 -04:00
|
|
|
- name: Prepare Laravel Environment
|
|
|
|
run: |
|
|
|
|
php -r "file_exists('.env') || copy('.env.ci', '.env');"
|
|
|
|
php artisan key:generate
|
2024-06-27 23:20:21 -04:00
|
|
|
php artisan optimize
|
2024-09-11 16:01:07 -04:00
|
|
|
|
2024-06-18 16:18:27 -04:00
|
|
|
- name: Run Database Migrations
|
|
|
|
run: php artisan migrate
|
2024-09-11 16:01:07 -04:00
|
|
|
|
2024-06-18 16:18:27 -04:00
|
|
|
- name: Link Storage
|
|
|
|
run: php artisan storage:link
|
2024-09-11 16:01:07 -04:00
|
|
|
|
2024-06-18 16:18:27 -04:00
|
|
|
- name: Run Tests
|
|
|
|
run: php artisan test
|
2024-09-11 16:01:07 -04:00
|
|
|
|
2024-06-18 17:36:41 -04:00
|
|
|
- name: Display Laravel Log
|
|
|
|
if: failure()
|
|
|
|
run: cat storage/logs/laravel.log
|