.unit-test:
    # Postgres DB service
    services:
      - name: ${BASE_REGISTRY_URL}/db:workspaces
        alias: db
    image: ${BASE_REGISTRY_URL}/${SERVICE_NAME}:${IMAGE_TAG}
    script:
        - pip3 install pytest pytest-cov
        - pytest test --cov=${SERVICE_NAME} --cov-report=html
        - mv htmlcov ${CI_PROJECT_DIR}/${SERVICE_NAME}.htmlcov
    artifacts:
        paths:
            - .coverage.${SERVICE_NAME}.${CI_COMMIT_SHORT_SHA}
    rules:
        - if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH || $CI_COMMIT_BRANCH =~ /(^[0-9]\.[0-9]|^[0-9]\.[0-9]\.[0-9])-DEVELOPMENT/'
          variables:
            IMAGE_TAG: $CI_COMMIT_BRANCH
          changes:
            - ${PATH_PREFIX}${SERVICE_NAME}/**/*
        - if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
          variables:
            IMAGE_TAG: $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME
          changes:
            - ${PATH_PREFIX}${SERVICE_NAME}/**/*
        - if: '$CI_COMMIT_TAG =~ /^end-of-sprint-[0-9]+/ || $CI_COMMIT_TAG =~ /[0-9]+\.[0-9]+\.[0-9]+-rc[0-9]+/'
          variables:
            IMAGE_TAG: $CI_COMMIT_TAG
          changes:
            - ${PATH_PREFIX}${SERVICE_NAME}/**/*
        - if: '$CI_COMMIT_TAG =~ /[0-9]+\.[0-9]+\.[0-9]+$/'
          variables:
            IMAGE_TAG: $CI_COMMIT_TAG
          changes:
            - ${PATH_PREFIX}${SERVICE_NAME}/**/*

    dependencies: []
