Skip to content

Commit

Permalink
Merge pull request #66 from yiisoft/fix-mssql-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Tigrov authored Sep 13, 2024
2 parents f72cc06 + aa7d3d5 commit 7b59806
Showing 1 changed file with 32 additions and 29 deletions.
61 changes: 32 additions & 29 deletions .github/workflows/mssql.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,20 @@
on:
pull_request:
paths-ignore:
- 'docs/**'
- 'README.md'
- 'CHANGELOG.md'
- '.gitignore'
- '.gitattributes'
- 'infection.json.dist'
- 'psalm.xml'
paths:
- 'src/**'
- 'tests/**'
- '.github/workflows/mssql.yml'
- 'composer.json'
- 'phpunit.xml.dist'

push:
branches: ['master']
paths-ignore:
- 'docs/**'
- 'README.md'
- 'CHANGELOG.md'
- '.gitignore'
- '.gitattributes'
- 'infection.json.dist'
- 'psalm.xml'
paths:
- 'src/**'
- 'tests/**'
- '.github/workflows/mssql.yml'
- 'composer.json'
- 'phpunit.xml.dist'

name: mssql

Expand All @@ -29,39 +25,47 @@ jobs:
env:
extensions: pdo, pdo_sqlsrv-5.11.1

runs-on: ${{ matrix.os }}
runs-on: ubuntu-latest

strategy:
matrix:
os:
- ubuntu-latest

php:
- 8.1
- 8.2
- 8.3

mssql:
- server:2019-latest
- server:2022-latest
- server: 2022-latest
odbc-version: 18
flag: "-C"

include:
- php: 8.3
mssql:
server: 2017-latest
- php: 8.3
mssql:
server: 2019-latest
odbc-version: 18
flag: "-C"

services:
mssql:
image: mcr.microsoft.com/mssql/${{ matrix.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/bin/sqlcmd -S localhost -U SA -P 'YourStrong!Passw0rd' -Q 'SELECT 1'" --health-interval=10s --health-timeout=5s --health-retries=3
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: Checkout
uses: actions/checkout@v3

- name: Create MS SQL Database
run: docker exec -i mssql /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P 'YourStrong!Passw0rd' -Q 'CREATE DATABASE yiitest'
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
Expand All @@ -73,11 +77,10 @@ jobs:
tools: composer:v2, pecl

- name: Determine composer cache directory
if: matrix.os == 'ubuntu-latest'
run: echo "COMPOSER_CACHE_DIR=$(composer config cache-dir)" >> $GITHUB_ENV

- name: Cache dependencies installed with composer
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ${{ env.COMPOSER_CACHE_DIR }}
key: php${{ matrix.php }}-composer-${{ hashFiles('**/composer.json') }}
Expand All @@ -94,7 +97,7 @@ jobs:
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
run: vendor/bin/phpunit --testsuite=Mssql --coverage-clover=coverage.xml --colors=always
env:
ENVIRONMENT: ci
YII_MSSQL_DATABASE: yiitest
Expand All @@ -104,7 +107,7 @@ jobs:
YII_MSSQL_PASSWORD: YourStrong!Passw0rd

- name: Upload coverage to Codecov
if: matrix.os == 'ubuntu-latest'
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage.xml

0 comments on commit 7b59806

Please sign in to comment.