image: lycantropos/cmake

stages:
  - build
  - test

before_script:
  - g++ --version
  - cat /etc/*-release

build:
  stage: build
  variables:
      GIT_SUBMODULE_STRATEGY: normal
      GCC_COLORS: "error=31;1:warning=35;1:note=36;1:range1=32:range2=34:locus=39;1:quote=39;1:fixit-insert=32:fixit-delete=31:diff-filename=39;1:diff-hunk=32:diff-delete=31:diff-insert=32:type-diff=32;1"
      CLICOLOR_FORCE: 1
  script:
    - cmake . -DCMAKE_CXX_FLAGS="-Werror -fdiagnostics-color=always"
    - make -j4
    - make clean
    - cmake . -DCMAKE_CXX_FLAGS="-Wall -Wextra -fdiagnostics-color=always" # Build again, but with more warnings
    - make -j4

tests:
  stage: test
  variables:
    GIT_SUBMODULE_STRATEGY: normal
  script:
    - cmake .
    - make tests -j4
    - ./tests --use-colour yes
  after_script:
    - ./tests -r junit -o junit.xml
  artifacts:
    reports:
      junit: junit.xml

cppcheck:
  stage: build
  before_script:
    - apt-get update -qq && apt-get install -y -qq cppcheck
    - cppcheck --version
  script:
    - ci/cppcheck.sh

vera:
  stage: build
  before_script:
    - apt-get update -qq && apt-get install -y -qq vera++
    - vera++ --version
    - cp ci/vera.profile /usr/lib/vera++/profiles/custom
  script:
    - ci/vera.sh

clang-tidy:
  stage: build
  variables:
    GIT_SUBMODULE_STRATEGY: normal
    TERM: xterm-color
  before_script:
    - echo deb http://deb.debian.org/debian sid main > /etc/apt/sources.list
    - apt-get update -qq && apt-get -t sid install -y -qq clang-tidy-7
    - clang-tidy-7 --version
  script:
    - script -c "bash -x ci/clang-tidy.sh"
