image: $CI_REGISTRY/backend/docker/images/php:8.1-deploy

stages:
  - build
  - test
  - deploy

cache:
    key: ${CI_COMMIT_REF_SLUG}
    paths:
        - vendor/

variables:
  DOCKER_DRIVER: overlay2

build:
  stage: build
  script:
    - composer install -n --prefer-dist -o --no-ansi --no-progress
  artifacts:
    expire_in: 30 min
    paths:
      - vendor/
      - app/config/parameters.yml

test:
  image: $CI_REGISTRY/backend/docker/images/php:8.1
  stage: test
  dependencies:
      - build
  before_script:
      - phpenmod pcov
  script:
      - SYMFONY_DEPRECATIONS_HELPER=disabled vendor/phpunit/phpunit/phpunit -d memory_limit=512M --coverage-text --colors=never --coverage-html coverage
  artifacts:
    paths:
      - coverage/

pages:
  stage: deploy
  dependencies:
      - test
  script:
      - mv coverage public
  artifacts:
    paths:
      - public/
    expire_in: 30 days
  only:
    - master
  variables:
    GIT_STRATEGY: none

image: $CI_REGISTRY/backend/docker/images/php:8.1-deploy

stages:
  - build
  - test
  - deploy

cache:
    key: ${CI_COMMIT_REF_SLUG}
    paths:
        - vendor/

variables:
  DOCKER_DRIVER: overlay2

build:
  stage: build
  script:
    - composer install -n --prefer-dist -o --no-ansi --no-progress
  artifacts:
    expire_in: 30 min
    paths:
      - vendor/
      - app/config/parameters.yml

test:
  image: $CI_REGISTRY/backend/docker/images/php:8.1
  stage: test
  dependencies:
      - build
  before_script:
      - phpenmod pcov
  script:
      - SYMFONY_DEPRECATIONS_HELPER=disabled vendor/phpunit/phpunit/phpunit -d memory_limit=512M --coverage-text --colors=never --coverage-html coverage
  coverage: '/^\s*Lines:\s*\d+.\d+\%/'
  artifacts:
    paths:
      - coverage/

pages:
  stage: deploy
  dependencies:
      - test
  script:
      - mv coverage public
  artifacts:
    paths:
      - public/
    expire_in: 30 days
  only:
    - master
  variables:
    GIT_STRATEGY: none

Set coverage in CI/CD config
Set coverage in CI/CD config
