|
| 1 | +name: PHPUnit |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: ["master", "main", "v3.x", "v3.0.x"] |
| 6 | + pull_request: |
| 7 | + branches: ["master", "main", "v3.x", "v3.0.x"] |
| 8 | + |
| 9 | +permissions: |
| 10 | + contents: read |
| 11 | + |
| 12 | +jobs: |
| 13 | + test: |
| 14 | + name: PHP ${{ matrix.php-version }} |
| 15 | + runs-on: ubuntu-latest |
| 16 | + |
| 17 | + strategy: |
| 18 | + fail-fast: false |
| 19 | + matrix: |
| 20 | + php-version: ["8.1", "8.2", "8.3", "8.4"] |
| 21 | + include: |
| 22 | + - php-version: "8.3" |
| 23 | + coverage: "true" |
| 24 | + |
| 25 | + steps: |
| 26 | + - name: Checkout |
| 27 | + uses: actions/checkout@v4 |
| 28 | + |
| 29 | + - name: Setup PHP |
| 30 | + uses: shivammathur/setup-php@v2 |
| 31 | + with: |
| 32 | + php-version: ${{ matrix.php-version }} |
| 33 | + extensions: pdo, pdo_sqlite |
| 34 | + coverage: ${{ matrix.coverage == 'true' && 'xdebug' || 'none' }} |
| 35 | + tools: composer:v2 |
| 36 | + |
| 37 | + - name: Cache Composer dependencies |
| 38 | + uses: actions/cache@v4 |
| 39 | + with: |
| 40 | + path: ~/.cache/composer |
| 41 | + key: composer-${{ runner.os }}-${{ matrix.php-version }}-${{ hashFiles('**/composer.json') }} |
| 42 | + restore-keys: | |
| 43 | + composer-${{ runner.os }}-${{ matrix.php-version }}- |
| 44 | +
|
| 45 | + - name: Install dependencies |
| 46 | + run: composer update --prefer-dist --no-progress --no-interaction |
| 47 | + |
| 48 | + - name: Run tests |
| 49 | + if: matrix.coverage != 'true' |
| 50 | + run: vendor/bin/phpunit --no-coverage |
| 51 | + |
| 52 | + - name: Run tests with coverage |
| 53 | + if: matrix.coverage == 'true' |
| 54 | + run: vendor/bin/phpunit --coverage-text --coverage-clover=build/coverage.xml |
| 55 | + |
| 56 | + - name: Upload coverage artifact |
| 57 | + if: matrix.coverage == 'true' |
| 58 | + uses: actions/upload-artifact@v4 |
| 59 | + with: |
| 60 | + name: coverage-report |
| 61 | + path: build/coverage.xml |
| 62 | + retention-days: 7 |
0 commit comments