From 5b87b92e6a20ada5ce985d9eaccbe7ef4447ceb1 Mon Sep 17 00:00:00 2001 From: Valentin Sickert <17144397+Lapotor@users.noreply.github.com> Date: Mon, 11 Dec 2023 20:35:08 +0100 Subject: [PATCH] changed to docker Signed-off-by: Valentin Sickert <17144397+Lapotor@users.noreply.github.com> --- .github/workflows/laravel-test.yml | 36 +++++++++++----------- .github/workflows/laravel.yml | 49 +++++------------------------- 2 files changed, 25 insertions(+), 60 deletions(-) diff --git a/.github/workflows/laravel-test.yml b/.github/workflows/laravel-test.yml index 89d9755a..e868ceea 100644 --- a/.github/workflows/laravel-test.yml +++ b/.github/workflows/laravel-test.yml @@ -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: @@ -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 @@ -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 diff --git a/.github/workflows/laravel.yml b/.github/workflows/laravel.yml index 2645ce40..729908ca 100644 --- a/.github/workflows/laravel.yml +++ b/.github/workflows/laravel.yml @@ -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 }}