name: PHP Composer

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

jobs:
  build:
    runs-on: ${{ matrix.operating-system }}
    strategy:
      matrix:
        operating-system: [ ubuntu-18.04 ]
        php: [ '5.4', '5.5', '5.6', '7.1', '7.2', '7.3', '7.4' ]
    name: PHP ${{ matrix.operating-system }} ${{ matrix.php }}

    steps:
    - uses: actions/checkout@v2
    - uses: nanasess/setup-php@master
      with:
        php-version: ${{ matrix.php }}

    - name: Validate composer.json and composer.lock
      run: composer validate

    - name: Install dependencies
      run: composer install --prefer-dist --no-progress

    # Add a test script to composer.json, for instance: "test": "vendor/bin/phpunit"
    # Docs: https://getcomposer.org/doc/articles/scripts.md

    - name: Run test suite
      run: ./vendor/bin/phpunit
