image: gitlab-registry.in2p3.fr/cta-lapp/cours/tests/testgitlabci/base_ubuntu_ci:0.1

stages:
- BuildTestinstall
- DocCoverage
- deploy

dailyBuildMasterAll:

    stage: BuildTestinstall

    script:
    - export LD_LIBRARY_PATH=/usr/lib
    - env
    - mkdir -p build
    - cd build
    - >
        cmake ..
        -DCMAKE_INSTALL_PREFIX=/usr
        -DSELF_TESTS_MODE=yes
    - make all
    - make install
    - make test

    only:
    - branches
    - tags
    tags:

TestCoverage:

    stage: DocCoverage

    script:

    - export LD_LIBRARY_PATH=/usr/lib
    - env
    - mkdir -p build coverage
    - cd build
    - >
        cmake ..
        -DCMAKE_INSTALL_PREFIX=/usr
        -DSELF_TESTS_MODE=yes
        -DCMAKE_BUILD_TYPE=Coverage
    - make all
    - make install
    - make test

    - cd ../coverage
    - gcovr -r ../ --exclude-throw-branches --html cov_report.html --html-details
    - gcovr -r ../ --exclude-throw-branches --xml Coverage.xml
    - gcovr -r ../ --exclude-throw-branches

    artifacts:
        paths:
        - coverage
        expire_in: 1d

    only:
    - branches
    - tags
    tags:

Doc:
    stage: DocCoverage

    script:
    - export LD_LIBRARY_PATH=/usr/lib
    - env
    - rm -fr build public
    - mkdir -p build
    - mkdir -p public
    - cd build
    - >
        cmake ..
        -DCMAKE_INSTALL_PREFIX=/usr
        -DDOC_MODE=yes
    - make all

    - make doc

    - scp -r doc/html/* ../public

    artifacts:
      paths:
      - public
      expire_in: 1d

    only:
    - branches
    - tags
    tags:

pages:
  stage: deploy

  script:
    - mv coverage public/

  artifacts:
    paths:
      - public
    expire_in: 1d

