stages:
  - build
  - test
  - debug
  - benchmark
  - publish

include:
  - project: 'kit/mpp/mpp'
    ref: feature
    file: 'pipeline/.mpp-ci-templates.yml'
  - local: 'pipeline/.cardmech-benchmark-on-horeka.yml'


variables:
  extends: .global-variables


build-cardmech:
  extends: .build_template
  variables:
    CMAKE_ARGS: '-DMPP_BUILD_TYPE=MppDebugFast -DBUILD_CARDIAC_TESTS=ON -DBUILD_TUTORIAL=OFF -DBUILD_TUTORIAL_TESTS=OFF'
    JOB_PRIORITY: 'frequently'


ctest-cardmech:
  extends: .test_template
  only:
    variables: [ $TRIGGER_ORIGIN == 'mpp_pipeline' ]
  dependencies:
    - build-cardmech
  script:
    - ctest --output-on-failure -E TestAssembleConsistency # Exclude TestAssembleConsistency

# The following job runs only if not triggered by mpp-pipeline (only by pushes to cardmech)
ctest-only-cardmech:
  extends: .test_template
  variables:
    JOB_PRIORITY: 'frequently'
  only:
    variables: [ $TRIGGER_ORIGIN != 'mpp_pipeline' && ($BENCHMARK == 'none') && ($RUN_PROJECTS == 'all') && ($JOB_PRIORITY == $PRIORITY || $JOB_PRIORITY == 'frequently') ]
  dependencies:
    - build-cardmech
  script:
    - ctest --output-on-failure

mpitest-cardmech:
  extends: .test_template
  variables:
    JOB_PRIORITY: 'frequently'
  dependencies:
    - build-cardmech
  script:  # Job may take max 10min to be frequently executed!!
    - python3 mppyrun.py --mpi_tests=1 --mute=0


ventricle-test:
  extends: .benchmark_on_horeka
  variables:
    CMAKE_ARGS: '-DMPP_BUILD_TYPE=MppRelease'
  script:
    - salloc -p cpuonly -t 00:10:00 -n 4 mpirun Elphy-M++ BiVentricleTest/start
