.unit-test:
    image: ${REGISTRY_URL}/workspaces/${SERVICE_NAME}:${IMAGE_TAG}
    script:
        - ls -la
        - pip3 install --upgrade pip
        - pip3 install -r test-requirements.txt
        - cd ${PATH_PREFIX}${SERVICE_NAME}
        - python3 -m pytest ./test --cov=${SERVICE_NAME} --cov-report=html
    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]+/ || $CI_COMMIT_TAG =~ /[0-9]+\.[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]+$/ || $CI_COMMIT_TAG =~ /[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$/'
          variables:
            IMAGE_TAG: $CI_COMMIT_TAG
          changes:
            - ${PATH_PREFIX}${SERVICE_NAME}/**/*

    dependencies: []
