version: "3.9"

services:
  lint:
    image: composer:2.1
    volumes:
      - ./:/app
    working_dir: /app
    command: >
      sh -c "rm -f ./composer.lock &&
             composer validate &&
             composer install &&
             php ./vendor/bin/phpcbf &&
             php ./vendor/bin/phpcs"

  tests:
    image: composer:2.1
    volumes:
      - ./:/app
    working_dir: /app
    command: >
      sh -c "rm -f ./composer.lock &&
             composer validate &&
             composer install &&
             php ./vendor/bin/phpstan analyse --ansi --debug --memory-limit 512M &&
             php ./vendor/bin/phpunit --stop-on-failure --testsuite=unit"

  tests-failing:
    image: composer:2.1
    volumes:
      - ./:/app
    working_dir: /app
    command: >
      sh -c "rm -f ./composer.lock &&
              composer validate &&
              composer install &&
              php ./vendor/bin/phpunit --stop-on-failure --testsuite=unit --group failing"
