|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: [pull_request, push] |
| 4 | + |
| 5 | +env: |
| 6 | + COMPOSER_COMMAND: composer update |
| 7 | + COMPOSER_ARGS: --no-interaction --no-progress |
| 8 | + |
| 9 | +jobs: |
| 10 | + Dependencies: |
| 11 | + runs-on: ubuntu-latest |
| 12 | + name: Dependency Checks |
| 13 | + steps: |
| 14 | + - name: Checkout |
| 15 | + uses: actions/checkout@v2 |
| 16 | + |
| 17 | + - name: Setup PHP |
| 18 | + uses: shivammathur/setup-php@v2 |
| 19 | + with: |
| 20 | + php-version: '7.4' |
| 21 | + coverage: none |
| 22 | + |
| 23 | + - name: Get composer cache directory |
| 24 | + id: composer-cache |
| 25 | + run: echo "::set-output name=dir::$(composer config cache-files-dir)" |
| 26 | + |
| 27 | + - name: Cache composer dependencies |
| 28 | + uses: actions/cache@v2 |
| 29 | + with: |
| 30 | + path: ${{ steps.composer-cache.outputs.dir }} |
| 31 | + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} |
| 32 | + restore-keys: ${{ runner.os }}-composer- |
| 33 | + |
| 34 | + - name: Install dependencies |
| 35 | + run: composer install $COMPOSER_ARGS |
| 36 | + |
| 37 | + - name: Run require check |
| 38 | + run: ./vendor/bin/composer-require-checker |
| 39 | + |
| 40 | + Tests: |
| 41 | + strategy: |
| 42 | + fail-fast: false |
| 43 | + matrix: |
| 44 | + php-versions: ['7.4', '8.0'] |
| 45 | + deps: [lowest, highest, locked] |
| 46 | + include: |
| 47 | + - deps: lowest |
| 48 | + deps-arg: --prefer-lowest |
| 49 | + - deps: locked |
| 50 | + composer-command: composer install |
| 51 | + hash-file: '**/composer.lock' |
| 52 | + runs-on: ubuntu-latest |
| 53 | + name: Test on PHP ${{ matrix.php-versions }} with deps ${{ matrix.deps }} |
| 54 | + steps: |
| 55 | + - name: Checkout |
| 56 | + uses: actions/checkout@v2 |
| 57 | + |
| 58 | + - name: Setup PHP ${{ matrix.php-versions }} |
| 59 | + uses: shivammathur/setup-php@v2 |
| 60 | + with: |
| 61 | + php-version: ${{ matrix.php-versions }} |
| 62 | + coverage: pcov |
| 63 | + env: |
| 64 | + update: true |
| 65 | + |
| 66 | + - name: Get composer cache directory |
| 67 | + id: composer-cache |
| 68 | + run: echo "::set-output name=dir::$(composer config cache-files-dir)" |
| 69 | + |
| 70 | + - name: Cache composer dependencies |
| 71 | + uses: actions/cache@v2 |
| 72 | + with: |
| 73 | + path: ${{ steps.composer-cache.outputs.dir }} |
| 74 | + key: >- |
| 75 | + ${{ format('{0}-composer-{1}-{2}', |
| 76 | + runner.os, |
| 77 | + matrix.deps, |
| 78 | + hashFiles(matrix.hash-file || '**/composer.json') |
| 79 | + ) }} |
| 80 | + restore-keys: ${{ runner.os }}-composer-${{ matrix.deps }}- |
| 81 | + |
| 82 | + - name: Install ${{ matrix.deps }} dependencies |
| 83 | + env: |
| 84 | + COMPOSER_COMMAND: ${{ matrix.composer-command || env.COMPOSER_COMMAND }} |
| 85 | + run: $COMPOSER_COMMAND $COMPOSER_ARGS ${{ matrix.deps-arg }} |
| 86 | + |
| 87 | + - name: Run tests |
| 88 | + run: vendor/bin/phpunit --coverage-text --coverage-clover=coverage.clover |
| 89 | + |
| 90 | + - name: Upload coverage to Scrutinizer |
| 91 | + run: | |
| 92 | + wget https://scrutinizer-ci.com/ocular.phar |
| 93 | + php ocular.phar code-coverage:upload --format=php-clover coverage.clover |
0 commit comments