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: PHP ${{ matrix.php }}

        strategy:
            fail-fast: false
            matrix:
                php: ["8.0", "8.1"]
                symfony: ["^5.4", "^6.0"]

        env:
            APP_ENV: test

        steps:
            -
                uses: actions/checkout@v2

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

            -   name: Restrict Symfony version
                if: matrix.symfony != ''
                run: |
                    composer global config --no-plugins allow-plugins.symfony/flex true
                    composer config extra.symfony.require "${{ matrix.symfony }}"

            -
                name: Install PHP dependencies
                run: composer install --no-interaction

            -
                name: Run PHPSpec
                run: vendor/bin/phpspec run --ansi -f progress --no-interaction

            -   name: Run PHPUnit
                run: vendor/bin/phpunit --colors=always

            -
                name: Run Behats
                run: vendor/bin/behat
