add test coverage reporting #10
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Test | |
| on: | |
| push: | |
| pull_request: | |
| permissions: | |
| contents: read | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| lint-and-test: | |
| name: PHP ${{ matrix.php-version }} | |
| runs-on: ubuntu-26.04 | |
| env: | |
| COMPOSER_CACHE_DIR: .cache/composer | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| php-version: | |
| - '8.1' | |
| - '8.2' | |
| - '8.3' | |
| - '8.4' | |
| - '8.5' | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v7 | |
| - name: Setup PHP | |
| uses: shivammathur/setup-php@v2 | |
| with: | |
| php-version: ${{ matrix.php-version }} | |
| coverage: none | |
| tools: composer:v2 | |
| - name: Setup cache | |
| uses: actions/cache@v6 | |
| with: | |
| path: .cache | |
| key: ${{ runner.os }}-php-${{ matrix.php-version }}-cache-${{ hashFiles('composer.lock', 'phpunit.xml*', 'phpstan.neon*') }} | |
| restore-keys: ${{ runner.os }}-php-${{ matrix.php-version }}-cache- | |
| - name: Validate Composer configuration | |
| run: composer validate --strict | |
| - name: Install dependencies | |
| run: composer install --no-interaction --no-progress --prefer-dist | |
| - name: Run linter | |
| run: composer lint | |
| - name: Run static analysis | |
| run: composer analyse | |
| - name: Run tests | |
| run: composer test | |
| test-coverage: | |
| name: Test coverage | |
| runs-on: ubuntu-26.04 | |
| env: | |
| COMPOSER_CACHE_DIR: .cache/composer | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v7 | |
| - name: Setup PHP | |
| uses: shivammathur/setup-php@v2 | |
| with: | |
| php-version: '8.1' | |
| coverage: xdebug | |
| tools: composer:v2 | |
| - name: Setup cache | |
| uses: actions/cache@v6 | |
| with: | |
| path: .cache | |
| key: ${{ runner.os }}-php-8.1-coverage-cache-${{ hashFiles('composer.lock', 'phpunit.xml*', 'phpstan.neon*') }} | |
| restore-keys: ${{ runner.os }}-php-8.1-coverage-cache- | |
| - name: Validate Composer configuration | |
| run: composer validate --strict | |
| - name: Install dependencies | |
| run: composer install | |
| - name: Run tests with coverage | |
| run: composer test:coverage | |
| - name: Upload coverage report | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| name: test-coverage | |
| path: tests/coverage |