Skip to content

Commit

Permalink
Add Postgres workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
roxblnfk committed Oct 23, 2024
1 parent b1248ec commit d8b17ae
Show file tree
Hide file tree
Showing 3 changed files with 155 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/db-mssql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ on:
required: false
type: string
mssql-version:
description: MSSQL versions.
description: MSSQL version.
default: 2019-latest
required: false
type: string
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/db-mysql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ on:
type: string
default: '["prefer-stable"]'
mysql-version:
description: MySQL versions.
description: MySQL version.
default: 8.0
required: false
type: string
Expand Down Expand Up @@ -139,7 +139,7 @@ jobs:
env:
DB: mysql
MYSQL: ${{ inputs.mysql-version }}
run: vendor/bin/phpunit --group driver-mysql --colors=always
run: vendor/bin/phpunit --group driver-mysql --colors=always --coverage-clover=coverage.clover

- name: Upload Coverage To Codecov
uses: codecov/codecov-action@v1
Expand Down
152 changes: 152 additions & 0 deletions .github/workflows/db-pgsql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
---

name: DB:Postgres

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"]'
pgsql-version:
description: Postgres version.
default: 12
required: false
type: string
pgsql-password:
description: Postgres password.
default: 'SSpaSS__1'
required: false
type: string
pgsql-port:
description: Postgres port.
default: '15432'
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_pgsql
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 }} Postgres-${{ inputs.pgsql-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:
postgres:
image: postgres:${{ inputs.pgsql-version }}
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: ${{ inputs.pgsql-password }}
POSTGRES_DB: spiral
ports:
- ${{ inputs.pgsql-port }}:5432
options: --name=postgres --health-cmd="pg_isready" --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 "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: Restore Composer Cache
uses: actions/cache@v3
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: postgres
POSTGRES: ${{ matrix.pgsql-version }}
run: vendor/bin/phpunit --group driver-postgres --colors=always --coverage-clover=coverage.clover

- 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 d8b17ae

Please sign in to comment.