|
| 1 | +name: PHP Test and Coverage |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + push: |
| 6 | + branches: |
| 7 | + - master |
| 8 | + |
| 9 | +jobs: |
| 10 | + test: |
| 11 | + runs-on: ubuntu-latest |
| 12 | + strategy: |
| 13 | + matrix: |
| 14 | + php: [ 7.2, 7.3 ] |
| 15 | + include: |
| 16 | + - php: 7.2 |
| 17 | + coverage: yes |
| 18 | + steps: |
| 19 | + - name: Checkout code |
| 20 | + uses: actions/checkout@v3 |
| 21 | + |
| 22 | + - name: Setup PHP |
| 23 | + uses: shivammathur/setup-php@v2 |
| 24 | + with: |
| 25 | + php-version: ${{ matrix.php }} |
| 26 | + extensions: mbstring, xml |
| 27 | + coverage: ${{ matrix.coverage == 'yes' }} |
| 28 | + |
| 29 | + - name: Cache dependencies |
| 30 | + uses: actions/cache@v3 |
| 31 | + with: |
| 32 | + path: ~/.composer/cache |
| 33 | + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} |
| 34 | + restore-keys: ${{ runner.os }}-composer- |
| 35 | + |
| 36 | + - name: Install dependencies |
| 37 | + run: composer install --prefer-source |
| 38 | + |
| 39 | + - name: Prepare test coverage (if applicable) |
| 40 | + if: ${{ matrix.coverage == 'yes' }} |
| 41 | + run: | |
| 42 | + curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter |
| 43 | + chmod +x ./cc-test-reporter |
| 44 | + ./cc-test-reporter before-build |
| 45 | +
|
| 46 | + - name: Run tests without coverage |
| 47 | + if: ${{ matrix.coverage != 'yes' }} |
| 48 | + run: composer test |
| 49 | + |
| 50 | + - name: Run tests with coverage |
| 51 | + if: ${{ matrix.coverage == 'yes' }} |
| 52 | + run: composer testc |
| 53 | + |
| 54 | + - name: Code checks |
| 55 | + if: ${{ matrix.coverage == 'yes' }} |
| 56 | + run: composer check-code |
| 57 | + |
| 58 | + - name: Upload test coverage (if applicable) |
| 59 | + if: ${{ matrix.coverage == 'yes' }} |
| 60 | + run: ./cc-test-reporter after-build --coverage-input-type clover --exit-code ${{ steps.test.outcome }} |
0 commit comments