name: Build

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

jobs:
    tests:
        runs-on: ubuntu-18.04
        name: "PHP ${{ matrix.php }}, Symfony ${{ matrix.symfony }}"
        strategy:
            fail-fast: false
            matrix:
                php: [7.3, 7.4, 8.0]
                symfony: [^4.4, ^5.2]

        steps:
            -
                uses: actions/checkout@v2

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

            -
                name: Restrict Symfony version
                run: |
                    composer global require --no-progress --no-scripts --no-plugins "symfony/flex:^1.10"
                    composer config extra.symfony.require "${{ matrix.symfony }}"

            -
                name: Install dependencies
                run: composer update --no-scripts

            -
                name: Run analysis
                run: composer analyse

            -
                name: Run tests
                run: composer test
