forked from wayofdev/gh-actions
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
155 additions
and
3 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
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 | ||
|
||
... |