name: PHP Composer

on: [push, pull_request]

jobs:
  test:
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        os: [ ubuntu-latest ]
        php: [ 7.4, 8.0 ]
        dependency-version: [ prefer-stable ]
        
    name: P${{ matrix.php }} - ${{ matrix.dependency-version }} - ${{ matrix.os }}

    steps:
      -   name: Checkout code
          uses: actions/checkout@v2

      -   name: Setup PHP
          uses: shivammathur/setup-php@v2
          with:
            php-version: ${{ matrix.php }}

      -   name: Install dependencies
          run: composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction --no-suggest

      -   name: Run test suite
          run: composer run-script test
      
      -   name: Generate coverage report
          run: composer run-script test-coverage-clover
    
      -   name: Upload coverage to codecov 
          uses: codecov/codecov-action@v1
          with:
            file: ./coverage.xml

