stages:
  - test

variables:
  APP_ENV: ci
  SSH_PRIVATE_KEY: $SSH_PRIVATE_KEY
  XDEBUG_MODE: coverage

cache:
  paths:
    - ./vendor

before_script:
  - bash tests/ci_docker_install.sh > /dev/null
  - php -v

static_analysis:
  script:
    - php --version
    - php -d memory_limit=512M vendor/bin/phpstan analyse -c phpstan.neon.dist --error-format gitlab > phpstan.json  # Display code quality in MR
    - php -d memory_limit=512M vendor/bin/phpstan analyse -c phpstan.neon.dist  # Display in console
  artifacts:
    when: always
    reports:
      codequality: phpstan.json

unit:
  stage: test

  script:
    - php vendor/phpunit/phpunit/phpunit --configuration phpunit.xml.dist --colors=never --no-interaction --testsuite=unit
    #- php vendor/phpunit/phpunit/phpunit --configuration phpunit.xml.dist --colors=never --no-interaction --no-coverage --testsuite=application

  artifacts:
    paths:
      - ./coverage/
    when: always
    reports:
      junit: ./coverage/junit-report.xml

  coverage: '/^\s*Lines:\s*\d+.\d+\%/'

