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..4e319a02 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 == true && '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 @@ -125,7 +130,12 @@ 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 diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index e8645328..1d56c7d7 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 == true && '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: | @@ -105,7 +110,12 @@ jobs: continue-on-error: ${{ matrix.continue-on-error || false }} - name: Run unit test suite - run: composer run-unit-tests + 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/.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 diff --git a/composer.json b/composer.json index 3164976b..a7d5a4e3 100644 --- a/composer.json +++ b/composer.json @@ -71,14 +71,11 @@ "phpstan": [ "phpstan analyse --configuration=./ci/phpstan/config.neon" ], - "phpunit": [ - "XDEBUG_MODE=coverage phpunit" - ], "phpunit:unit": [ - "@phpunit --configuration=./ci/phpunit/config-unit.xml" + "phpunit --configuration=./ci/phpunit/config-unit.xml" ], "phpunit:integration": [ - "@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"