variables:
  ROOT_URL: https://$GITLAB_TOKEN_NAME:$GITLAB_TOKEN@gitlab.pleiade.edf.fr/codeaster
  PREREQ_VERSION: 20240327
  IMAGE_URL: nexus.retd.edf.fr:5075/codeaster-prerequisites:${PREREQ_VERSION}-debian-11
  REFREV: ${CI_MERGE_REQUEST_TARGET_BRANCH_NAME}
  GIT_SSL_NO_VERIFY: "true"
  NPROC_MAX: 4
  FF_DISABLE_UMASK_FOR_DOCKER_EXECUTOR: "true"

default:
  tags:
    - docker-executor

workflow:
  rules:
    - if: $CI_MERGE_REQUEST_IID
    #   seems redudant using fast-forward merges
  auto_cancel:
    on_new_commit: interruptible

stages:
  - setup
  - test

image:
  name: ${IMAGE_URL}

prepare:
  interruptible: true
  stage: setup
  script:
    - .gitlabci/prepare.sh

unittests:
  interruptible: true
  stage: test
  needs: ["prepare"]
  script:
    - .gitlabci/test.sh --output-junit run_testcases.xml
  artifacts:
    when: always
    paths:
      - share/test/run_testcases.xml
      - share/test/Testing/Temporary/*
    expire_in: 3 days
    reports:
      junit: share/test/run_testcases.xml

auto_install:
  interruptible: true
  stage: test
  needs: ["prepare", "unittests"]
  script:
    - .gitlabci/test_auto_install.sh

sonarqube:
  interruptible: true
  stage: test
  image:
    name: nexus.retd.edf.fr:5012/sonarsource/sonar-scanner-cli:latest
    entrypoint: ["/bin/sh", "-c"]
  script:
    - sonar-scanner
        -Dsonar.projectBaseDir=.
        -Dsonar.sources=.
        -Dsonar.projectKey="gitlab-${CI_PROJECT_ID}"
        -Dsonar.projectName="${CI_PROJECT_PATH_SLUG}"
        -Dsonar.host.url="${SQ_SERVER}"
        -Dsonar.login="${SQ_TOKEN}"
  variables:
    SQ_SERVER: "https://sonar.pleiade.edf.fr:443"
  allow_failure: true
  # only:
  #   - main
