Skip to content

Improve local testing for all RDBMS #74

Improve local testing for all RDBMS

Improve local testing for all RDBMS #74

Workflow file for this run

on:
pull_request:
paths:
- 'src/**'
- 'tests/**'
- '.github/workflows/mssql.yml'
- 'composer.json'
- 'phpunit.xml.dist'
push:
branches: ['master']
paths:
- 'src/**'
- 'tests/**'
- '.github/workflows/mssql.yml'
- 'composer.json'
- 'phpunit.xml.dist'
name: mssql
jobs:
tests:
name: PHP ${{ matrix.php }}-mssql-${{ matrix.mssql.server }}
env:
extensions: pdo, pdo_sqlsrv-5.12
runs-on: ${{ matrix.mssql.os || 'ubuntu-latest' }}
strategy:
matrix:
php:
- 8.1
- 8.2
- 8.3
mssql:
- server: 2022-latest
odbc-version: 18
flag: "-C"
include:
- php: 8.3
mssql:
server: 2017-latest
os: ubuntu-20.04
- php: 8.3
mssql:
server: 2019-latest
odbc-version: 18
flag: "-C"
services:
mssql:
image: mcr.microsoft.com/mssql/server:${{ matrix.mssql.server }}
env:
SA_PASSWORD: YourStrong!Passw0rd
ACCEPT_EULA: Y
MSSQL_PID: Developer
ports:
- 1433:1433
options: --name=mssql --health-cmd="/opt/mssql-tools${{ matrix.mssql.odbc-version }}/bin/sqlcmd ${{ matrix.mssql.flag }} -S localhost -U SA -P 'YourStrong!Passw0rd' -Q 'SELECT 1'" --health-interval=10s --health-timeout=5s --health-retries=3
steps:
- name: Install ODBC driver.
run: |
sudo curl https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/prod.list | sudo tee /etc/apt/sources.list.d/mssql-release.list
sudo ACCEPT_EULA=Y apt-get install -y msodbcsql18
- name: Checkout
uses: actions/checkout@v3
- name: Create MS SQL Database
run: docker exec -i mssql /opt/mssql-tools${{ matrix.mssql.odbc-version }}/bin/sqlcmd ${{ matrix.mssql.flag }} -S localhost -U SA -P 'YourStrong!Passw0rd' -Q 'CREATE DATABASE yiitest'
- name: Install PHP with extensions
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: ${{ env.extensions }}
ini-values: date.timezone='UTC'
coverage: pcov
tools: composer:v2, pecl
- name: Determine composer cache directory
run: echo "COMPOSER_CACHE_DIR=$(composer config cache-dir)" >> $GITHUB_ENV
- name: Cache dependencies installed with composer
uses: actions/cache@v4
with:
path: ${{ env.COMPOSER_CACHE_DIR }}
key: php${{ matrix.php }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: |
php${{ matrix.php }}-composer-
- name: Update composer
run: composer self-update
- name: Remove unused dependencies of DB drivers
run: composer remove --dev yiisoft/db-sqlite yiisoft/db-mysql yiisoft/db-pgsql yiisoft/db-oracle
- name: Install dependencies with composer
run: composer update --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi
- name: Run tests with phpunit
run: vendor/bin/phpunit --testsuite=Mssql --coverage-clover=coverage.xml --colors=always
env:
ENVIRONMENT: ci
YII_MSSQL_DATABASE: yiitest
YII_MSSQL_HOST: 127.0.0.1
YII_MSSQL_PORT: 1433
YII_MSSQL_USER: SA
YII_MSSQL_PASSWORD: YourStrong!Passw0rd
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage.xml