|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main, "*.x", "feat/*", "fix/*"] |
| 6 | + pull_request: |
| 7 | + branches: [main, "*.x"] |
| 8 | + |
| 9 | +permissions: |
| 10 | + contents: read |
| 11 | + |
| 12 | +jobs: |
| 13 | + validate: |
| 14 | + name: composer validate |
| 15 | + runs-on: ubuntu-latest |
| 16 | + steps: |
| 17 | + - uses: actions/checkout@v4 |
| 18 | + - uses: shivammathur/setup-php@v2 |
| 19 | + with: |
| 20 | + php-version: "8.1" |
| 21 | + coverage: none |
| 22 | + tools: composer:v2 |
| 23 | + - run: composer validate --strict |
| 24 | + |
| 25 | + cs: |
| 26 | + name: Coding style (PHP-CS-Fixer) |
| 27 | + runs-on: ubuntu-latest |
| 28 | + needs: validate |
| 29 | + steps: |
| 30 | + - uses: actions/checkout@v4 |
| 31 | + - uses: shivammathur/setup-php@v2 |
| 32 | + with: |
| 33 | + php-version: "8.1" |
| 34 | + coverage: none |
| 35 | + tools: composer:v2 |
| 36 | + - name: Install dependencies |
| 37 | + run: composer install --prefer-dist --no-progress --no-interaction |
| 38 | + - name: Check coding standards |
| 39 | + run: composer cs-check |
| 40 | + |
| 41 | + stan: |
| 42 | + name: Static analysis (PHPStan) |
| 43 | + runs-on: ubuntu-latest |
| 44 | + needs: validate |
| 45 | + steps: |
| 46 | + - uses: actions/checkout@v4 |
| 47 | + - uses: shivammathur/setup-php@v2 |
| 48 | + with: |
| 49 | + php-version: "8.3" |
| 50 | + coverage: none |
| 51 | + tools: composer:v2 |
| 52 | + - name: Install dependencies |
| 53 | + run: composer install --prefer-dist --no-progress --no-interaction |
| 54 | + - name: Run PHPStan |
| 55 | + run: composer stan |
| 56 | + |
| 57 | + tests: |
| 58 | + name: PHPUnit (PHP ${{ matrix.php }}, ${{ matrix.deps }}) |
| 59 | + runs-on: ubuntu-latest |
| 60 | + needs: validate |
| 61 | + strategy: |
| 62 | + fail-fast: false |
| 63 | + matrix: |
| 64 | + php: ["8.1", "8.2", "8.3", "8.4"] |
| 65 | + deps: ["highest"] |
| 66 | + include: |
| 67 | + - php: "8.1" |
| 68 | + deps: "lowest" |
| 69 | + steps: |
| 70 | + - uses: actions/checkout@v4 |
| 71 | + |
| 72 | + - name: Set up PHP ${{ matrix.php }} |
| 73 | + uses: shivammathur/setup-php@v2 |
| 74 | + with: |
| 75 | + php-version: ${{ matrix.php }} |
| 76 | + coverage: none |
| 77 | + tools: composer:v2 |
| 78 | + |
| 79 | + - name: Get composer cache directory |
| 80 | + id: composer-cache |
| 81 | + run: echo "dir=$(composer config cache-files-dir)" >> "$GITHUB_OUTPUT" |
| 82 | + |
| 83 | + - name: Cache composer dependencies |
| 84 | + uses: actions/cache@v4 |
| 85 | + with: |
| 86 | + path: ${{ steps.composer-cache.outputs.dir }} |
| 87 | + key: composer-${{ matrix.php }}-${{ matrix.deps }}-${{ hashFiles('**/composer.json') }} |
| 88 | + restore-keys: composer-${{ matrix.php }}-${{ matrix.deps }}- |
| 89 | + |
| 90 | + - name: Install highest dependencies |
| 91 | + if: matrix.deps == 'highest' |
| 92 | + run: composer update --prefer-dist --no-progress --no-interaction |
| 93 | + |
| 94 | + - name: Install lowest dependencies |
| 95 | + if: matrix.deps == 'lowest' |
| 96 | + run: composer update --prefer-dist --no-progress --no-interaction --prefer-lowest --prefer-stable |
| 97 | + |
| 98 | + - name: Run PHPUnit |
| 99 | + run: composer test |
| 100 | + |
| 101 | + coverage: |
| 102 | + name: Coverage |
| 103 | + runs-on: ubuntu-latest |
| 104 | + needs: tests |
| 105 | + steps: |
| 106 | + - uses: actions/checkout@v4 |
| 107 | + |
| 108 | + - name: Set up PHP |
| 109 | + uses: shivammathur/setup-php@v2 |
| 110 | + with: |
| 111 | + php-version: "8.3" |
| 112 | + coverage: pcov |
| 113 | + tools: composer:v2 |
| 114 | + |
| 115 | + - name: Install dependencies |
| 116 | + run: composer install --prefer-dist --no-progress --no-interaction |
| 117 | + |
| 118 | + - name: Run PHPUnit with coverage |
| 119 | + run: vendor/bin/phpunit --coverage-clover=coverage.xml |
| 120 | + |
| 121 | + - name: Upload coverage to Codecov |
| 122 | + uses: codecov/codecov-action@v5 |
| 123 | + with: |
| 124 | + files: ./coverage.xml |
| 125 | + flags: phpunit |
| 126 | + fail_ci_if_error: false |
0 commit comments