Skip to content

Unit tests

Unit tests #197

Workflow file for this run

name: Unit tests
permissions:
contents: read
on:
pull_request:
branches: [ main, develop ]
push:
branches: [ main, develop ]
schedule:
# Run daily at 2 AM UTC to catch dependency issues
- cron: '0 2 * * *'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
COMPOSER_ROOT_VERSION: "1.0.0"
jobs:
# =====================================================
# Unit Tests with Matrix Strategy
# =====================================================
unit-tests:
permissions:
contents: read
name: Unit Tests
runs-on: ubuntu-latest
timeout-minutes: 15
env:
XDEBUG_MODE: coverage
strategy:
fail-fast: false
matrix:
php: [ '8.2', '8.3', '8.4' ]
symfony: [ '6.4.*', '7.0.*', '7.1.*', '7.2.*', '7.3.*' ]
dependencies: [ 'highest' ]
include:
- php: '8.2'
symfony: '6.4.*'
dependencies: 'lowest'
exclude:
# Exclude invalid combinations
- php: '8.2'
symfony: '7.1.*'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: opentelemetry, protobuf, json, mbstring, xdebug
coverage: none
tools: composer:v2
- name: Show php extensions
run: php -m
- name: Get composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache composer dependencies
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ matrix.php }}-${{ matrix.symfony }}-${{ matrix.dependencies }}-${{ hashFiles('**/composer.lock', '**/composer.json') }}
restore-keys: |
${{ runner.os }}-composer-${{ matrix.php }}-${{ matrix.symfony }}-${{ matrix.dependencies }}-
${{ runner.os }}-composer-${{ matrix.php }}-${{ matrix.symfony }}-
${{ runner.os }}-composer-${{ matrix.php }}-
- name: Configure Symfony version
if: matrix.symfony != ''
run: |
composer require symfony/dependency-injection:${{ matrix.symfony }} --no-update --no-scripts
composer require symfony/config:${{ matrix.symfony }} --no-update --no-scripts
composer require symfony/yaml:${{ matrix.symfony }} --no-update --no-scripts
composer require symfony/http-kernel:${{ matrix.symfony }} --no-update --no-scripts
- name: Install dependencies (highest)
if: matrix.dependencies == 'highest'
run: composer update --prefer-dist --no-progress
- name: Install dependencies (lowest)
if: matrix.dependencies == 'lowest'
run: composer update --prefer-dist --no-progress --prefer-lowest
- name: Add PHPUnit matcher
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
- name: Run PHPUnit tests
run: vendor/bin/phpunit --testdox