image: irmb/virtualfluids-deps:latest

stages:
  - build
  - test
  - deploy

build:
  stage: build

  artifacts:
    paths:
      - build/

  before_script:
    - export DEBIAN_FRONTEND=noninteractive
    - apt-get update

  script:
    - cmake -S . -B build -DBUILD_VF_CPU:BOOL=ON -DBUILD_VF_UNIT_TESTS:BOOL=ON
    - cmake --build build --target VirtualFluidsCore
    - cmake --build build --target basicsTests


test:
  stage: test

  before_script:
    - export DEBIAN_FRONTEND=noninteractive

  script:
    - build/bin/basicsTests



benchmark_ClangBuildAnalyzer:
  stage: deploy

  rules:
    - when: manual

  before_script:
    - export DEBIAN_FRONTEND=noninteractive
    - apt-get update
    - cmake --version
    - mpirun --version
    - export CC=clang
    - export CXX=clang++
    - $CXX --version
    - cd /tmp
    - git clone https://github.com/aras-p/ClangBuildAnalyzer.git
    - cd ClangBuildAnalyzer
    - cmake .
    - make
    - export PATH+=:$(pwd)

  script:
    - cd $CI_PROJECT_DIR/build
    - rm -r ./*
    - cmake .. -DBUILD_VF_CPU=ON -DUSE_OPENMP=OFF -DCMAKE_CXX_FLAGS=-ftime-trace
    - ClangBuildAnalyzer --start .
    - make
    - ClangBuildAnalyzer --stop . CBA
    - ClangBuildAnalyzer --analyze CBA


benchmark_Include_what_you_use:
  stage: deploy

  before_script:
    - export DEBIAN_FRONTEND=noninteractive
    - apt-get update
    - cd /tmp
    - git clone https://github.com/include-what-you-use/include-what-you-use.git
    - cd include-what-you-use
    - git checkout clang_10
    - cmake . -DCMAKE_PREFIX_PATH=/usr/lib/llvm-10
    - make
    - export PATH+=:$(pwd)/bin

  script:
    - cd $CI_PROJECT_DIR/build
    - rm -r ./*
    - cmake .. -DBUILD_VF_CPU=ON -DUSE_OPENMP=OFF -DBUILD_VF_INCLUDE_WHAT_YOU_USE=ON
    - make


benchmark_cppcheck:
  stage: deploy

  before_script:
    - export DEBIAN_FRONTEND=noninteractive
    - apt-get update
    - apt-get install -y cppcheck

  script:
    - cd $CI_PROJECT_DIR
    - cppcheck --version
    - cppcheck src --enable=all --xml 2> report.xml
    - cppcheck-htmlreport --file=report.xml --report-dir=html_report --source-dir=.

