Skip to content

Commit

Permalink
Add MySQL workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
roxblnfk committed Oct 23, 2024
1 parent c552c68 commit 99af137
Show file tree
Hide file tree
Showing 2 changed files with 152 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/db-mssql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ on:
default: '["ubuntu-latest"]'
php:
description: PHP versions to test, separated by comma. Part of matrix.
default: '["8.1","8.2","8.3"]'
default: '["8.0","8.1","8.2","8.3"]'
required: false
type: string
stability:
Expand Down
151 changes: 151 additions & 0 deletions .github/workflows/db-mysql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
---

name: DB:MySQL

on:
workflow_call:
inputs:
os:
description: Os to test, separated by comma. Part of matrix.
required: false
type: string
default: '["ubuntu-latest"]'
php:
description: PHP versions to test, separated by comma. Part of matrix.
default: '["8.0","8.1","8.2","8.3"]'
required: false
type: string
stability:
description: Stability to test, separated by comma. Part of matrix.
required: false
type: string
default: '["prefer-stable"]'
mysql-version:
description: MySQL versions.
default: 8.0
required: false
type: string
mysql-password:
description: MySQL password.
default: 'SSpaSS__1'
required: false
type: string
mysql-port:
description: MySQL port.
default: '13306'
required: false
type: string
coverage:
description: Generate code coverage report.
default: pcov
required: false
type: string
extensions:
description: List of extensions to PHP.
default: curl, intl, pdo, pdo_mysql
required: false
type: string
ini-values:
description: Initial values for PHP configuration.
default: date.timezone='UTC'
required: false
type: string
tools:
description: Tools to test, separated by comma.
default: composer:v2, pecl
required: false
type: string

jobs:
tests:
name: PHP ${{ matrix.php }} MySQL-${{ inputs.mysql-version }}

env:
key: cache

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

strategy:
fail-fast: false
matrix:
php: ${{ fromJson(inputs.php) }}
os: ${{ fromJson(inputs.os) }}
stability: ${{ fromJson(inputs.stability) }}

services:
mysql:
image: mysql:${{ inputs.mysql-version }}
env:
MYSQL_ROOT_PASSWORD: ${{ inputs.mysql-password }}
MYSQL_DATABASE: spiral
MYSQL_AUTHENTICATION_PLUGIN: mysql_native_password
ports:
- ${{ inputs.mysql-port }}:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3

steps:
# General Steps
- name: Set Git To Use LF
run: |
git config --global core.autocrlf false
git config --global core.eol lf
- name: Checkout
uses: actions/checkout@v3

- name: Configure environment
run: |
export COMPOSER_ROOT_VERSION=$(/usr/bin/jq --null-input --raw-output 'first(inputs["extra"]["branch-alias"])[]' composer.json)
echo COMPOSER_ROOT_VERSION=$COMPOSER_ROOT_VERSION >> $GITHUB_ENV
- name: Setup PHP ${{ matrix.php }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
# PHP Extras
extensions: ${{ inputs.extensions }}
coverage: ${{ inputs.coverage }}
tools: ${{ inputs.tools }}
ini-values: ${{ inputs.ini-values }}

- name: Validate Composer
run: composer validate

- name: Get Composer Cache Directory
# Docs: <https://github.com/actions/cache/blob/master/examples.md#php---composer>
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

- name: Restore Composer Cache
uses: actions/cache@v2
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-${{ matrix.php }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-${{ matrix.php }}-composer

- name: Install dependencies with composer
if: matrix.php != '8.4'
run: composer update --${{ matrix.stability }} --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi

- name: Install dependencies with composer php 8.3
if: matrix.php == '8.4'
run: composer update --${{ matrix.stability }} --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi --ignore-platform-reqs

- name: Build test server
run: docker build --tag test-server:local -f ./tests/test-server/Dockerfile ./tests/test-server
if: ${{ inputs.test-server }}

- name: Run tests with phpunit without coverage
env:
DB: mysql
MYSQL: ${{ inputs.mysql-version }}
run: vendor/bin/phpunit --group driver-mysql --colors=always

- name: Upload Coverage To Codecov
uses: codecov/codecov-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage.clover
fail_ci_if_error: false

...

0 comments on commit 99af137

Please sign in to comment.