|
| 1 | + |
| 2 | +# Run this workflow every time a new commit pushed to your repository |
| 3 | +on: |
| 4 | + push: |
| 5 | + |
| 6 | +jobs: |
| 7 | + tests: |
| 8 | + if: "! contains(toJSON(github.event.commits.*.msg), 'skip') && ! contains(toJSON(github.event.commits.*.msg), 'ci')" #skip ci... |
| 9 | + runs-on: ${{ matrix.operating-system }} |
| 10 | + |
| 11 | + strategy: |
| 12 | + fail-fast: false |
| 13 | + matrix: |
| 14 | + operating-system: [ubuntu-20.04] |
| 15 | + php-versions: ['7.2', '7.3', '7.4', '8.0'] |
| 16 | + include: |
| 17 | + - operating-system: ubuntu-16.04 |
| 18 | + php-versions: '7.1' |
| 19 | + COMPOSER_FLAGS: '--prefer-stable --prefer-lowest' |
| 20 | + COVERAGE: 'true' |
| 21 | + PHPUNIT_FLAGS: '--coverage-clover build/coverage.xml' |
| 22 | + |
| 23 | + name: PHP ${{ matrix.php-versions }} - ${{ matrix.operating-system }} |
| 24 | + |
| 25 | + env: |
| 26 | + extensions: curl json libxml dom |
| 27 | + key: cache-v1 # can be any string, change to clear the extension cache. |
| 28 | + |
| 29 | + steps: |
| 30 | + # Checks out a copy of your repository on the ubuntu machine |
| 31 | + - name: Checkout code |
| 32 | + uses: actions/checkout@v2 |
| 33 | + |
| 34 | + - name: Setup cache environment |
| 35 | + id: extcache |
| 36 | + uses: shivammathur/cache-extensions@v1 |
| 37 | + with: |
| 38 | + php-version: ${{ matrix.php-versions }} |
| 39 | + extensions: ${{ env.extensions }} |
| 40 | + key: ${{ env.key }} |
| 41 | + |
| 42 | + - name: Cache PHP Extensions |
| 43 | + uses: actions/cache@v2 |
| 44 | + with: |
| 45 | + path: ${{ steps.extcache.outputs.dir }} |
| 46 | + key: ${{ steps.extcache.outputs.key }} |
| 47 | + restore-keys: ${{ steps.extcache.outputs.key }} |
| 48 | + |
| 49 | + - name: Cache Composer Dependencies |
| 50 | + uses: actions/cache@v1 |
| 51 | + with: |
| 52 | + path: ~/.composer/cache/files |
| 53 | + key: dependencies-composer-${{ hashFiles('composer.json') }} |
| 54 | + |
| 55 | + - name: Setup PHP Action |
| 56 | + uses: shivammathur/[email protected] |
| 57 | + with: |
| 58 | + php-version: ${{ matrix.php-versions }} |
| 59 | + extensions: ${{ env.extensions }} |
| 60 | + coverage: xdebug |
| 61 | + tools: pecl, composer |
| 62 | + |
| 63 | + - name: Get composer cache directory |
| 64 | + id: composer-cache |
| 65 | + run: echo "::set-output name=dir::$(composer config cache-files-dir)" |
| 66 | + |
| 67 | + - name: Cache dependencies |
| 68 | + uses: actions/cache@v2 |
| 69 | + with: |
| 70 | + path: ${{ steps.composer-cache.outputs.dir }} |
| 71 | + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} |
| 72 | + restore-keys: ${{ runner.os }}-composer- |
| 73 | + |
| 74 | + - name: Composer self update |
| 75 | + run: composer self-update |
| 76 | + |
| 77 | + - name: Install Composer dependencies |
| 78 | + run: composer update ${{ matrix.COMPOSER_FLAGS }} --prefer-source --no-interaction |
| 79 | + |
| 80 | + - name: boot test server |
| 81 | + run: vendor/bin/http_test_server > /dev/null 2>&1 & |
| 82 | + |
| 83 | + - name: Apply tests |
| 84 | + run: composer test |
| 85 | + |
| 86 | + - name: Apply coverage |
| 87 | + if: ${{ matrix.COVERAGE == 'true' }} |
| 88 | + run: | |
| 89 | + wget https://scrutinizer-ci.com/ocular.phar |
| 90 | + php ocular.phar code-coverage:upload --format=php-clover build/coverage.xml |
0 commit comments