Skip to content

Commit

Permalink
Updates gh-action
Browse files Browse the repository at this point in the history
  • Loading branch information
butschster committed Apr 30, 2024
1 parent 18f8b1e commit f13d2e7
Showing 1 changed file with 112 additions and 27 deletions.
139 changes: 112 additions & 27 deletions .github/workflows/phpunit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,115 @@ name: phpunit

jobs:
phpunit-db:
uses: buggregator/gh-actions/.github/workflows/phpunit.yml@master
with:
extensions: >-
['sockets', 'mongodb', 'pgsql', 'pdo_pgsql', 'pdo_mysql']
os: >-
['ubuntu-latest']
php: >-
['8.3']
stability: >-
['prefer-stable']
env:
PERSISTENCE_DRIVER: db
DB_DRIVER: sqlite

phpunit-memory:
uses: buggregator/gh-actions/.github/workflows/phpunit.yml@master
with:
extensions: >-
['sockets', 'mongodb', 'pgsql', 'pdo_pgsql', 'pdo_mysql']
os: >-
['ubuntu-latest']
php: >-
['8.3']
stability: >-
['prefer-stable']
env:
PERSISTENCE_DRIVER: memory
name: PHP 8.3-${{ matrix.os }}, ${{ matrix.stability }})

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

strategy:
fail-fast: false
matrix:
php: [ '8.3' ]
os: [ 'ubuntu-latest' ]
stability: [ 'prefer-stable' ]

services:
postgres:
image: postgres
env:
POSTGRES_PASSWORD: secret
POSTGRES_DB: buggregator
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432

mongodb:
image: mongo
env:
MONGO_INITDB_ROOT_USERNAME: mongo
MONGO_INITDB_ROOT_PASSWORD: secret
MONGO_INITDB_DATABASE: buggregator
ports:
- 27017:27017
options: >-
--health-cmd mongo
--health-interval 10s
--health-timeout 5s
--health-retries 5
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 }}
extensions: sockets,mongodb,pgsql,pdo_pgsql,pdo_mysql
tools: pecl

- name: Validate Composer
run: composer validate

- name: Get Composer Cache Directory
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
uses: nick-invision/retry@v2
with:
timeout_minutes: 5
max_attempts: 5
command: composer update --${{ matrix.stability }} --prefer-dist --no-interaction --no-progress

# Execution SQLite
- name: Execute Tests on SQLite
run: vendor/bin/phpunit
env:
PERSISTENCE_DRIVER: db
DB_DRIVER: sqlite

# Execution in memory
- name: Execute Tests on SQLite
run: vendor/bin/phpunit
env:
PERSISTENCE_DRIVER: memory

# Execution pgsql
- name: Execute Tests on Postgres
run: vendor/bin/phpunit
env:
PERSISTENCE_DRIVER: db
DB_DRIVER: pgsql
DB_HOST: postgres
DB_PORT: 5432
DB_USERNAME: postgres
DB_PASSWORD: secret

# Execution mongo
- name: Execute Tests on Mongo
run: vendor/bin/phpunit
env:
PERSISTENCE_DRIVER: mongodb
MONGODB_CONNECTION: mongodb://mongo:secret@mongodb:27017

0 comments on commit f13d2e7

Please sign in to comment.