Migrate CI from Travis to GitHub Actions #4
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI | |
| on: | |
| push: | |
| branches: | |
| - master | |
| pull_request: | |
| jobs: | |
| test: | |
| name: PHP ${{ matrix.php }}${{ matrix.prefer-lowest == '--prefer-lowest' && ' (lowest)' || '' }} | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| php: ['7.4'] | |
| prefer-lowest: ['', '--prefer-lowest'] | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup PHP | |
| uses: shivammathur/setup-php@v2 | |
| with: | |
| php-version: ${{ matrix.php }} | |
| coverage: xdebug | |
| tools: composer:v2 | |
| - name: Get Composer cache directory | |
| id: composer-cache | |
| run: echo "dir=$(composer config cache-files-dir)" >> "$GITHUB_OUTPUT" | |
| - name: Cache Composer packages | |
| uses: actions/cache@v4 | |
| with: | |
| path: ${{ steps.composer-cache.outputs.dir }} | |
| key: composer-${{ matrix.php }}-${{ matrix.prefer-lowest }}-${{ hashFiles('composer.json') }} | |
| restore-keys: | | |
| composer-${{ matrix.php }}- | |
| - name: Pin Composer platform to the runtime PHP version | |
| run: composer config platform.php "$(php -r 'echo PHP_VERSION;')" | |
| - name: Install dependencies | |
| run: composer update --no-interaction --prefer-dist ${{ matrix.prefer-lowest }} | |
| - name: Lint (phpcs) | |
| run: vendor/bin/phpcs -p --warning-severity=0 src/ tests/ | |
| - name: Unit tests | |
| run: vendor/bin/phpunit --coverage-clover=./tests/report/coverage.clover | |
| - name: Upload coverage to Scrutinizer | |
| # Upload once, from a single representative job (matches the old single Travis upload). | |
| if: ${{ matrix.prefer-lowest == '' }} | |
| continue-on-error: true | |
| run: | | |
| wget https://scrutinizer-ci.com/ocular.phar | |
| php ocular.phar code-coverage:upload --format=php-clover ./tests/report/coverage.clover |