|
| 1 | +name: PHPUnit |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + branches: |
| 6 | + - develop |
| 7 | + push: |
| 8 | + branches: |
| 9 | + - develop |
| 10 | + |
| 11 | +jobs: |
| 12 | + main: |
| 13 | + name: PHP ${{ matrix.php-versions }} Unit Tests |
| 14 | + |
| 15 | + strategy: |
| 16 | + matrix: |
| 17 | + php-versions: ['7.3', '7.4', '8.0'] |
| 18 | + |
| 19 | + runs-on: ubuntu-latest |
| 20 | + |
| 21 | + if: "!contains(github.event.head_commit.message, '[ci skip]')" |
| 22 | + |
| 23 | + steps: |
| 24 | + - name: Checkout |
| 25 | + uses: actions/checkout@v2 |
| 26 | + |
| 27 | + - name: Setup PHP, with composer and extensions |
| 28 | + uses: shivammathur/setup-php@v2 |
| 29 | + with: |
| 30 | + php-version: ${{ matrix.php-versions }} |
| 31 | + tools: composer, pecl, phpunit |
| 32 | + extensions: intl, json, mbstring, gd, mysqlnd, xdebug, xml, sqlite3 |
| 33 | + coverage: xdebug |
| 34 | + env: |
| 35 | + COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 36 | + |
| 37 | + - name: Get composer cache directory |
| 38 | + id: composer-cache |
| 39 | + run: echo "::set-output name=dir::$(composer config cache-files-dir)" |
| 40 | + |
| 41 | + - name: Cache composer dependencies |
| 42 | + uses: actions/cache@v2 |
| 43 | + with: |
| 44 | + path: ${{ steps.composer-cache.outputs.dir }} |
| 45 | + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} |
| 46 | + restore-keys: ${{ runner.os }}-composer- |
| 47 | + |
| 48 | + - name: Install dependencies (limited) |
| 49 | + if: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name }} |
| 50 | + run: composer update --no-progress --no-interaction --prefer-dist --optimize-autoloader |
| 51 | + |
| 52 | + - name: Install dependencies (authenticated) |
| 53 | + if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name }} |
| 54 | + run: composer update --no-progress --no-interaction --prefer-dist --optimize-autoloader |
| 55 | + env: |
| 56 | + COMPOSER_AUTH: ${{ secrets.COMPOSER_AUTH }} |
| 57 | + |
| 58 | + - name: Test with PHPUnit |
| 59 | + run: vendor/bin/phpunit --verbose --coverage-text |
| 60 | + env: |
| 61 | + TERM: xterm-256color |
| 62 | + TACHYCARDIA_MONITOR_GA: enabled |
| 63 | + |
| 64 | + - if: matrix.php-versions == '8.0' |
| 65 | + name: Mutate with Infection |
| 66 | + run: | |
| 67 | + composer global require infection/infection |
| 68 | + git fetch --depth=1 origin $GITHUB_BASE_REF |
| 69 | + infection --threads=2 --skip-initial-tests --coverage=build/phpunit --git-diff-base=origin/$GITHUB_BASE_REF --git-diff-filter=AM --logger-github --ignore-msi-with-no-mutations |
| 70 | +
|
| 71 | + - if: matrix.php-versions == '8.0' |
| 72 | + name: Run Coveralls |
| 73 | + run: vendor/bin/php-coveralls --verbose --coverage_clover=build/phpunit/clover.xml --json_path build/phpunit/coveralls-upload.json |
| 74 | + env: |
| 75 | + COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 76 | + COVERALLS_PARALLEL: true |
| 77 | + COVERALLS_FLAG_NAME: PHP ${{ matrix.php-versions }} |
| 78 | + |
| 79 | + coveralls: |
| 80 | + needs: [main] |
| 81 | + name: Coveralls Finished |
| 82 | + runs-on: ubuntu-latest |
| 83 | + steps: |
| 84 | + - name: Upload Coveralls results |
| 85 | + uses: coverallsapp/github-action@master |
| 86 | + with: |
| 87 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 88 | + parallel-finished: true |
0 commit comments