Add README sample #13
This file contains 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: Test | |
on: | |
push: | |
pull_request: | |
permissions: | |
contents: read | |
jobs: | |
tests: | |
name: Unit Tests on PHP ${{ matrix.php-versions }} with ${{ matrix.deps }} dependencies | |
strategy: | |
matrix: | |
php-versions: | |
- '8.2' | |
- '8.3' | |
deps: | |
- 'highest' | |
- 'lowest' | |
env: | |
extensions: pdo_mysql | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 1 | |
- name: Setup cache Environment | |
id: extcache | |
uses: shivammathur/cache-extensions@v1 | |
with: | |
php-version: ${{ matrix.php-versions }} | |
extensions: ${{ env.extensions }} | |
key: ext-cache-v1 | |
- name: Cache extensions | |
uses: actions/cache@v4 | |
with: | |
path: ${{ steps.extcache.outputs.dir }} | |
key: ${{ steps.extcache.outputs.key }} | |
restore-keys: ${{ steps.extcache.outputs.key }} | |
- name: Setup PHP | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: ${{ matrix.php-versions }} | |
extensions: ${{ env.extensions }} | |
coverage: pcov | |
env: | |
fail-fast: true | |
- name: Get composer cache directory | |
id: composer-cache | |
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT | |
- name: Cache dependencies | |
uses: actions/cache@v4 | |
with: | |
path: ${{ steps.composer-cache.outputs.dir }} | |
key: ${{ runner.os }}-${{ matrix.deps }}-composer-${{ hashFiles('**/composer.json') }} | |
restore-keys: ${{ runner.os }}-${{ matrix.deps }}-composer- | |
- name: Install dependencies | |
run: | | |
if [[ "${{ matrix.deps }}" == "lowest" ]]; then | |
composer update --prefer-lowest --no-progress --ansi --prefer-dist | |
else | |
composer update --prefer-stable --no-progress --ansi --prefer-dist | |
fi | |
- name: Run PHPUnit | |
run: composer test | |
- name: Run PHPStan | |
run: composer lint |