name: Tests

on:
    push:
        branches: [ master ]
    pull_request:
        branches: [ master ]

    workflow_dispatch:

jobs:
    tests :
        runs-on: ubuntu-latest
        strategy:
            matrix:
                php:
                    - "7.4"
                    - "8.0"
                    - "8.1"
                dependency-mode:
                  - prefer-stable
                  - prefer-lowest
        steps:
            - name: Checkout
              uses: actions/checkout@v2

            - name: Install PHP with extensions
              uses: shivammathur/setup-php@v2
              with:
                  php-version: ${{ matrix.php }}
                  tools: composer:v2

            - name: Install dependencies
              run: composer install --ansi

            - name: Update  dependencies
              run: composer update --${{ matrix.dependency-mode }} --ansi

            - name: Run Twig linter
              run: ./vendor/bin/twigcs ./templates

            - name: Run code sniffer
              run: vendor/bin/phpcs -p --colors

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