Merge pull request #87 from clementtalleu/chore/allow_to_provide_redi… #170
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: Tests | |
on: | |
pull_request: | |
branches: | |
- main | |
push: | |
branches: | |
- main | |
jobs: | |
tests: | |
runs-on: ubuntu-latest | |
services: | |
redis: | |
image: redis/redis-stack-server | |
options: >- | |
--health-cmd "redis-cli ping" | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
ports: | |
- 6379:6379 | |
strategy: | |
fail-fast: false | |
matrix: | |
php-versions: ['8.2', '8.3'] | |
env: | |
REDIS_HOST: localhost | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup PHP | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: ${{ matrix.php-versions }} | |
extensions: redis, xdebug | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Configure Xdebug | |
run: echo "xdebug.mode=coverage" | sudo tee -a /etc/php/${{ matrix.php-versions }}/cli/conf.d/20-xdebug.ini | |
- 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 }}-composer-${{ hashFiles('**/composer.json') }} | |
restore-keys: ${{ runner.os }}-composer- | |
- name: Install dependencies | |
run: composer install --prefer-dist | |
- name: Install Predis optional package | |
run: composer require predis/predis | |
- name: Test cs-fixer | |
run: vendor/bin/php-cs-fixer fix src --dry-run --diff --no-ansi | |
- name: Run phpstan | |
run: vendor/bin/phpstan analyse src --level=5 | |
- name: Run tests with redis extension | |
run: XDEBUG_MODE=coverage REDIS_CLIENT=redis vendor/bin/phpunit | |
- name: Run tests with predis dependency | |
run: XDEBUG_MODE=coverage REDIS_CLIENT=predis vendor/bin/phpunit | |
- name: Upload coverage to Codecov | |
uses: codecov/codecov-action@v4 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
files: ./coverage.xml | |
verbose: true | |
- name: composer audit | |
run: composer audit | |
- name: composer validate | |
run: composer validate |