Skip to content

changed ci config for mysql, postgres and mssql #127

changed ci config for mysql, postgres and mssql

changed ci config for mysql, postgres and mssql #127

Workflow file for this run

name: CI
on:
push:
branches: [ feature-*, develop, dev-*, master ]
tags:
- '*'
pull_request:
branches: [ feature-*, develop, dev-*, master ]
jobs:
test:
runs-on: ubuntu-latest
timeout-minutes: 30
strategy:
matrix:
laravel: [10, 11, 12]
php: [8.2, 8.3, 8.4]
db:
- engine: mysql
version: 5.7
- engine: mysql
version: 8.0
- engine: pgsql
version: 15
- engine: sqlsrv
version: 2022-latest
exclude:
- laravel: 10
php: 8.4
db:
engine: mysql
version: 5.7
- laravel: 10
php: 8.4
db:
engine: mysql
version: 8.0
- laravel: 10
db:
engine: sqlsrv
version: 2022-latest
- laravel: 11
db:
engine: sqlsrv
version: 2022-latest
services:
mysql:
image: mysql:${{ matrix.db.version }}
ports:
- 3306:3306
env:
MYSQL_ALLOW_EMPTY_PASSWORD: 'yes'
MYSQL_DATABASE: testing
options: >-
--health-cmd="mysqladmin ping --silent"
--health-interval=10s
--health-timeout=5s
--health-retries=3
postgres:
image: postgres:15
ports:
- 5432:5432
env:
POSTGRES_DB: testing
POSTGRES_USER: postgres
POSTGRES_PASSWORD: ''
options: >-
--health-cmd="pg_isready -U postgres"
--health-interval=10s
--health-timeout=5s
--health-retries=3
mssql:
image: mcr.microsoft.com/mssql/server:2022-latest
ports:
- 1433:1433
env:
ACCEPT_EULA: Y
SA_PASSWORD: Passw0rd1234!
MSSQL_PID: Express
options: >-
--health-cmd="exit 0"
--health-interval=10s
--health-timeout=5s
--health-retries=3
name: Laravel ${{ matrix.laravel }} / PHP ${{ matrix.php }} / DB ${{ matrix.db.engine }} ${{ matrix.db.version }}
steps:
- uses: actions/checkout@v4
- name: Set DB_DISPLAY_NAME
run: |
if [ "${{ matrix.db_engine }}" = "mysql" ] && [ "${{ matrix.mysql }}" != "" ]; then
echo "DB_DISPLAY_NAME=mysql ${{ matrix.mysql }}" >> $GITHUB_ENV
else
echo "DB_DISPLAY_NAME=${{ matrix.db_engine }}" >> $GITHUB_ENV
fi
- name: Set DB env variables
run: |
if [ "${{ matrix.db_engine }}" = "mysql" ]; then
echo "DB_HOST=127.0.0.1" >> $GITHUB_ENV
echo "DB_PORT=3306" >> $GITHUB_ENV
echo "DB_USERNAME=root" >> $GITHUB_ENV
echo "DB_PASSWORD=" >> $GITHUB_ENV
echo "DB_DATABASE=testing" >> $GITHUB_ENV
elif [ "${{ matrix.db_engine }}" = "pgsql" ]; then
echo "DB_HOST=127.0.0.1" >> $GITHUB_ENV
echo "DB_PORT=5432" >> $GITHUB_ENV
echo "DB_USERNAME=postgres" >> $GITHUB_ENV
echo "DB_PASSWORD=" >> $GITHUB_ENV
echo "DB_DATABASE=testing" >> $GITHUB_ENV
elif [ "${{ matrix.db_engine }}" = "sqlsrv" ]; then
echo "DB_HOST=127.0.0.1" >> $GITHUB_ENV
echo "DB_PORT=1433" >> $GITHUB_ENV
echo "DB_USERNAME=SA" >> $GITHUB_ENV
echo "DB_PASSWORD=Passw0rd1234!" >> $GITHUB_ENV
echo "DB_DATABASE=testing" >> $GITHUB_ENV
fi
- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: mbstring, pdo_mysql, pdo_pgsql, pdo_sqlsrv, zip, exif, intl, gd, bcmath, curl, dom, xdebug
coverage: xdebug
- name: Debug info
run: |
php -v
composer --version
mysql --version || true
psql --version || true
/opt/mssql-tools/bin/sqlcmd -? || true
- name: Set DB env variables
run: |
if [[ "${{ matrix.db_engine }}" == "mysql" ]]; then
echo "DB_HOST=127.0.0.1" >> $GITHUB_ENV
echo "DB_PORT=3306" >> $GITHUB_ENV
echo "DB_USERNAME=root" >> $GITHUB_ENV
echo "DB_PASSWORD=" >> $GITHUB_ENV
echo "DB_DATABASE=testing" >> $GITHUB_ENV
elif [[ "${{ matrix.db_engine }}" == "pgsql" ]]; then
echo "DB_HOST=127.0.0.1" >> $GITHUB_ENV
echo "DB_PORT=5432" >> $GITHUB_ENV
echo "DB_USERNAME=postgres" >> $GITHUB_ENV
echo "DB_PASSWORD=" >> $GITHUB_ENV
echo "DB_DATABASE=testing" >> $GITHUB_ENV
elif [[ "${{ matrix.db_engine }}" == "sqlsrv" ]]; then
echo "DB_HOST=127.0.0.1" >> $GITHUB_ENV
echo "DB_PORT=1433" >> $GITHUB_ENV
echo "DB_USERNAME=SA" >> $GITHUB_ENV
echo "DB_PASSWORD=Passw0rd1234!" >> $GITHUB_ENV
echo "DB_DATABASE=testing" >> $GITHUB_ENV
fi
- name: Wait for DB service
run: |
if [[ "${{ matrix.db_engine }}" == "mysql" ]]; then
for i in {30..0}; do
if mysqladmin ping -h 127.0.0.1 --silent; then
echo "MySQL is ready"
break
fi
echo "Waiting for MySQL ($i)..."
sleep 1
done
elif [[ "${{ matrix.db_engine }}" == "pgsql" ]]; then
for i in {30..0}; do
if pg_isready -h 127.0.0.1 -U postgres; then
echo "Postgres is ready"
break
fi
echo "Waiting for Postgres ($i)..."
sleep 1
done
elif [[ "${{ matrix.db_engine }}" == "sqlsrv" ]]; then
# MSSQL health check not straightforward, wait fixed time
echo "Waiting 30 seconds for MSSQL to start..."
sleep 30
fi
- name: Adjust Laravel/Testbench version per matrix
run: |
composer remove laravel/framework orchestra/testbench --no-update || true
composer require laravel/framework:^${{ matrix.laravel }} --no-update
if [[ "${{ matrix.laravel }}" == "10" ]]; then
composer require orchestra/testbench:^8.0 --dev --no-update
elif [[ "${{ matrix.laravel }}" == "11" ]]; then
composer require orchestra/testbench:^9.0 --dev --no-update
elif [[ "${{ matrix.laravel }}" == "12" ]]; then
composer require orchestra/testbench:^10.0 --dev --no-update
fi
composer update --no-interaction --prefer-dist --no-progress
- name: Ensure coverage directory exists
run: mkdir -p coverage
- name: Run Tests
run: vendor/bin/phpunit --coverage-clover=coverage/clover.xml --path-coverage
- uses: qltysh/qlty-action/coverage@v1
with:
token: ${{ secrets.QLTY_COVERAGE_TOKEN }}
files: coverage/clover.xml