Merge pull request #146 from Lomkit/fix/force-morph-to-relation-test #269
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
name: tests | |
on: | |
push: | |
branches: [ master, next ] | |
pull_request: | |
branches: [ master ] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
php-version: [ '8.1', '8.2', '8.3' ] | |
laravel-version: [ '^10.0', '^11.0' ] | |
database: [ 'sqlite', 'mysql', 'pgsql' ] | |
exclude: | |
- php-version: '8.1' | |
laravel-version: '^11.0' | |
name: Tests on PHP ${{ matrix.php-version }} with Laravel ${{ matrix.laravel-version }} and ${{ matrix.database }} | |
services: | |
mysql: | |
image: mysql:8 | |
env: | |
MYSQL_ALLOW_EMPTY_PASSWORD: yes | |
MYSQL_DATABASE: rest | |
ports: | |
- 3306:3306 | |
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 | |
pgsql: | |
image: postgres:16 | |
env: | |
POSTGRES_USER: postgres | |
POSTGRES_PASSWORD: postgres | |
POSTGRES_DB: rest | |
ports: | |
- 5432:5432 | |
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup PHP | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: ${{ matrix.php-version }} | |
coverage: none | |
- name: Validate composer.json and composer.lock | |
run: composer validate | |
- name: Cache Composer packages | |
id: composer-cache | |
uses: actions/cache@v4 | |
with: | |
path: vendor | |
key: ${{ runner.os }}-php-${{ matrix.php-version }}-laravel-${{ matrix.laravel-version }}-${{ hashFiles('**/composer.lock') }} | |
restore-keys: | | |
${{ runner.os }}-php-${{ matrix.php-version }}-laravel-${{ matrix.laravel-version }}- | |
- name: Install dependencies | |
if: steps.composer-cache.outputs.cache-hit != 'true' | |
run: composer require laravel/framework:${{ matrix.laravel-version }} -W --prefer-dist --no-progress | |
- name: Run test suite with Sqlite | |
if: matrix.database == 'sqlite' | |
run: vendor/bin/phpunit | |
env: | |
DB_CONNECTION: sqlite | |
DB_DATABASE: ':memory:' | |
- name: Run test suite with MySQL | |
if: matrix.database == 'mysql' | |
run: vendor/bin/phpunit | |
env: | |
DB_CONNECTION: mysql | |
DB_PORT: ${{ job.services.mysql.ports[3306] }} | |
DB_DATABASE: rest | |
DB_USERNAME: root | |
- name: Run test suite with PostgreSQL | |
if: matrix.database == 'pgsql' | |
run: vendor/bin/phpunit | |
env: | |
DB_CONNECTION: pgsql | |
DB_PORT: ${{ job.services.pgsql.ports[5432] }} | |
DB_DATABASE: rest | |
DB_USERNAME: postgres | |
DB_PASSWORD: postgres |