variables:
  DEBUG: 'TRUE'
  SOURCE_FOLDER: "."
  COMPILATION_FIXUP: "cmake -DBBF_VENDOR_PREFIX=\\\"X_IOPSYS_EU_\\\" -DBBF_MAX_OBJECT_INSTANCES=255 -DBBFDMD_MAX_MSG_LEN=1048576 -DCMAKE_INSTALL_PREFIX=/"
  CPPCHECK_OPTIONS: "--suppress=cert-MSC24-C -DBBF_VENDOR_PREFIX=X_IOPSYS_EU_"
  CPD_OPTIONS: "--exclude ./build/ --minimum-tokens 200"

include:
  - project: 'iopsys/gitlab-ci-pipeline'
    file: '/static-code-analysis.yml'
    ref: '1.2'
  - project: 'docs/portal2/pipeline-template'
    file: 'MkDocs.gitlab-ci.yml'
    rules:
       - if: $CI_COMMIT_BRANCH == "devel"

stages:
    - static_code_analysis
    - unit_test
    - functional_test
    - deploy

run_unit_test:
  stage: unit_test
  image: ${COMMON_IMAGE}
  allow_failure: false
  script:
  - "./gitlab-ci/pipeline_setup.sh"
  - "./gitlab-ci/install-dependencies.sh ms"
  - "./gitlab-ci/setup.sh ms"
  - "./gitlab-ci/unit-test.sh"

  artifacts:
    when: always
    paths:
      - unit-test-coverage.xml

run_tools_test:
  stage: unit_test
  image: ${COMMON_IMAGE}
  allow_failure: false
  script:
  - |
      echo "
      machine dev.iopsys.eu
      login gitlab-ci-token
      password $CI_JOB_TOKEN
      " > ~/.netrc
  - "./gitlab-ci/pipeline_setup.sh"
  - "./gitlab-ci/setup.sh ms"
  - "./gitlab-ci/tools-test.sh"
  - "./gitlab-ci/generate_supported_dm.sh"

  artifacts:
      when: always
      paths:
          - out/datamodel_default.xml
          - out/datamodel_hdm.xml
          - out/datamodel.xls

run_libbbfdm_api_functional_test:
  stage: functional_test
  image: ${COMMON_IMAGE}
  allow_failure: false
  script:
  - "./gitlab-ci/pipeline_setup.sh"
  - "./gitlab-ci/install-dependencies.sh ms"
  - "./gitlab-ci/setup.sh ms"
  - "./gitlab-ci/functional-api-test.sh"

  artifacts:
      when: always
      paths:
          - functional-api-test-coverage.xml

run_libbbfdm_functional_test:
  stage: functional_test
  image: ${COMMON_IMAGE}
  allow_failure: false
  script:
  - "./gitlab-ci/pipeline_setup.sh"
  - "./gitlab-ci/install-dependencies.sh ms"
  - "./gitlab-ci/setup.sh ms"
  - "./gitlab-ci/functional-test.sh"

  artifacts:
      when: always
      paths:
          - functional-test-coverage.xml

run_libbbfdm_memory_test:
  stage: functional_test
  image: ${COMMON_IMAGE}
  allow_failure: false
  script:
  - "./gitlab-ci/pipeline_setup.sh"
  - "./gitlab-ci/install-dependencies.sh ms"
  - "./gitlab-ci/setup.sh ms"
  - "./gitlab-ci/memory-test.sh"
  artifacts:
      when: always
      paths:
          - output-report-device-get.txt
          - memory-*.xml

run_bbfd_functional_test:
    stage: functional_test
    image: ${COMMON_IMAGE}
    allow_failure: false
    script:
    - "./gitlab-ci/pipeline_setup.sh"
    - "./gitlab-ci/install-dependencies.sh ms"
    - "./gitlab-ci/setup.sh ms"
    - "./gitlab-ci/bbfdmd-functional-test.sh"
    artifacts:
        when: always
        reports:
            junit: ./report/*.xml
        paths:
            - funl-result.log
            - funl-test-coverage.xml
            - report/
            - memory-*.xml
