-
Notifications
You must be signed in to change notification settings - Fork 0
80 lines (66 loc) · 2.96 KB
/
laravel-test.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
name: Laravel Application Tests
on:
workflow_call:
inputs:
db-type:
description: "Database type"
required: true
type: string
db-version:
description: "Database version"
required: true
type: string
jobs:
laravel-test:
name: Laravel (PHP ${{ matrix.php-versions }}) - ${{ inputs.db-type }} ${{ inputs.db-version }}
runs-on: ubuntu-latest
env:
DB_CONNECTION: ${{ inputs.db-type }}
DB_PORT: ${{ inputs.db-type == 'mysql' && '3306' || inputs.db-type == 'pgsql' && '5432' }}
DB_USERNAME: radioroster
DB_PASSWORD: testPassword
DB_DATABASE: radioroster
APP_ENV: testing
strategy:
fail-fast: false
max-parallel: 3
matrix:
php-versions: ["8.1", "8.2", "8.3"]
steps:
- if: ${{ inputs.db-type == 'mysql' }}
name: Setup MariaDB ${{ inputs.db-version }}
run: |
docker run -d --name mariadb -e MARIADB_RANDOM_ROOT_PASSWORD=true -e MARIADB_DATABASE=${{ env.DB_DATABASE }} -e MARIADB_USER=${{ env.DB_USERNAME }} -e MARIADB_PASSWORD=${{ env.DB_PASSWORD }} --publish 3306:3306 mariadb:${{ inputs.db-version }}
- if: ${{ inputs.db-type == 'pgsql' }}
name: Setup PostgreSQL ${{ inputs.db-version }}
run: |
docker run -d --name postgres -e POSTGRES_DB=${{ env.DB_DATABASE }} -e POSTGRES_USER=${{ env.DB_USERNAME }} -e POSTGRES_PASSWORD=${{ env.DB_PASSWORD }} --publish 5432:5432 postgres:${{ inputs.db-version }}
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
- name: Setup PHP ${{ matrix.php-versions }}
uses: shivammathur/setup-php@67271131b1870a5a241694badbda0ac2cae0648e
with:
php-version: ${{ matrix.php-versions }}
extensions: pcntl, zip, intl, exif, mbstring, dom, fileinfo, ${{ inputs.db-type == 'mysql' && 'pdo_mysql' || inputs.db-type == 'pgsql' && 'pdo_pgsql' }}
coverage: xdebug
- name: Get Composer Cache Directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache Composer Dependencies
uses: actions/cache@e12d46a63a90f2fae62d114769bbf2a179198b5c # v3
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 -q --no-interaction --no-scripts --no-progress --prefer-dist --optimize-autoloader
- name: Prepare Laravel Application
run: |
php -r "file_exists('.env') || copy('.env.example', '.env');"
php artisan key:generate
- name: Clear config
run: php artisan config:clear
- name: Run Migrations
run: php artisan migrate -v
- name: Execute tests (Unit and Feature tests) via PHPUnit
run: vendor/bin/phpunit --coverage-text