From e7667558c7fc5e9b0a04dcafa3e11bdcf8b4f47d Mon Sep 17 00:00:00 2001 From: florentdevk Date: Thu, 2 Jul 2026 21:32:00 +0200 Subject: [PATCH 1/3] chore: add PostgreSQL service to CI pipeline --- .github/workflows/ci.yml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index de0f895..b85233f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,6 +10,24 @@ jobs: build: runs-on: ubuntu-latest + services: + postgres: + image: postgres:16-alpine + env: + POSTGRES_DB: chess_api_test + POSTGRES_USER: app + POSTGRES_PASSWORD: ${{ secrets.DB_PASSWORD }} + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + ports: + - 5432:5432 + + env: + DATABASE_URL: postgresql://app:${{ secrets.DB_PASSWORD }}@127.0.0.1:5432/chess_api_test?serverVersion=16&charset=utf8 + steps: - uses: actions/checkout@v4 @@ -28,5 +46,8 @@ jobs: - name: Run PHPStan run: vendor/bin/phpstan analyse + - name: Run database migrations + run: php bin/console doctrine:migrations:migrate --no-interaction --env=test + - name: Run PHPUnit run: vendor/bin/phpunit \ No newline at end of file From 66cdf98b21bcc2629a9b44629f148b4a890b0245 Mon Sep 17 00:00:00 2001 From: florentdevk Date: Thu, 2 Jul 2026 22:06:59 +0200 Subject: [PATCH 2/3] chore: fix CI database setup for test environment --- .github/workflows/ci.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b85233f..b061bb9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -26,7 +26,7 @@ jobs: - 5432:5432 env: - DATABASE_URL: postgresql://app:${{ secrets.DB_PASSWORD }}@127.0.0.1:5432/chess_api_test?serverVersion=16&charset=utf8 + DATABASE_URL: postgresql://app:${{ secrets.DB_PASSWORD }}@127.0.0.1:5432/chess_api?serverVersion=16&charset=utf8 steps: - uses: actions/checkout@v4 @@ -46,6 +46,9 @@ jobs: - name: Run PHPStan run: vendor/bin/phpstan analyse + - name: Create test database + run: php bin/console doctrine:database:create --env=test --no-interaction + - name: Run database migrations run: php bin/console doctrine:migrations:migrate --no-interaction --env=test From b9f10f53c2adccee58f031ea5dae86607de17ce2 Mon Sep 17 00:00:00 2001 From: florentdevk Date: Thu, 2 Jul 2026 22:18:47 +0200 Subject: [PATCH 3/3] chore: use --if-not-exists for test database creation in CI --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b061bb9..32467f3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -47,7 +47,7 @@ jobs: run: vendor/bin/phpstan analyse - name: Create test database - run: php bin/console doctrine:database:create --env=test --no-interaction + run: php bin/console doctrine:database:create --env=test --no-interaction --if-not-exists - name: Run database migrations run: php bin/console doctrine:migrations:migrate --no-interaction --env=test