# automatically generated by auxilium
image: {% if aux.ci.use_adaux_img == True %}{{ aux.versions.ci_adaux_image }}{% else %}{{ aux.versions.ci_docker_image }}{% endif %}
{% if aux.ci.runner == "normal" -%}
services:
-   name: docker:dind
{%- endif %}

stages:
{% if aux.ci.mechanism == "monolith" -%}
-   mono
{% if "docs" not in aux.meta.disabled -%}
-   deploy
{%- endif %}
{%- endif %}

variables:
    ROOT: $CI_BUILDS_DIR/root
    DOCKER_DIR: devops/docker
    GIT_DEPTH: 2
    GIT_CLONE_PATH: $CI_BUILDS_DIR/root
    PROJECT_REGISTRY: $CI_REGISTRY/$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME

workflow:
    rules:
    -   if: $CI_PIPELINE_SOURCE == "push"
    -   if: $CI_PIPELINE_SOURCE == "merge_request_event"
    -   if: $CI_PIPELINE_SOURCE == "web"
    -   if: $CI_PIPELINE_SOURCE == "pipeline"
    -   if: $CI_PIPELINE_SOURCE == "schedule"

before_script:
-   echo -e "\e[0Ksection_start:`date +%s`:before_script[collapsed=true]\r\e[0Kbefore_script"
-   docker login -u $CI_REGISTRY_USER -p $CI_JOB_TOKEN $CI_REGISTRY
-   'echo CI_PIPELINE_SOURCE: $CI_PIPELINE_SOURCE'
{%- if aux.ci.mechanism in ["monolith"] %}
{%- if aux.ci.use_adaux_img == False %}
-   apk add python3-dev py3-pip libc-dev gcc git
-   pip3 install wheel
-   pip3 install {% if aux.project.slug == "adaux" %}-e "$GIT_CLONE_PATH" --config-settings editable_mode=strict{% else %}{{ aux.versions.adaux }}{% endif %} > /dev/null
{%- endif %}
{%- endif %}
-   echo -e "\e[0Ksection_end:`date +%s`:before_script\r\e[0K"

{% if aux.ci.mechanism == "monolith" -%}
include:
-   local: devops/CI/01-rules.yml

monolith:
    stage: mono
    rules:
    {% for rule in aux.ci.used_rules -%}
    -   !reference [.r-{{ rule }}]
    {% endfor -%}
    -   when: never
    script:
    -   adaux ci gitlab
    allow_failure:
        exit_codes:
        -   42  # draft mr exit
{% include 'coverage.jinja2' %}
{% include 'tags.jinja2' %}
{%- if "docs" not in aux.meta.disabled %}
    artifacts:
        paths:
        -   devops/cache/docs/html
pages:
    rules:
    -   !reference [.r-release-push]
    -   when: never
    stage: deploy
    script:
    -   mkdir -p public
    -   cp -r devops/cache/docs/html/* public/
{% include 'tags.jinja2' %}
    artifacts:
        paths:
        -   public
    dependencies:
    -   monolith
{%- endif -%}
{%- endif %}
