image: rikorose/gcc-cmake

stages:
  - build
  - test

before_script:
  - g++ --version

build:
  stage: build
  script:
    - cmake . -DCMAKE_CXX_FLAGS="-Werror"
    - make -j4
    - make clean
    - cmake . -DCMAKE_CXX_FLAGS="-Wall -Wextra" # 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:
    - bash -x 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:
    - bash -x ci/vera.sh

clang-tidy:
  stage: build
  before_script:
    - apt-get update -qq && apt-get install -y -qq clang-tidy-4.0
    - clang-tidy-4.0 --version
  script:
    - bash -x ci/clang-tidy.sh
