name: Test PHP
on:
  push:
    branches:
      - '**'
      - '!stable'
      - '!stage'

env:
  php_version: 7.1
  phpunit_version: 4
  composer_version: 1

jobs:
  release:
    name: Test
    if: |
      !(github.event_name == 'push' && contains(github.event.head_commit.message, '[skip ci]')) &&
      !(github.event_name == 'pull_request' && contains(join(github.event.pull_request.title, github.event.pull_request.body), '[skip ci]'))
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2

      - uses: php-actions/composer@v6
        with:
          version: ${{ env.composer_version }}
          php_version: ${{ env.php_version }}

      - name: Run PHPUnit
        uses: php-actions/phpunit@v3
        with:
          version: ${{ env.phpunit_version }}
          php_version: ${{ env.php_version }}

      - name: Run PHPCS
        run: php vendor/bin/phpcs --standard=PSR2 src/
