-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
aec022f
commit db7159c
Showing
1 changed file
with
46 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,50 @@ | ||
name: Laravel | ||
# GitHub Action for Laravel | ||
name: Testing Laravel | ||
on: [push, pull_request] | ||
jobs: | ||
laravel: | ||
name: Laravel (PHP ${{ matrix.php-versions }} on ${{ matrix.operating-system }}) | ||
runs-on: ${{ matrix.operating-system }} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
operating-system: [ubuntu-latest, windows-latest, macos-latest] | ||
php-versions: ['8.3'] | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
on: | ||
push: | ||
branches: [ "main" ] | ||
pull_request: | ||
branches: [ "main" ] | ||
# Docs: https://github.com/shivammathur/setup-php | ||
- name: Setup PHP | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: ${{ matrix.php-versions }} | ||
extensions: mbstring, dom, fileinfo | ||
coverage: xdebug | ||
|
||
jobs: | ||
laravel-tests: | ||
- name: Get composer cache directory | ||
id: composer-cache | ||
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT | ||
|
||
runs-on: ubuntu-latest | ||
- name: Cache composer dependencies | ||
uses: actions/cache@v3 | ||
with: | ||
path: ${{ steps.composer-cache.outputs.dir }} | ||
# Use composer.json for key, if composer.lock is not committed. | ||
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} | ||
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} | ||
restore-keys: ${{ runner.os }}-composer- | ||
|
||
steps: | ||
- uses: shivammathur/setup-php@15c43e89cdef867065b0213be354c2841860869e | ||
with: | ||
php-version: '8.3' | ||
- uses: actions/checkout@v4 | ||
- name: Copy .env | ||
run: php -r "file_exists('.env') || copy('.env.example', '.env');" | ||
- name: Install Dependencies | ||
run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist | ||
- name: Generate key | ||
run: php artisan key:generate | ||
- name: Directory Permissions | ||
run: chmod -R 777 storage bootstrap/cache | ||
- name: Create Database | ||
run: | | ||
mkdir -p database | ||
touch database/database.sqlite | ||
- name: Execute tests (Unit and Feature tests) via PHPUnit/Pest | ||
env: | ||
DB_CONNECTION: sqlite | ||
DB_DATABASE: database/database.sqlite | ||
run: php artisan test | ||
- name: Install Composer dependencies | ||
run: composer install --no-progress --prefer-dist --optimize-autoloader | ||
|
||
- name: Prepare the application | ||
run: | | ||
php -r "file_exists('.env') || copy('.env.example', '.env');" | ||
php artisan key:generate | ||
- name: Clear Config | ||
run: php artisan config:clear | ||
|
||
- name: Test with phpunit | ||
run: vendor/bin/phpunit --coverage-text |