name: CI

on: [push]

jobs:
  build-test:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2

      - name: Setup PHP
        uses: shivammathur/setup-php@v2
        with:
          php-version: 8.1

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

      - name: Coding Style
        run: PHP_CS_FIXER_IGNORE_ENV=true composer src:lint

      - name: PHP Stan
        run: composer src:php-stan

      - name: PHPUnit Tests
        uses: php-actions/phpunit@v2
        with:
          php_version: 8.1
          php_extensions: xdebug
          bootstrap: tests/bootstrap.php
          configuration: phpunit.xml.dist
          args:  --coverage-text
      
      - name: Code climate Coverage
        uses: paambaati/codeclimate-action@v3.0.0
        env:
          CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
        with:
          debug: true
          coverageCommand: ./vendor/bin/phpunit --coverage-clover clover.xml 
          coverageLocations: clover.xml:clover

