From dc49c80c73ef5cad5a8fe6d0b1a74dfc71fe57d7 Mon Sep 17 00:00:00 2001 From: Martin Georgiev Date: Tue, 21 Oct 2025 19:46:17 +0100 Subject: [PATCH 1/7] ci: optimize CI workflow performance --- .github/workflows/ci.yml | 4 ++++ .github/workflows/integration-tests.yml | 11 ++++++++--- .github/workflows/unit-tests.yml | 11 ++++++++--- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7277a940..bbf4965c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,6 +10,10 @@ on: branches: - main +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} + permissions: contents: read diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index bd597d77..4aa8a00a 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -10,6 +10,10 @@ on: branches: - main +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} + permissions: contents: read @@ -81,7 +85,7 @@ jobs: uses: shivammathur/setup-php@bf6b4fbd49ca58e4608c9c89fba0b8d90bd2a39f # v2 with: php-version: ${{ matrix.php }} - coverage: xdebug + coverage: ${{ matrix.calculate-code-coverage && 'xdebug' || 'none' }} extensions: ctype, json, mbstring, pdo_pgsql tools: composer @@ -93,9 +97,10 @@ jobs: uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4 with: path: vendor - key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} + key: ${{ runner.os }}-php-${{ matrix.php }}-pg-${{ matrix.postgres }}-${{ hashFiles('**/composer.lock') }} restore-keys: | - ${{ runner.os }}-php- + ${{ runner.os }}-php-${{ matrix.php }}-pg-${{ matrix.postgres }}- + ${{ runner.os }}-php-${{ matrix.php }}- - name: Install dependencies run: composer install --prefer-dist --no-interaction --no-progress diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index e8645328..373bda03 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -10,6 +10,10 @@ on: branches: - main +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} + permissions: contents: read @@ -63,7 +67,7 @@ jobs: uses: shivammathur/setup-php@bf6b4fbd49ca58e4608c9c89fba0b8d90bd2a39f # v2 with: php-version: ${{ matrix.php }} - coverage: xdebug + coverage: ${{ matrix.calculate-code-coverage && 'xdebug' || 'none' }} extensions: ctype, json, mbstring tools: composer @@ -72,9 +76,10 @@ jobs: uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4 with: path: vendor - key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} + key: ${{ runner.os }}-php-${{ matrix.php }}-orm-${{ matrix.doctrine-orm }}-lexer-${{ matrix.doctrine-lexer }}-${{ hashFiles('**/composer.lock') }} restore-keys: | - ${{ runner.os }}-php- + ${{ runner.os }}-php-${{ matrix.php }}-orm-${{ matrix.doctrine-orm }}-lexer-${{ matrix.doctrine-lexer }}- + ${{ runner.os }}-php-${{ matrix.php }}- - name: Install Doctrine Lexer dependency run: | From 66002c55d4e5e09ce8d65dd2d8e3f68f53f6c289 Mon Sep 17 00:00:00 2001 From: Martin Georgiev Date: Tue, 21 Oct 2025 19:50:07 +0100 Subject: [PATCH 2/7] no message --- .github/workflows/integration-tests.yml | 2 +- .github/workflows/unit-tests.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index 4aa8a00a..0162e502 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -85,7 +85,7 @@ jobs: uses: shivammathur/setup-php@bf6b4fbd49ca58e4608c9c89fba0b8d90bd2a39f # v2 with: php-version: ${{ matrix.php }} - coverage: ${{ matrix.calculate-code-coverage && 'xdebug' || 'none' }} + coverage: ${{ matrix.calculate-code-coverage == true && 'xdebug' || 'none' }} extensions: ctype, json, mbstring, pdo_pgsql tools: composer diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index 373bda03..81a6aca9 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -67,7 +67,7 @@ jobs: uses: shivammathur/setup-php@bf6b4fbd49ca58e4608c9c89fba0b8d90bd2a39f # v2 with: php-version: ${{ matrix.php }} - coverage: ${{ matrix.calculate-code-coverage && 'xdebug' || 'none' }} + coverage: ${{ matrix.calculate-code-coverage == true && 'xdebug' || 'none' }} extensions: ctype, json, mbstring tools: composer From 238fda017e6460015bd02fd9aadc883cda37063d Mon Sep 17 00:00:00 2001 From: Martin Georgiev Date: Tue, 21 Oct 2025 19:56:58 +0100 Subject: [PATCH 3/7] no message --- .github/workflows/integration-tests.yml | 1 + .github/workflows/unit-tests.yml | 2 ++ 2 files changed, 3 insertions(+) diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index 0162e502..e7e4d782 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -137,6 +137,7 @@ jobs: POSTGRES_DB: postgres_doctrine_test POSTGRES_USER: postgres POSTGRES_PASSWORD: postgres + XDEBUG_MODE: ${{ matrix.calculate-code-coverage == true && 'coverage' || 'off' }} - name: Upload coverage results to Coveralls if: matrix.calculate-code-coverage == true diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index 81a6aca9..5433420c 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -111,6 +111,8 @@ jobs: - name: Run unit test suite run: composer run-unit-tests + env: + XDEBUG_MODE: ${{ matrix.calculate-code-coverage == true && 'coverage' || 'off' }} - name: Upload coverage results to Coveralls if: matrix.calculate-code-coverage == true From e4c0ea343ca4ccf6737d73b492f28a8f01dea9eb Mon Sep 17 00:00:00 2001 From: Martin Georgiev Date: Tue, 21 Oct 2025 20:00:33 +0100 Subject: [PATCH 4/7] no message --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 3164976b..160991e4 100644 --- a/composer.json +++ b/composer.json @@ -72,7 +72,7 @@ "phpstan analyse --configuration=./ci/phpstan/config.neon" ], "phpunit": [ - "XDEBUG_MODE=coverage phpunit" + "XDEBUG_MODE=${XDEBUG_MODE:-coverage} phpunit" ], "phpunit:unit": [ "@phpunit --configuration=./ci/phpunit/config-unit.xml" From 22f9ebe0cf990ab3e139b66246352411bae2f8ce Mon Sep 17 00:00:00 2001 From: Martin Georgiev Date: Tue, 21 Oct 2025 20:05:52 +0100 Subject: [PATCH 5/7] no message --- composer.json | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/composer.json b/composer.json index 160991e4..9dade7c3 100644 --- a/composer.json +++ b/composer.json @@ -71,14 +71,11 @@ "phpstan": [ "phpstan analyse --configuration=./ci/phpstan/config.neon" ], - "phpunit": [ - "XDEBUG_MODE=${XDEBUG_MODE:-coverage} phpunit" - ], "phpunit:unit": [ - "@phpunit --configuration=./ci/phpunit/config-unit.xml" + "XDEBUG_MODE=${XDEBUG_MODE:-coverage} phpunit --configuration=./ci/phpunit/config-unit.xml" ], "phpunit:integration": [ - "@phpunit --configuration=./ci/phpunit/config-integration.xml" + "XDEBUG_MODE=${XDEBUG_MODE:-coverage} phpunit --configuration=./ci/phpunit/config-integration.xml" ], "rector": [ "rector --config=./ci/rector/config.php --ansi --no-progress-bar" From 3cafe33d98fc7f1ee61ddd0cfa7aae787e0e6a20 Mon Sep 17 00:00:00 2001 From: Martin Georgiev Date: Tue, 21 Oct 2025 21:48:26 +0100 Subject: [PATCH 6/7] Fix PHPUnit coverage warnings in CI - Remove XDEBUG_MODE from composer scripts to avoid redundancy - Update workflows to explicitly set XDEBUG_MODE=coverage when coverage is needed - Use --no-coverage flag when xdebug is not installed to prevent warnings - This fixes 'No code coverage driver available' warning causing CI failures --- .github/workflows/integration-tests.yml | 8 ++++++-- .github/workflows/unit-tests.yml | 9 ++++++--- composer.json | 4 ++-- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index e7e4d782..4e319a02 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -130,14 +130,18 @@ jobs: PGPASSWORD=postgres psql -h localhost -U postgres -d postgres_doctrine_test -c "SELECT PostGIS_Version();" - name: Run integration test suite - run: composer run-integration-tests + run: | + if [ "${{ matrix.calculate-code-coverage }}" = "true" ]; then + XDEBUG_MODE=coverage composer run-integration-tests + else + composer run-integration-tests -- --no-coverage + fi env: POSTGRES_HOST: localhost POSTGRES_PORT: 5432 POSTGRES_DB: postgres_doctrine_test POSTGRES_USER: postgres POSTGRES_PASSWORD: postgres - XDEBUG_MODE: ${{ matrix.calculate-code-coverage == true && 'coverage' || 'off' }} - name: Upload coverage results to Coveralls if: matrix.calculate-code-coverage == true diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index 5433420c..1d56c7d7 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -110,9 +110,12 @@ jobs: continue-on-error: ${{ matrix.continue-on-error || false }} - name: Run unit test suite - run: composer run-unit-tests - env: - XDEBUG_MODE: ${{ matrix.calculate-code-coverage == true && 'coverage' || 'off' }} + run: | + if [ "${{ matrix.calculate-code-coverage }}" = "true" ]; then + XDEBUG_MODE=coverage composer run-unit-tests + else + composer run-unit-tests -- --no-coverage + fi - name: Upload coverage results to Coveralls if: matrix.calculate-code-coverage == true diff --git a/composer.json b/composer.json index 9dade7c3..a7d5a4e3 100644 --- a/composer.json +++ b/composer.json @@ -72,10 +72,10 @@ "phpstan analyse --configuration=./ci/phpstan/config.neon" ], "phpunit:unit": [ - "XDEBUG_MODE=${XDEBUG_MODE:-coverage} phpunit --configuration=./ci/phpunit/config-unit.xml" + "phpunit --configuration=./ci/phpunit/config-unit.xml" ], "phpunit:integration": [ - "XDEBUG_MODE=${XDEBUG_MODE:-coverage} phpunit --configuration=./ci/phpunit/config-integration.xml" + "phpunit --configuration=./ci/phpunit/config-integration.xml" ], "rector": [ "rector --config=./ci/rector/config.php --ansi --no-progress-bar" From cf3b9bf8441a9980192bdefbdaec44fdc35c9ed2 Mon Sep 17 00:00:00 2001 From: Martin Georgiev Date: Tue, 21 Oct 2025 22:48:42 +0100 Subject: [PATCH 7/7] Fix Scrutinizer CI by explicitly setting XDEBUG_MODE=coverage - Scrutinizer needs XDEBUG_MODE=coverage to generate coverage reports - This aligns with the GitHub Actions workflow approach --- .scrutinizer.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.scrutinizer.yml b/.scrutinizer.yml index 627db6b8..77c7aaab 100644 --- a/.scrutinizer.yml +++ b/.scrutinizer.yml @@ -8,7 +8,7 @@ build: tests: override: - php-scrutinizer-run - - command: composer run-unit-tests + - command: XDEBUG_MODE=coverage composer run-unit-tests coverage: file: var/logs/test-coverage/unit/clover.xml format: clover