From 15e8f3c0636cca8139c795ef87495d5c46f58657 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 20 Nov 2025 04:23:12 +0000 Subject: [PATCH] Add code coverage configuration and CI integration - Add coverage configuration to phpunit.xml.dist - Include all src/ files except resources directory - Enable processUncoveredFiles for accurate coverage - Add composer scripts for coverage measurement - `composer coverage`: CLI text output - `composer coverage-report`: HTML report to coverage-html/ - Add coverage-html/ to .gitignore - Add GitHub Actions coverage job with Xdebug enabled - Runs on PHP 8.4 - Executes coverage during CI pipeline --- .github/workflows/test.yml | 27 +++++++++++++++++++++++++++ .gitignore | 1 + composer.json | 2 ++ phpunit.xml.dist | 8 ++++++++ 4 files changed, 38 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9e6af5d3..51377202 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -43,6 +43,33 @@ jobs: - name: Tests run: composer test + coverage: + name: Code Coverage + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Install PHP + uses: shivammathur/setup-php@v2 + with: + php-version: 8.4 + coverage: xdebug + + - name: Cache PHP dependencies + uses: actions/cache@v4 + with: + path: vendor + key: ${{ runner.os }}-php-8.4-composer-${{ hashFiles('**/composer.json') }} + restore-keys: ${{ runner.os }}-php-8.4-composer- + + - name: Install dependencies + run: composer install + + - name: Run tests with coverage + run: composer coverage + phpstan: name: PHPStan Static Analysis runs-on: ubuntu-latest diff --git a/.gitignore b/.gitignore index 29e4a489..51c4c040 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ *.cache *.code-workspace composer.lock +coverage-html env.php phpunit.xml vendor diff --git a/composer.json b/composer.json index 993f65e5..583af410 100644 --- a/composer.json +++ b/composer.json @@ -65,6 +65,8 @@ "scripts": { "demo": "php -S localhost:8888 demo/index.php", "test": "phpunit", + "coverage": "phpunit --coverage-text", + "coverage-report": "phpunit --coverage-html coverage-html", "cs-fix": "php-cs-fixer fix", "phpstan": "phpstan --memory-limit=-1", "update-resources": [ diff --git a/phpunit.xml.dist b/phpunit.xml.dist index d8e22e25..d706bd80 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -22,4 +22,12 @@ ignore + + + src + + + src/resources + +