|
| 1 | +name: Tests |
| 2 | + |
| 3 | +on: |
| 4 | + # Run testing on all push and pull requests for the main branch that have committed changes in PHP files |
| 5 | + push: |
| 6 | + branches: [ "main" ] |
| 7 | + paths: |
| 8 | + - '**.php' |
| 9 | + pull_request: |
| 10 | + branches: [ "main" ] |
| 11 | + paths: |
| 12 | + - '**.php' |
| 13 | + # Make it possible to run the workflow manually |
| 14 | + workflow_dispatch: |
| 15 | + |
| 16 | +permissions: |
| 17 | + contents: read |
| 18 | + |
| 19 | +jobs: |
| 20 | + test: |
| 21 | + |
| 22 | + runs-on: ${{ matrix.os }} |
| 23 | + |
| 24 | + # Define the matrix of different PHP and dependency versions |
| 25 | + strategy: |
| 26 | + # Fail the whole workflow if one of the jobs fails |
| 27 | + fail-fast: true |
| 28 | + matrix: |
| 29 | + os: [ ubuntu-latest ] |
| 30 | + php: [ 8.2, 8.3, 8.4 ] |
| 31 | + dependency-version: [ prefer-lowest, prefer-stable ] |
| 32 | + |
| 33 | + name: ${{ matrix.os }} / PHP ${{ matrix.php }} / ${{ matrix.dependency-version }} |
| 34 | + |
| 35 | + steps: |
| 36 | + |
| 37 | + #- name: Configure operating system |
| 38 | + # if: matrix.os == 'ubuntu-latest' |
| 39 | + # run: sudo apt-get update && sudo apt-get install -y locales locales-all |
| 40 | + |
| 41 | + - name: Checkout code |
| 42 | + uses: actions/checkout@v4 |
| 43 | + with: |
| 44 | + ref: ${{ github.head_ref }} |
| 45 | + |
| 46 | + - name: Validate composer.json and composer.lock |
| 47 | + run: composer validate --strict |
| 48 | + |
| 49 | + - name: Cache Composer packages |
| 50 | + id: composer-cache |
| 51 | + uses: actions/cache@v3 |
| 52 | + with: |
| 53 | + path: vendor |
| 54 | + key: ${{ runner.os }}-php-${{ matrix.php }}-${{ matrix.dependency-version }}-${{ hashFiles('**/composer.lock') }} |
| 55 | + |
| 56 | + - name: Setup PHP |
| 57 | + uses: shivammathur/setup-php@v2 |
| 58 | + with: |
| 59 | + php-version: ${{ matrix.php }} |
| 60 | + coverage: xdebug |
| 61 | + # extensions: mbstring, gd, intl |
| 62 | + |
| 63 | + - name: Install dependencies |
| 64 | + run: composer update --prefer-dist --no-progress --${{ matrix.dependency-version }} |
| 65 | + |
| 66 | + - name: Run test suite |
| 67 | + run: composer test -- --coverage-clover ./coverage.xml |
| 68 | + |
| 69 | + - name: Upload coverage reports to Codecov |
| 70 | + # Make sure the Codecov action is only executed once |
| 71 | + if: matrix.os == 'ubuntu-latest' && matrix.php == '8.2' && matrix.dependency-version == 'prefer-stable' |
| 72 | + uses: codecov/codecov-action@v5 |
| 73 | + with: |
| 74 | + token: ${{ secrets.CODECOV_TOKEN }} |
| 75 | + files: ./coverage.xml |
| 76 | + verbose: true |
0 commit comments