|
| 1 | +name: build |
| 2 | + |
| 3 | +on: [push, pull_request] |
| 4 | + |
| 5 | +env: |
| 6 | + DEFAULT_COMPOSER_FLAGS: "--prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi" |
| 7 | + |
| 8 | +jobs: |
| 9 | + phpunit: |
| 10 | + name: PHP ${{ matrix.php }} on ${{ matrix.os }} |
| 11 | + runs-on: ${{ matrix.os }} |
| 12 | + services: |
| 13 | + mongodb: |
| 14 | + image: mongo:${{ matrix.mongo }} |
| 15 | + ports: |
| 16 | + - 27017:27017 |
| 17 | + strategy: |
| 18 | + fail-fast: false |
| 19 | + matrix: |
| 20 | + os: [ubuntu-latest] |
| 21 | + php: ['7.0', '7.1', '7.2', '7.3', '7.4'] |
| 22 | + mongo: ['3'] |
| 23 | + |
| 24 | + steps: |
| 25 | + - name: Checkout |
| 26 | + uses: actions/checkout@v2 |
| 27 | + - name: Install PHP |
| 28 | + uses: shivammathur/setup-php@v2 |
| 29 | + with: |
| 30 | + php-version: ${{ matrix.php }} |
| 31 | + tools: pecl |
| 32 | + extensions: mongodb |
| 33 | + ini-values: date.timezone='UTC' |
| 34 | + - name: Get composer cache directory |
| 35 | + id: composer-cache |
| 36 | + run: echo "::set-output name=dir::$(composer config cache-files-dir)" |
| 37 | + - name: Cache composer dependencies |
| 38 | + uses: actions/cache@v1 |
| 39 | + with: |
| 40 | + path: ${{ steps.composer-cache.outputs.dir }} |
| 41 | + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} |
| 42 | + restore-keys: ${{ runner.os }}-composer- |
| 43 | + - name: Install dependencies |
| 44 | + run: composer update $DEFAULT_COMPOSER_FLAGS |
| 45 | + - name: PHP Unit tests for PHP 7.1 |
| 46 | + run: vendor/bin/phpunit --verbose --coverage-clover=coverage.clover --colors=always |
| 47 | + if: matrix.php == '7.1' |
| 48 | + - name: PHP Unit tests for PHP >= 7.2 |
| 49 | + run: vendor/bin/phpunit --verbose --colors=always |
| 50 | + if: matrix.php >= '7.2' |
| 51 | + - name: PHP Unit tests for PHP <= 7.0 |
| 52 | + run: vendor/bin/phpunit --verbose --colors=always |
| 53 | + if: matrix.php <= '7.0' |
| 54 | + - name: Code coverage |
| 55 | + run: | |
| 56 | + wget https://scrutinizer-ci.com/ocular.phar |
| 57 | + php ocular.phar code-coverage:upload --format=php-clover coverage.clover |
| 58 | + if: matrix.php == '7.1' |
| 59 | + continue-on-error: true # if is fork |
0 commit comments