Skip to content

Commit

Permalink
changed to docker
Browse files Browse the repository at this point in the history
Signed-off-by: Valentin Sickert <[email protected]>
  • Loading branch information
Lapotor committed Dec 11, 2023
1 parent b276b32 commit 5b87b92
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 60 deletions.
36 changes: 17 additions & 19 deletions .github/workflows/laravel-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,20 @@ on:
description: "Database type"
required: true
type: string
db-port:
description: "Database port"
required: true
type: string
db-user:
description: "Database user"
required: true
type: string
db-password:
description: "Database password"
required: true
type: string
db-database:
description: "Database name"
db-version:
description: "Database version"
required: true
type: string

jobs:
laravel-test:
name: Laravel (PHP ${{ matrix.php-versions }})
name: Laravel (PHP ${{ matrix.php-versions }}) with ${{ inputs.db-type }} ${{ inputs.db-version }}
runs-on: ubuntu-latest
env:
DB_CONNECTION: ${{ inputs.db-type }}
DB_USERNAME: ${{ inputs.db-user }}
DB_PASSWORD: ${{ inputs.db-password }}
DB_DATABASE: ${{ inputs.db-database }}
DB_USERNAME: radioroster
DB_PASSWORD: testPassword
DB_DATABASE: radioroster
APP_ENV: testing

strategy:
Expand All @@ -41,6 +29,16 @@ jobs:
php-versions: ["8.1", "8.2", "8.3"]

steps:
- if: ${{ github.event.inputs.db-type == 'mysql' }}
name: Setup MariaDB ${{ inputs.db-version }}
run: |
docker run -d --name mariadb -e MARIADB_RANDOM_ROOT_PASSWORD=true -e MARIADB_DATABASE=${{ env.DB_DATABASE }} -e MARIADB_USER=${{ env.DB_USERNAME }} -e MARIADB_PASSWORD=${{ env.DB_PASSWORD }} --publish 3306:3306 mariadb:${{ inputs.db-version }}
- if: ${{ github.event.inputs.db-type == 'psql' }}
name: Setup PostgreSQL ${{ inputs.db-version }}
run: |
docker run -d --name postgres -e POSTGRES_DB=${{ env.DB_DATABASE }} -e POSTGRES_USER=${{ env.DB_USERNAME }} -e POSTGRES_PASSWORD=${{ env.DB_PASSWORD }} --publish 5432:5432 postgres:${{ inputs.db-version }}
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4

Expand Down Expand Up @@ -76,7 +74,7 @@ jobs:
- name: Run Migrations
run: php artisan migrate -v
env:
DB_PORT: ${{ inputs.db-port }}
DB_PORT: ${{ github.event.inputs.db-type == 'mysql' && 3306 || github.event.inputs.db-type == 'psql' && 5432 }}

- name: Execute tests (Unit and Feature tests) via PHPUnit
run: vendor/bin/phpunit --coverage-text
49 changes: 8 additions & 41 deletions .github/workflows/laravel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,55 +14,22 @@ env:
jobs:
laravel-mariadb:
name: Laravel with MariaDB ${{ matrix.mariadb-versions }}
runs-on: ubuntu-latest
services:
mariadb:
image: mariadb:${{ matrix.mariadb-versions }}
env:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: ${{ env.DB_DATABASE }}
MYSQL_USER: ${{ env.DB_USERNAME }}
MYSQL_PASSWORD: ${{ env.DB_PASSWORD }}
ports:
- 3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
uses: ./.github/workflows/laravel-test.yml
with:
db-type: mysql
db-version: ${{ matrix.mariadb-versions }}

strategy:
matrix:
mariadb-versions: ["10", "11"]

steps:
- uses: ./.github/workflows/laravel-test.yml
with:
db-type: mysql
db-port: ${{ job.services.mariadb.ports[3306] }}
db-user: ${{ env.DB_USERNAME }}
db-password: ${{ env.DB_PASSWORD }}
db-database: ${{ env.DB_DATABASE }}

laravel-psql:
name: Laravel with PostgreSQL ${{ matrix.psql-versions }}
runs-on: ubuntu-latest
services:
postgres:
image: postgres:${{ matrix.psql-versions }}
env:
POSTGRES_USER: ${{ env.DB_USERNAME }}
POSTGRES_PASSWORD: ${{ env.DB_PASSWORD }}
POSTGRES_DB: ${{ env.DB_DATABASE }}
ports:
- 5432
options: --health-cmd="pg_isready" --health-interval=10s --health-timeout=5s --health-retries=3
uses: ./.github/workflows/laravel-test.yml
with:
db-type: psql
db-version: ${{ matrix.psql-versions }}

strategy:
matrix:
psql-versions: ["14", "15", "16"]

steps:
- uses: ./.github/workflows/laravel-test.yml
with:
db-type: pgsql
db-port: ${{ job.services.postgres.ports[5432] }}
db-user: ${{ env.DB_USERNAME }}
db-password: ${{ env.DB_PASSWORD }}
db-database: ${{ env.DB_DATABASE }}

0 comments on commit 5b87b92

Please sign in to comment.