name: PHPUnit

on: [push, pull_request]

jobs:
  phpunit:
    strategy:
      matrix:
        php: ['7.3', '7.4', '8.0', '8.1.0RC5']

    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2

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

      - run: composer install

      - run: ./vendor/bin/phpunit --coverage-clover clover.xml

#      - name: Coveralls
#        uses: coverallsapp/github-action@master
#        with:
#          github-token: ${{ secrets.GITHUB_TOKEN }}
#          parallel: true
#          flag-name: php${{ matrix.php }}

      - name: Upload to coveralls
        env:
          COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        run: |
          if [ '${{ matrix.php }}' = '8.0' ]; then vendor/bin/php-coveralls -vvv ; fi