Update mssql.yml #199
Workflow file for this run
This file contains hidden or 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
| 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: | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| 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 | |
| - 8.4 | |
| - 8.5 | |
| mssql: | |
| - server: 2022-latest | |
| odbc-version: 18 | |
| flag: "-C" | |
| tools-path: "/opt/mssql-tools18" | |
| include: | |
| - php: 8.3 | |
| mssql: | |
| server: 2017-latest | |
| odbc-version: 17 | |
| flag: "" | |
| tools-path: "/opt/mssql-tools" | |
| os: ubuntu-22.04 | |
| - php: 8.3 | |
| mssql: | |
| server: 2019-latest | |
| odbc-version: 18 | |
| flag: "-C" | |
| tools-path: "/opt/mssql-tools18" | |
| 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="${{ matrix.mssql.tools-path }}/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: | | |
| curl -fsSL https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor | sudo tee /usr/share/keyrings/microsoft-prod.gpg > /dev/null | |
| curl -fsSL https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/prod.list | sudo tee /etc/apt/sources.list.d/mssql-release.list | |
| sudo apt-get update | |
| sudo ACCEPT_EULA=Y apt-get install -y msodbcsql${{ matrix.mssql.odbc-version }} | |
| - name: Verify ODBC driver installation | |
| run: | | |
| echo "=== Installed ODBC Drivers ===" | |
| odbcinst -q -d | |
| echo "" | |
| echo "=== Expected Driver: ODBC Driver ${{ matrix.mssql.odbc-version }} for SQL Server ===" | |
| if odbcinst -q -d -n "ODBC Driver ${{ matrix.mssql.odbc-version }} for SQL Server"; then | |
| echo "✓ Correct driver version installed!" | |
| else | |
| echo "✗ Expected driver not found!" | |
| exit 1 | |
| fi | |
| echo "" | |
| echo "=== ODBC Driver Package Info ===" | |
| dpkg -l | grep msodbcsql | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - name: Create MS SQL Database | |
| run: docker exec -i mssql ${{ matrix.mssql.tools-path }}/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: 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 | |
| CYCLE_MSSQL_DATABASE: yiitest | |
| CYCLE_MSSQL_HOST: 127.0.0.1 | |
| CYCLE_MSSQL_PORT: 1433 | |
| CYCLE_MSSQL_USER: SA | |
| CYCLE_MSSQL_PASSWORD: YourStrong!Passw0rd | |
| - name: Upload coverage to Codecov | |
| uses: codecov/codecov-action@v3 | |
| with: | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| files: ./coverage.xml |