|
| 1 | +name: Symfony |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ "main" ] |
| 6 | + pull_request: |
| 7 | + branches: [ "main" ] |
| 8 | + |
| 9 | +permissions: |
| 10 | + contents: read |
| 11 | + |
| 12 | +jobs: |
| 13 | + tests: |
| 14 | + runs-on: ubuntu-latest |
| 15 | + |
| 16 | + services: |
| 17 | + postgres: |
| 18 | + image: postgres:15 |
| 19 | + env: |
| 20 | + POSTGRES_PASSWORD: postgres |
| 21 | + POSTGRES_DB: test_db |
| 22 | + options: >- |
| 23 | + --health-cmd pg_isready |
| 24 | + --health-interval 10s |
| 25 | + --health-timeout 5s |
| 26 | + --health-retries 5 |
| 27 | + ports: |
| 28 | + - 5432:5432 |
| 29 | + |
| 30 | + mysql: |
| 31 | + image: mysql:8.0 |
| 32 | + env: |
| 33 | + MYSQL_ROOT_PASSWORD: root |
| 34 | + MYSQL_DATABASE: test_db |
| 35 | + options: >- |
| 36 | + --health-cmd="mysqladmin ping" |
| 37 | + --health-interval=10s |
| 38 | + --health-timeout=5s |
| 39 | + --health-retries=3 |
| 40 | + ports: |
| 41 | + - 3306:3306 |
| 42 | + |
| 43 | + strategy: |
| 44 | + fail-fast: false |
| 45 | + matrix: |
| 46 | + php-version: ['8.2', '8.3', '8.4'] |
| 47 | + symfony-version: ['6.4', '7.0'] |
| 48 | + database: ['mysql', 'postgres'] |
| 49 | + |
| 50 | + name: PHP ${{ matrix.php-version }} - Symfony ${{ matrix.symfony-version }} - ${{ matrix.database }} |
| 51 | + |
| 52 | + steps: |
| 53 | + - uses: actions/checkout@v4 |
| 54 | + |
| 55 | + - name: Setup PHP |
| 56 | + uses: shivammathur/setup-php@v2 |
| 57 | + with: |
| 58 | + php-version: ${{ matrix.php-version }} |
| 59 | + extensions: mbstring, xml, ctype, iconv, intl, pdo, pdo_mysql, pdo_pgsql |
| 60 | + coverage: none |
| 61 | + |
| 62 | + - name: Cache Composer packages |
| 63 | + uses: actions/cache@v3 |
| 64 | + with: |
| 65 | + path: vendor |
| 66 | + key: ${{ runner.os }}-php-${{ matrix.php-version }}-symfony-${{ matrix.symfony-version }}-${{ hashFiles('**/composer.lock') }} |
| 67 | + restore-keys: | |
| 68 | + ${{ runner.os }}-php-${{ matrix.php-version }}-symfony-${{ matrix.symfony-version }}- |
| 69 | + |
| 70 | + - name: Install dependencies |
| 71 | + run: | |
| 72 | + composer require "symfony/framework-bundle:^${{ matrix.symfony-version }}" --no-update |
| 73 | + composer require "symfony/var-exporter:^${{ matrix.symfony-version }}" --no-update --dev |
| 74 | + composer install --prefer-dist --no-progress --no-interaction |
| 75 | + |
| 76 | + - name: Run PHPStan |
| 77 | + run: composer phpstan |
| 78 | + |
| 79 | + - name: Run PHPUnit tests (PostgreSQL) |
| 80 | + if: matrix.database == 'postgres' |
| 81 | + env: |
| 82 | + DATABASE_URL: postgresql://postgres:postgres@127.0.0.1:5432/test_db?serverVersion=15&charset=utf8 |
| 83 | + run: composer test |
| 84 | + |
| 85 | + - name: Run PHPUnit tests (MySQL) |
| 86 | + if: matrix.database == 'mysql' |
| 87 | + env: |
| 88 | + DATABASE_URL: mysql://root:root@127.0.0.1:3306/test_db?serverVersion=8.0 |
| 89 | + run: composer test |
0 commit comments