name: Build

on:
    push: ~
    pull_request: ~
    release:
        types: [created]
    schedule:
        -
            cron: "0 1 * * 6" # Run at 1am every Saturday

jobs:
    tests:
        runs-on: ubuntu-latest
        name: Build and test
        strategy:
            fail-fast: false
            matrix:
                include:
                    -
                        php: 7.3
                        symfony-version: 4.4.*
                    -
                        php: 7.3
                        symfony-version: 5.1.*
                    -
                        php: 7.4
                        symfony-version: 4.4.*
                    -
                        php: 7.4
                        symfony-version: 5.1.*
                    -
                        php: 8.0
                        symfony-version: 4.4.*
                        composer-flags: "--ignore-platform-req=php"
                    -
                        php: 8.0
                        symfony-version: 5.1.*
                        composer-flags: "--ignore-platform-req=php"

        steps:
            -
                uses: actions/checkout@v2

            -
                name: Setup PHP
                uses: shivammathur/setup-php@v2
                with:
                    php-version: "${{ matrix.php }}"
                    coverage: none

            -
                name: Update Symfony version
                if: matrix.symfony-version != ''
                run: composer require --no-update --no-scripts "symfony/framework-bundle:${{ matrix.symfony-version }}" "symfony/monolog-bridge:${{ matrix.symfony-version }}"

            -
                name: Install dependencies
                run: composer update ${{ matrix.composer-flags }}

            -
                name: Run analysis
                run: composer analyse

            -
                name: Run tests
                run: composer test
