Skip to content

Commit

Permalink
split database tests into multiple jobs
Browse files Browse the repository at this point in the history
  • Loading branch information
mszulik committed Dec 18, 2024
1 parent 4dc54ee commit cefd86a
Showing 1 changed file with 30 additions and 11 deletions.
41 changes: 30 additions & 11 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ env:
POSTGRES_PORT: 5432
POSTGRES_DB_OPTIONS: "--health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 3"
POSTGRES_PHPUNIT_CONFIG: "phpunit-ci-postgres.xml.dist"
MATRIX_EXCLUDE: "[{\"php\"=>\"8.3\", \"laravel\"=>\"9.*\"},{\"php\"=>\"8.1\", \"laravel\"=>\"11.*\"}]"

jobs:
# Environment variables are not available in the matrix context, so we have to define them as outputs.
Expand All @@ -37,14 +38,12 @@ jobs:
- run: echo "null"

mysql-tests:
name: Setup testing environment and execute tests
name: MySQL tests
needs: prepare
uses: cybex-gmbh/github-workflows/.github/workflows/tests.yml@feature/pass-db-image
strategy:
fail-fast: true
matrix:
db-image: [ "${{ needs.prepare.outputs.MYSQL_IMAGE }}", "${{ needs.prepare.outputs.POSTGRES_IMAGE }}" ]
db-options: [ "${{ needs.prepare.outputs.MYSQL_DB_OPTIONS }}", "${{ needs.prepare.outputs.POSTGRES_DB_OPTIONS }}" ]
php: [ 8.1, 8.2, 8.3 ]
laravel: [ 9.*, 10.*, 11.* ]
dependency-version: [ prefer-stable ]
Expand All @@ -53,16 +52,36 @@ jobs:
laravel: 9.*
- php: 8.1
laravel: 11.*
- db-image: "${{ needs.prepare.outputs.MYSQL_IMAGE }}"
db-options: "${{ needs.prepare.outputs.POSTGRES_DB_OPTIONS }}"
- db-image: "${{ needs.prepare.outputs.POSTGRES_IMAGE }}"
db-options: "${{ needs.prepare.outputs.MYSQL_DB_OPTIONS }}"
with:
DATABASE_IMAGE: ${{ matrix.db-image }}
DATABASE_NAME: protector_test
DATABASE_PORT: ${{ matrix.db-image == needs.prepare.outputs.MYSQL_IMAGE && needs.prepare.outputs.MYSQL_PORT || needs.prepare.outputs.POSTGRES_PORT }}
DATABASE_OPTIONS: ${{ matrix.db-options }}
PHP_VERSION: ${{ matrix.php }}
LARAVEL_VERSION: ${{ matrix.laravel }}
DEPENDENCY_VERSION: ${{ matrix.dependency-version }}
TEST_COMMANDS: vendor/bin/phpunit -c ${{ matrix.db-image == needs.prepare.outputs.MYSQL_IMAGE && needs.prepare.outputs.MYSQL_PHPUNIT_CONFIG || needs.prepare.outputs.POSTGRES_PHPUNIT_CONFIG }}
TEST_COMMANDS: vendor/bin/phpunit -c ${{ needs.prepare.outputs.MYSQL_PHPUNIT_CONFIG }}

postgres-tests:
name: PostgreSQL tests
needs: prepare
uses: cybex-gmbh/github-workflows/.github/workflows/tests.yml@feature/pass-db-image
strategy:
fail-fast: true
matrix:
php: [ 8.1, 8.2, 8.3 ]
laravel: [ 9.*, 10.*, 11.* ]
dependency-version: [ prefer-stable ]
exclude:
- php: 8.3
laravel: 9.*
- php: 8.1
laravel: 11.*
with:
DATABASE_IMAGE: ${{ needs.prepare.outputs.POSTGRES_IMAGE }}
DATABASE_NAME: protector_test
DATABASE_PORT: ${{ needs.prepare.outputs.POSTGRES_PORT }}
DATABASE_USERNAME: postgres
DATABASE_CONNECTION: pgsql
DATABASE_OPTIONS: ${{ needs.prepare.outputs.POSTGRES_DB_OPTIONS }}
PHP_VERSION: ${{ matrix.php }}
LARAVEL_VERSION: ${{ matrix.laravel }}
DEPENDENCY_VERSION: ${{ matrix.dependency-version }}
TEST_COMMANDS: vendor/bin/phpunit -c ${{ needs.prepare.outputs.MYSQL_PHPUNIT_CONFIG }}

0 comments on commit cefd86a

Please sign in to comment.