|
| 1 | +name: Test |
| 2 | + |
| 3 | +on: |
| 4 | + push: ~ |
| 5 | + pull_request: |
| 6 | + branches: [ master ] |
| 7 | + |
| 8 | +jobs: |
| 9 | + test: |
| 10 | + runs-on: ubuntu-latest |
| 11 | + strategy: |
| 12 | + matrix: |
| 13 | + # Earliest and latest version of each major version |
| 14 | + php-versions: ['7.2', '7.4', '8.0', '8.1'] |
| 15 | + prefer: ['prefer-stable', 'prefer-lowest'] |
| 16 | + symfony-versions: ['^3.4', '^4', '^5', '^6'] |
| 17 | + include: |
| 18 | + - symfony-versions: '^3.4' |
| 19 | + symfony-bundle-test-version: '^1.8' |
| 20 | + exclude: |
| 21 | + # Symfony 6 requires PHP 8 |
| 22 | + - php-versions: '7.2' |
| 23 | + symfony-versions: '^6' |
| 24 | + - php-versions: '7.4' |
| 25 | + symfony-versions: '^6' |
| 26 | + # Symfony 3.4 with PHP 8 is possible, though we skip it to reduce the number of jobs |
| 27 | + - php-versions: '8.0' |
| 28 | + symfony-versions: '^3.4' |
| 29 | + - php-versions: '8.1' |
| 30 | + symfony-versions: '^3.4' |
| 31 | + name: Test PHP ${{ matrix.php-versions }}, Symfony ${{ matrix.symfony-versions }}, ${{ matrix.prefer }} |
| 32 | + |
| 33 | + steps: |
| 34 | + - uses: actions/checkout@v3 |
| 35 | + |
| 36 | + - name: Setup PHP |
| 37 | + uses: shivammathur/setup-php@v2 |
| 38 | + with: |
| 39 | + php-version: ${{ matrix.php-versions }} |
| 40 | + env: |
| 41 | + fail-fast: true |
| 42 | + |
| 43 | + - name: Get composer cache directory |
| 44 | + id: composer-cache |
| 45 | + run: echo "::set-output name=dir::$(composer config cache-files-dir)" |
| 46 | + |
| 47 | + - name: Cache dependencies |
| 48 | + uses: actions/cache@v3 |
| 49 | + with: |
| 50 | + path: ${{ steps.composer-cache.outputs.dir }} |
| 51 | + key: ${{ runner.os }}-composer-${{ matrix.prefer }}-${{ matrix.symfony-versions }}-${{ hashFiles('**/composer.json') }} |
| 52 | + restore-keys: ${{ runner.os }}-composer-${{ matrix.prefer }}-${{ matrix.symfony-versions }}- |
| 53 | + |
| 54 | + - name: Install dependencies |
| 55 | + run: | |
| 56 | + if [ -n "${{ matrix.symfony-bundle-test-version }}" ]; then |
| 57 | + composer require --dev --no-update "nyholm/symfony-bundle-test:${{ matrix.symfony-bundle-test-version }}" |
| 58 | + fi |
| 59 | + for symfony_package in $(jq -r '.require | keys[]' composer.json | grep '^symfony/'); do |
| 60 | + composer require --no-update "${symfony_package}:${{ matrix.symfony-versions }}" |
| 61 | + done |
| 62 | + composer --prefer-dist --${{ matrix.prefer }} update |
| 63 | +
|
| 64 | + - name: Setup problem matchers for PHPUnit |
| 65 | + run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" |
| 66 | + |
| 67 | + - name: Run PHPUnit |
| 68 | + run: ./vendor/bin/phpunit |
0 commit comments