Skip to content

Commit

Permalink
[CI] Add GitHub Actions: test.yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
il-masaru-yamagishi committed Aug 1, 2024
1 parent b782522 commit 9161b43
Showing 1 changed file with 83 additions and 0 deletions.
83 changes: 83 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
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.1'
- '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 --no-suggest --ansi --prefer-dist
else
composer update --prefer-stable --no-progress --no-suggest --ansi --prefer-dist
fi
- name: Run PHPUnit
run: composer test

- name: Run PHPStan
run: composer lint

0 comments on commit 9161b43

Please sign in to comment.