|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - master |
| 7 | + - develop |
| 8 | + pull_request: |
| 9 | + branches: |
| 10 | + - master |
| 11 | + - develop |
| 12 | + |
| 13 | +permissions: |
| 14 | + contents: read |
| 15 | + |
| 16 | +jobs: |
| 17 | + test: |
| 18 | + name: Test (PHP ${{ matrix.php }}) |
| 19 | + runs-on: ubuntu-latest |
| 20 | + |
| 21 | + strategy: |
| 22 | + fail-fast: false |
| 23 | + matrix: |
| 24 | + php: ['7.4', '8.0', '8.1', '8.2'] |
| 25 | + |
| 26 | + steps: |
| 27 | + - name: Checkout code |
| 28 | + uses: actions/checkout@v4 |
| 29 | + |
| 30 | + - name: Set up PHP |
| 31 | + uses: shivammathur/setup-php@v2 |
| 32 | + with: |
| 33 | + php-version: ${{ matrix.php }} |
| 34 | + coverage: xdebug |
| 35 | + tools: composer |
| 36 | + |
| 37 | + - name: Get Composer cache directory |
| 38 | + id: composer-cache |
| 39 | + run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT |
| 40 | + |
| 41 | + - name: Cache Composer dependencies |
| 42 | + uses: actions/cache@v4 |
| 43 | + with: |
| 44 | + path: ${{ steps.composer-cache.outputs.dir }} |
| 45 | + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} |
| 46 | + restore-keys: ${{ runner.os }}-composer- |
| 47 | + |
| 48 | + - name: Install PHP dependencies |
| 49 | + run: composer install --no-interaction --prefer-dist |
| 50 | + |
| 51 | + - name: Run PHPUnit tests |
| 52 | + run: vendor/bin/phpunit --colors=always |
| 53 | + |
| 54 | + - name: Run PHPUnit tests with coverage |
| 55 | + if: matrix.php == '8.1' |
| 56 | + run: vendor/bin/phpunit --coverage-clover=coverage.xml --colors=always |
| 57 | + |
| 58 | + - name: Upload coverage to Codecov |
| 59 | + if: matrix.php == '8.1' |
| 60 | + uses: codecov/codecov-action@v4 |
| 61 | + with: |
| 62 | + files: ./coverage.xml |
| 63 | + flags: unittests |
| 64 | + name: codecov-php-${{ matrix.php }} |
| 65 | + fail_ci_if_error: false |
| 66 | + token: ${{ secrets.CODECOV_TOKEN }} |
| 67 | + |
| 68 | + lint: |
| 69 | + name: Lint (PHP ${{ matrix.php }}) |
| 70 | + runs-on: ubuntu-latest |
| 71 | + |
| 72 | + strategy: |
| 73 | + fail-fast: false |
| 74 | + matrix: |
| 75 | + php: ['7.4', '8.0', '8.1', '8.2'] |
| 76 | + |
| 77 | + steps: |
| 78 | + - name: Checkout code |
| 79 | + uses: actions/checkout@v4 |
| 80 | + |
| 81 | + - name: Set up PHP |
| 82 | + uses: shivammathur/setup-php@v2 |
| 83 | + with: |
| 84 | + php-version: ${{ matrix.php }} |
| 85 | + tools: composer, cs2pr |
| 86 | + |
| 87 | + - name: Get Composer cache directory |
| 88 | + id: composer-cache |
| 89 | + run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT |
| 90 | + |
| 91 | + - name: Cache Composer dependencies |
| 92 | + uses: actions/cache@v4 |
| 93 | + with: |
| 94 | + path: ${{ steps.composer-cache.outputs.dir }} |
| 95 | + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} |
| 96 | + restore-keys: ${{ runner.os }}-composer- |
| 97 | + |
| 98 | + - name: Install PHP dependencies |
| 99 | + run: composer install --no-interaction --prefer-dist |
| 100 | + |
| 101 | + - name: Run PHPCS |
| 102 | + run: composer run-script lint |
0 commit comments