diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 5e16607cc..aa58f04f9 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,283 +1,287 @@ stages: - configure - build - check-warnings - test - deploy .docker_build: image: 'docker:19.03.11' stage: .pre services: - docker:19.03.11-dind variables: # Use TLS https://docs.gitlab.com/ee/ci/docker/using_docker_build.html#tls-enabled DOCKER_HOST: tcp://docker:2376 DOCKER_TLS_CERTDIR: "/certs" before_script: - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY script: - cd test/ci/${IMAGE_NAME}/ - docker build -t registry.gitlab.com/akantu/akantu/${IMAGE_NAME} . - docker push registry.gitlab.com/akantu/akantu/${IMAGE_NAME} docker build:debian-testing: variables: IMAGE_NAME: debian:testing extends: .docker_build rules: - changes: - test/ci/debian:testing/Dockerfile docker build:ubuntu-lts: variables: IMAGE_NAME: ubuntu:lts extends: .docker_build rules: - changes: - test/ci/ubuntu:lts/Dockerfile .configure: stage: configure except: - tags variables: BLA_VENDOR: 'Generic' script: - cmake -E make_directory build - cd build - cmake -DAKANTU_COHESIVE_ELEMENT:BOOL=TRUE -DAKANTU_IMPLICIT:BOOL=TRUE -DAKANTU_PARALLEL:BOOL=TRUE -DAKANTU_STRUCTURAL_MECHANICS:BOOL=TRUE -DAKANTU_HEAT_TRANSFER:BOOL=TRUE -DAKANTU_DAMAGE_NON_LOCAL:BOOL=TRUE -DAKANTU_PYTHON_INTERFACE:BOOL=TRUE -DAKANTU_EXAMPLES:BOOL=TRUE -DAKANTU_BUILD_ALL_EXAMPLES:BOOL=TRUE -DAKANTU_TEST_EXAMPLES:BOOL=FALSE -DAKANTU_TESTS:BOOL=TRUE -DAKANTU_RUN_IN_DOCKER:BOOL=TRUE - -DCMAKE_BUILD_TYPE:STRING=Debug .. + -DCMAKE_BUILD_TYPE:STRING=Coverage .. artifacts: when: on_success paths: - build expire_in: 10h .build: stage: build script: - cmake --build build/src > >(tee -a ${output}-out.log) 2> >(tee -a ${output}-err.log >&2) - cmake --build build/python > >(tee -a ${output}-out.log) 2> >(tee -a ${output}-err.log >&2) - cmake --build build/test/ > >(tee -a ${output}-out.log) 2> >(tee -a ${output}-err.log >&2) - cmake --build build/examples > >(tee -a ${output}-out.log) 2> >(tee -a ${output}-err.log >&2) artifacts: when: on_success paths: - build/ #- ${output}-out.log - ${output}-err.log expire_in: 10h .tests: stage: test script: - cd build - ctest -T test --no-compress-output --timeout 1800 after_script: - cd build - tag=$(head -n 1 < Testing/TAG) - if [ -e Testing/${tag}/Test.xml ]; then - xsltproc -o ./juint.xml ${CI_PROJECT_DIR}/test/ci/ctest2junit.xsl Testing/${tag}/Test.xml; - fi + - gcovr --xml -o coverage.xml --object-directory ./ --root ../ -s || true artifacts: when: always paths: - build/juint.xml + - build/coverage.xml reports: junit: - build/juint.xml + cobertura: + - build/coverage.xml .analyse_build: stage: check-warnings script: - if [[ $(cat ${output}-err.log | grep warning -i) ]]; then - cat ${output}-err.log; - exit 1; - fi allow_failure: true artifacts: when: on_failure paths: - "$output-err.log" # ------------------------------------------------------------------------------ .cache_build: variables: CCACHE_BASEDIRE: ${CI_PROJECT_DIR}/build CCACHE_DIR: ${CI_PROJECT_DIR}/.ccache CCACHE_NOHASHDIR: 1 CCACHE_COMPILERCHECK: content cache: key: ${output} policy: pull-push paths: - .ccache/ - third-party/google-test - third-party/pybind11 before_script: - ccache --zero-stats || true after_script: - ccache --show-stats || true # ------------------------------------------------------------------------------ .image_debian_testing: image: registry.gitlab.com/akantu/akantu/debian:testing .image_ubuntu_lts: image: registry.gitlab.com/akantu/akantu/ubuntu:lts # ------------------------------------------------------------------------------ .compiler_gcc: variables: CC: /usr/lib/ccache/gcc CXX: /usr/lib/ccache/g++ FC: gfortran .compiler_clang: variables: CC: /usr/lib/ccache/clang CXX: /usr/lib/ccache/clang++ FC: gfortran # ------------------------------------------------------------------------------ .debian_testing_gcc: variables: output: debian_testing_gcc extends: - .compiler_gcc - .image_debian_testing - .cache_build .debian_testing_clang: variables: output: debian_testing_clang extends: - .compiler_clang - .image_debian_testing - .cache_build .ubuntu_lts_gcc: variables: output: ubuntu_lts_gcc extends: - .compiler_gcc - .image_ubuntu_lts - .cache_build # ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------ configure:debian_testing_gcc: extends: - .debian_testing_gcc - .configure cache: policy: pull-push build:debian_testing_gcc: extends: - .debian_testing_gcc - .build dependencies: - configure:debian_testing_gcc test:debian_testing_gcc: extends: - .debian_testing_gcc - .tests dependencies: - build:debian_testing_gcc analyse_build:debian_testing_gcc: extends: - .debian_testing_gcc - .analyse_build dependencies: - build:debian_testing_gcc # ------------------------------------------------------------------------------ configure:debian_testing_clang: extends: - .debian_testing_clang - .configure cache: policy: pull-push build:debian_testing_clang: extends: - .debian_testing_clang - .build dependencies: - configure:debian_testing_clang test:debian_testing_clang: extends: - .debian_testing_clang - .tests dependencies: - build:debian_testing_clang analyse_build:debian_testing_clang: extends: - .debian_testing_clang - .analyse_build dependencies: - build:debian_testing_clang # ------------------------------------------------------------------------------ configure:ubuntu_lts_gcc: extends: - .ubuntu_lts_gcc - .configure cache: policy: pull-push build:ubuntu_lts_gcc: extends: - .ubuntu_lts_gcc - .build dependencies: - configure:ubuntu_lts_gcc analyse_build:ubuntu_lts_gcc: extends: - .ubuntu_lts_gcc - .analyse_build dependencies: - build:ubuntu_lts_gcc test:ubuntu_lts_gcc: extends: - .ubuntu_lts_gcc - .tests dependencies: - build:ubuntu_lts_gcc # ------------------------------------------------------------------------------ pages: stage: deploy extends: - .debian_testing_gcc script: - cd build - cmake -DAKANTU_DOCUMENTATION_DEVELOPER_MANUAL=ON .. - cmake --build . -t sphinx-doc - mv doc/dev-doc/html ../public dependencies: - build:debian_testing_gcc artifacts: paths: - public only: - features/doc diff --git a/cmake/AkantuExtraCompilationProfiles.cmake b/cmake/AkantuExtraCompilationProfiles.cmake index ec5d7e8e6..fd0fb5ae4 100644 --- a/cmake/AkantuExtraCompilationProfiles.cmake +++ b/cmake/AkantuExtraCompilationProfiles.cmake @@ -1,58 +1,87 @@ #Profiling -set(CMAKE_CXX_FLAGS_PROFILING "-g -ggdb3 -pg -DNDEBUG -DAKANTU_NDEBUG -O2" +set(_profiling "-g -ggdb3 -pg -DNDEBUG -DAKANTU_NDEBUG -O2") +set(CMAKE_CXX_FLAGS_PROFILING ${_profiling} CACHE STRING "Flags used by the compiler during profiling builds") -set(CMAKE_C_FLAGS_PROFILING "-g -ggdb3 -pg -DNDEBUG -DAKANTU_NDEBUG -O2" +set(CMAKE_C_FLAGS_PROFILING ${_profiling} CACHE STRING "Flags used by the compiler during profiling builds") -set(CMAKE_Fortran_FLAGS_PROFILING "-g -ggdb3 -pg -DNDEBUG -DAKANTU_NDEBUG -O2" +set(CMAKE_Fortran_FLAGS_PROFILING ${_profiling} CACHE STRING "Flags used by the compiler during profiling builds") set(CMAKE_EXE_LINKER_FLAGS_PROFILING "-pg" CACHE STRING "Flags used by the linker during profiling builds") set(CMAKE_SHARED_LINKER_FLAGS_PROFILING "-pg" CACHE STRING "Flags used by the linker during profiling builds") -mark_as_advanced(CMAKE_CXX_FLAGS_PROFILING CMAKE_C_FLAGS_PROFILING - CMAKE_Fortran_FLAGS_PROFILING CMAKE_EXE_LINKER_FLAGS_PROFILING - CMAKE_SHARED_LINKER_FLAGS_PROFILING) +mark_as_advanced( + CMAKE_CXX_FLAGS_PROFILING + CMAKE_C_FLAGS_PROFILING + CMAKE_Fortran_FLAGS_PROFILING + CMAKE_EXE_LINKER_FLAGS_PROFILING + CMAKE_SHARED_LINKER_FLAGS_PROFILING + ) + # Sanitize the code if ((CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER "5.2") OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang") set(_sanitize "-g -ggdb3 -O2 -fsanitize=address -fsanitize=leak -fsanitize=undefined -fno-omit-frame-pointer -fsanitize-blacklist=${PROJECT_SOURCE_DIR}/cmake/sanitize-blacklist.txt") set(CMAKE_CXX_FLAGS_SANITIZE ${_sanitize} CACHE STRING "Flags used by the compiler during sanitizing builds") set(CMAKE_C_FLAGS_SANITIZE ${_sanitize} CACHE STRING "Flags used by the compiler during sanitizing builds") set(CMAKE_Fortran_FLAGS_SANITIZE ${_sanitize} CACHE STRING "Flags used by the compiler during sanitizing builds") set(CMAKE_EXE_LINKER_FLAGS_SANITIZE ${_sanitize} CACHE STRING "Flags used by the linker during sanitizing builds") set(CMAKE_SHARED_LINKER_FLAGS_SANITIZE ${_sanitize} CACHE STRING "Flags used by the linker during sanitizing builds") - mark_as_advanced(CMAKE_SHARED_LINKER_FLAGS_SANITIZE - CMAKE_CXX_FLAGS_SANITIZE CMAKE_C_FLAGS_SANITIZE - CMAKE_Fortran_FLAGS_SANITIZE CMAKE_EXE_LINKER_FLAGS_SANITIZE + mark_as_advanced( + CMAKE_CXX_FLAGS_SANITIZE + CMAKE_C_FLAGS_SANITIZE + CMAKE_Fortran_FLAGS_SANITIZE + CMAKE_SHARED_LINKER_FLAGS_SANITIZE + CMAKE_EXE_LINKER_FLAGS_SANITIZE ) endif() if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") set(_sanitize "-g -ggdb3 -O2 -fPIE -fsanitize=memory -fsanitize-memory-track-origins -fsanitize-recover=all -fno-omit-frame-pointer -fsanitize-blacklist=${PROJECT_SOURCE_DIR}/cmake/sanitize-blacklist.txt") set(CMAKE_CXX_FLAGS_SANITIZEMEMORY ${_sanitize} CACHE STRING "Flags used by the compiler during sanitizing builds") set(CMAKE_C_FLAGS_SANITIZEMEMORY ${_sanitize} CACHE STRING "Flags used by the compiler during sanitizing builds") set(CMAKE_Fortran_FLAGS_SANITIZEMEMORY ${_sanitize} CACHE STRING "Flags used by the compiler during sanitizing builds") set(CMAKE_EXE_LINKER_FLAGS_SANITIZEMEMORY ${_sanitize} CACHE STRING "Flags used by the linker during sanitizing builds") set(CMAKE_SHARED_LINKER_FLAGS_SANITIZEMEMORY ${_sanitize} CACHE STRING "Flags used by the linker during sanitizing builds") - mark_as_advanced(CMAKE_SHARED_LINKER_FLAGS_SANITIZEMEMORY - CMAKE_CXX_FLAGS_SANITIZEMEMORY CMAKE_C_FLAGS_SANITIZEMEMORY - CMAKE_Fortran_FLAGS_SANITIZEMEMORY CMAKE_EXE_LINKER_FLAGS_SANITIZEMEMORY + mark_as_advanced( + CMAKE_CXX_FLAGS_SANITIZEMEMORY + CMAKE_C_FLAGS_SANITIZEMEMORY + CMAKE_Fortran_FLAGS_SANITIZEMEMORY + CMAKE_SHARED_LINKER_FLAGS_SANITIZEMEMORY + CMAKE_EXE_LINKER_FLAGS_SANITIZEMEMORY + ) +endif() + +find_program(GCOV_EXECUTABLE gcov) +if (GCOV_EXECUTABLE) + set(_coverage "-g -ggdb3 -DNDEBUG -DAKANTU_NDEBUG -O2 -fprofile-arcs -ftest-coverage") + set(CMAKE_CXX_FLAGS_COVERAGE ${_coverage} + CACHE STRING "Flags used by the compiler during profiling builds") + set(CMAKE_C_FLAGS_COVERAGE ${_coverage} + CACHE STRING "Flags used by the compiler during profiling builds") + set(CMAKE_Fortran_FLAGS_COVERAGE ${_coverage} + CACHE STRING "Flags used by the compiler during profiling builds") + + mark_as_advanced( + CMAKE_CXX_FLAGS_COVERAGE + CMAKE_C_FLAGS_COVERAGE + CMAKE_Fortran_FLAGS_COVERAGE ) endif() diff --git a/test/ci/debian:testing/Dockerfile b/test/ci/debian:testing/Dockerfile index f7638b35f..ba3923f1a 100644 --- a/test/ci/debian:testing/Dockerfile +++ b/test/ci/debian:testing/Dockerfile @@ -1,29 +1,30 @@ FROM debian:testing MAINTAINER Nicolas Richart # library dependencies RUN apt-get -qq update && apt-get -qq -y install \ g++ gfortran clang cmake \ openmpi-bin libmumps-dev libscotch-dev \ libboost-dev libopenblas-dev \ python3 python3-dev python3-numpy python3-scipy python3-mpi4py \ && rm -rf /var/lib/apt/lists/* # for documentation RUN apt-get -qq update && apt-get -qq -y install \ python3-sphinx python3-sphinx-rtd-theme python3-breathe doxygen graphviz \ && rm -rf /var/lib/apt/lists/* # for ci RUN apt-get -qq update && apt-get -qq -y install \ gmsh python3-pytest \ ccache clang-format python3-flake8 clang-tidy \ curl git xsltproc jq \ + gcovr binutils \ && rm -rf /var/lib/apt/lists/* COPY .openmpi /root/.openmpi # for debug RUN apt-get -qq update && apt-get -qq -y install \ gdb valgrind \ && rm -rf /var/lib/apt/lists/* diff --git a/test/ci/ubuntu:lts/Dockerfile b/test/ci/ubuntu:lts/Dockerfile index 8ff6d649d..b1a78720e 100644 --- a/test/ci/ubuntu:lts/Dockerfile +++ b/test/ci/ubuntu:lts/Dockerfile @@ -1,28 +1,29 @@ FROM ubuntu:xenial MAINTAINER Nicolas Richart ENV TZ=Europe/Zurich RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone # Install akantu dependencies RUN apt-get -qq update && apt-get -qq -y install \ g++ gfortran cmake \ openmpi-bin libmumps-dev libscotch-dev \ libboost-dev libopenblas-dev libcgal-dev \ python3 python3-dev python3-numpy python3-scipy python3-pip \ && rm -rf /var/lib/apt/lists/* RUN pip3 install mpi4py # Install test utilities RUN apt-get -qq update && apt-get -qq -y install \ python3-yaml python3-pytest ccache \ gmsh curl git xsltproc \ + gcovr binutils \ && rm -rf /var/lib/apt/lists/* COPY .openmpi /root/.openmpi # for debug RUN apt-get -qq update && apt-get -qq -y install \ gdb valgrind \ && rm -rf /var/lib/apt/lists/*