2022-08-12 02:30:52 -05:00
|
|
|
name: Database tests
|
|
|
|
|
|
|
|
on:
|
|
|
|
workflow_call:
|
|
|
|
inputs:
|
|
|
|
platform:
|
|
|
|
type: string
|
|
|
|
required: true
|
|
|
|
description: One of sqlite:ci, mysql, maria, postgres or ms
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
db-tests:
|
|
|
|
runs-on: ubuntu-22.04
|
|
|
|
strategy:
|
|
|
|
matrix:
|
|
|
|
php-version: [ '8.1' ]
|
|
|
|
env:
|
|
|
|
LC_ALL: C
|
2022-08-12 13:32:16 -05:00
|
|
|
extensions: openswoole-4.11.1, pdo_sqlsrv-5.10.1
|
2022-08-12 02:30:52 -05:00
|
|
|
steps:
|
|
|
|
- name: Checkout code
|
2022-08-13 03:19:38 -05:00
|
|
|
uses: actions/checkout@v3
|
2022-08-12 02:30:52 -05:00
|
|
|
- name: Install MSSQL ODBC
|
|
|
|
if: ${{ inputs.platform == 'ms' }}
|
|
|
|
run: sudo ./data/infra/ci/install-ms-odbc.sh
|
|
|
|
- name: Start database server
|
|
|
|
if: ${{ inputs.platform != 'sqlite:ci' }}
|
|
|
|
run: docker-compose -f docker-compose.yml -f docker-compose.ci.yml up -d shlink_db_${{ inputs.platform }}
|
2022-08-12 13:32:16 -05:00
|
|
|
- name: Setup cache environment
|
|
|
|
id: extcache
|
|
|
|
uses: shivammathur/cache-extensions@v1
|
|
|
|
with:
|
|
|
|
php-version: ${{ matrix.php-version }}
|
|
|
|
extensions: ${{ env.extensions }}
|
2022-08-13 03:11:41 -05:00
|
|
|
key: db-tests-extensions-${{ matrix.php-version }}-${{ inputs.platform }}
|
2022-08-12 13:32:16 -05:00
|
|
|
- name: Cache extensions
|
|
|
|
uses: actions/cache@v2
|
|
|
|
with:
|
|
|
|
path: ${{ steps.extcache.outputs.dir }}
|
|
|
|
key: ${{ steps.extcache.outputs.key }}
|
|
|
|
restore-keys: ${{ steps.extcache.outputs.key }}
|
2022-08-12 02:30:52 -05:00
|
|
|
- name: Use PHP
|
|
|
|
uses: shivammathur/setup-php@v2
|
|
|
|
with:
|
|
|
|
php-version: ${{ matrix.php-version }}
|
|
|
|
tools: composer
|
2022-08-12 13:32:16 -05:00
|
|
|
extensions: ${{ env.extensions }}
|
2022-08-12 02:30:52 -05:00
|
|
|
coverage: pcov
|
|
|
|
ini-values: pcov.directory=module
|
|
|
|
- name: Install dependencies
|
|
|
|
run: composer install --no-interaction --prefer-dist
|
|
|
|
- name: Create test database
|
|
|
|
if: ${{ inputs.platform == 'ms' }}
|
|
|
|
run: docker-compose exec -T shlink_db_ms /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P 'Passw0rd!' -Q "CREATE DATABASE shlink_test;"
|
|
|
|
- name: Run tests
|
|
|
|
run: composer test:db:${{ inputs.platform }}
|
|
|
|
- name: Upload code coverage
|
2022-08-12 11:19:12 -05:00
|
|
|
uses: actions/upload-artifact@v3
|
2022-08-12 02:30:52 -05:00
|
|
|
if: ${{ matrix.php-version == '8.1' && inputs.platform == 'sqlite:ci' }}
|
|
|
|
with:
|
|
|
|
name: coverage-db
|
|
|
|
path: |
|
|
|
|
build/coverage-db
|
|
|
|
build/coverage-db.cov
|