diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d28d6c1cc5d273a666ddd17e2f3e35da11040df1..fc669c4c91bf1439dc42ac91e1b4a9e8ad30c17b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,29 +1,15 @@ -image: localhost:5000/ubuntu_gcc - -cache: - key: "$CI_COMMIT_REF_SLUG" - paths: - - build/ - untracked: true - stages: - build - test - deploy -build:coverage: - stage: build - script: - - mkdir -p build - - cd build - - CXX=g++-7 CC=gcc-7 cmake .. -DCMAKE_BUILD_TYPE=Coverage - - make pugs +variables: + CTEST_OUTPUT_ON_FAILURE: 1 -test:coverage: - stage: test - dependencies: - - build:coverage - script: - - cd build - - make run_unit_tests - - make coverage +include: + - local: '/.gitlab-ci/gcc8-seq-dbg.yml' + - local: '/.gitlab-ci/gcc8-seq-release.yml' + - local: '/.gitlab-ci/clang8-seq-coverage.yml' + - local: '/.gitlab-ci/clang8-seq-release.yml' + - local: '/.gitlab-ci/clang8-mpi-coverage.yml' + - local: '/.gitlab-ci/clang8-mpi-release.yml' diff --git a/.gitlab-ci/clang8-mpi-coverage.yml b/.gitlab-ci/clang8-mpi-coverage.yml new file mode 100644 index 0000000000000000000000000000000000000000..a299e04833f750c47c0d8f9c980fb1d49a5656f8 --- /dev/null +++ b/.gitlab-ci/clang8-mpi-coverage.yml @@ -0,0 +1,27 @@ +build:clang8-mpi-coverage: + image: localhost:5000/ubuntu_clang8_mpi + stage: build + script: + - mkdir -p build/clang8-cov-mpi + - cd build/clang8-cov-mpi + - CXX=clang++-8 CC=clang-8 cmake ../.. -DCMAKE_BUILD_TYPE=Coverage -DCLANG_FORMAT=/usr/bin/clang-format-8 + - make pugs + cache: + key: "${CI_COMMIT_REF_SLUG}-clang8-cov-mpi" + paths: + - build/clang8-cov-mpi + untracked: true + +test:clang8-mpi-coverage: + image: localhost:5000/ubuntu_clang8_mpi + stage: test + dependencies: + - build:clang8-mpi-coverage + script: + - cd build/clang8-cov-mpi + - make coverage + cache: + key: "${CI_COMMIT_REF_SLUG}-clang8-cov-mpi" + paths: + - build/clang8-cov-mpi + untracked: true diff --git a/.gitlab-ci/clang8-mpi-release.yml b/.gitlab-ci/clang8-mpi-release.yml new file mode 100644 index 0000000000000000000000000000000000000000..1191266ac605a861c5420c5f5404c7c985fca615 --- /dev/null +++ b/.gitlab-ci/clang8-mpi-release.yml @@ -0,0 +1,27 @@ +build:clang8-mpi-release: + image: localhost:5000/ubuntu_clang8_mpi + stage: build + script: + - mkdir -p build/clang8-release-mpi + - cd build/clang8-release-mpi + - CXX=clang++-8 CC=clang-8 cmake ../.. -DCMAKE_BUILD_TYPE=Release -DCLANG_FORMAT=/usr/bin/clang-format-8 + - make pugs + cache: + key: "${CI_COMMIT_REF_SLUG}-clang8-release-mpi" + paths: + - build/clang8-release-mpi + untracked: true + +test:clang8-mpi-release: + image: localhost:5000/ubuntu_clang8_mpi + stage: test + dependencies: + - build:clang8-mpi-release + script: + - cd build/clang8-release-mpi + - make run_unit_tests + cache: + key: "${CI_COMMIT_REF_SLUG}-clang8-release-mpi" + paths: + - build/clang8-release-mpi + untracked: true diff --git a/.gitlab-ci/clang8-seq-coverage.yml b/.gitlab-ci/clang8-seq-coverage.yml new file mode 100644 index 0000000000000000000000000000000000000000..a79f27cb4802e51d87fbba2516db9225a2b4cf27 --- /dev/null +++ b/.gitlab-ci/clang8-seq-coverage.yml @@ -0,0 +1,27 @@ +build:clang8-seq-coverage: + image: localhost:5000/ubuntu_clang8 + stage: build + script: + - mkdir -p build/clang8-cov + - cd build/clang8-cov + - CXX=clang++-8 CC=clang-8 cmake ../.. -DCMAKE_BUILD_TYPE=Coverage -DCLANG_FORMAT=/usr/bin/clang-format-8 + - make pugs + cache: + key: "${CI_COMMIT_REF_SLUG}-clang8-cov" + paths: + - build/clang8-cov + untracked: true + +test:clang8-seq-coverage: + image: localhost:5000/ubuntu_clang8 + stage: test + dependencies: + - build:clang8-seq-coverage + script: + - cd build/clang8-cov + - make coverage + cache: + key: "${CI_COMMIT_REF_SLUG}-clang8-cov" + paths: + - build/clang8-cov + untracked: true diff --git a/.gitlab-ci/clang8-seq-release.yml b/.gitlab-ci/clang8-seq-release.yml new file mode 100644 index 0000000000000000000000000000000000000000..c12c0566457487edbc574efaa67e4ab506ea458b --- /dev/null +++ b/.gitlab-ci/clang8-seq-release.yml @@ -0,0 +1,27 @@ +build:clang8-seq-release: + image: localhost:5000/ubuntu_clang8 + stage: build + script: + - mkdir -p build/clang8-release-seq + - cd build/clang8-release-seq + - CXX=clang++-8 CC=clang-8 cmake ../.. -DCMAKE_BUILD_TYPE=Release -DCLANG_FORMAT=/usr/bin/clang-format-8 + - make pugs + cache: + key: "${CI_COMMIT_REF_SLUG}-clang8-release-seq" + paths: + - build/clang8-release-seq + untracked: true + +test:clang8-seq-release: + image: localhost:5000/ubuntu_clang8 + stage: test + dependencies: + - build:clang8-seq-release + script: + - cd build/clang8-release-seq + - make run_unit_tests + cache: + key: "${CI_COMMIT_REF_SLUG}-clang8-release-seq" + paths: + - build/clang8-release-seq + untracked: true diff --git a/.gitlab-ci/gcc8-seq-dbg.yml b/.gitlab-ci/gcc8-seq-dbg.yml new file mode 100644 index 0000000000000000000000000000000000000000..fb3f5d03f3e39955c7d07a20467276d1562878e0 --- /dev/null +++ b/.gitlab-ci/gcc8-seq-dbg.yml @@ -0,0 +1,27 @@ +build:gcc8-seq-dbg: + image: localhost:5000/ubuntu_gcc8 + stage: build + script: + - mkdir -p build/gcc8-seq-dbg + - cd build/gcc8-seq-dbg + - CXX=g++-8 CC=gcc-8 cmake ../.. -DCMAKE_BUILD_TYPE=Debug + - make pugs + cache: + key: "${CI_COMMIT_REF_SLUG}-gcc8-seq-dbg" + paths: + - build/gcc8-seq-dbg + untracked: true + +test:gcc8-seq-dbg: + image: localhost:5000/ubuntu_gcc8 + stage: test + dependencies: + - build:gcc8-seq-dbg + script: + - cd build/gcc8-seq-dbg + - make run_unit_tests + cache: + key: "${CI_COMMIT_REF_SLUG}-gcc8-seq-dbg" + paths: + - build/gcc8-seq-dbg + untracked: true diff --git a/.gitlab-ci/gcc8-seq-release.yml b/.gitlab-ci/gcc8-seq-release.yml new file mode 100644 index 0000000000000000000000000000000000000000..eecb64a126e257bd658001d99b790947d892b14a --- /dev/null +++ b/.gitlab-ci/gcc8-seq-release.yml @@ -0,0 +1,27 @@ +build:gcc8-seq-release: + image: localhost:5000/ubuntu_gcc8 + stage: build + script: + - mkdir -p build/gcc8-seq-release + - cd build/gcc8-seq-release + - CXX=g++-8 CC=gcc-8 cmake ../.. -DCMAKE_BUILD_TYPE=Release + - make pugs + cache: + key: "${CI_COMMIT_REF_SLUG}-gcc8-seq-release" + paths: + - build/gcc8-seq-release + untracked: true + +test:gcc8-seq-release: + image: localhost:5000/ubuntu_gcc8 + stage: test + dependencies: + - build:gcc8-seq-release + script: + - cd build/gcc8-seq-release + - make run_unit_tests + cache: + key: "${CI_COMMIT_REF_SLUG}-gcc8-seq-release" + paths: + - build/gcc8-seq-release + untracked: true diff --git a/CMakeLists.txt b/CMakeLists.txt index d10115dc440e1e60b79ffe645f2d86e7eeecee39..50864fccb06527f527726dec31544d798550c120 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -219,6 +219,12 @@ add_subdirectory("${CATCH_MODULE_PATH}") add_subdirectory(tests) enable_testing() +add_custom_target(run_unit_tests + COMMAND ${CMAKE_CTEST_COMMAND} -j ${PROCESSOR_COUNT} + DEPENDS unit_tests mpi_unit_tests + COMMENT "Executing unit tests." + ) + # unit tests coverage if("${CMAKE_BUILD_TYPE}" STREQUAL "Coverage") @@ -244,17 +250,10 @@ if("${CMAKE_BUILD_TYPE}" STREQUAL "Coverage") set(GCOVR_OPTIONS --object-directory="${PUGS_BINARY_DIR}" -r "${PUGS_SOURCE_DIR}/src" ${GCOVR_EXCLUDE} ${GCOVR_EXTRA}) - add_custom_target(run_unit_tests - ALL - COMMAND ${CMAKE_CTEST_COMMAND} -j ${PROCESSOR_COUNT} - DEPENDS unit_tests mpi_unit_tests pugs - COMMENT "Executing unit tests." - ) - add_custom_target(coverage ALL COMMAND ${GCOVR} ${GCOVR_OPTIONS} --exclude-unreachable-branches --sort-percentage - DEPENDS run_unit_tests + DEPENDS run_unit_tests pugs COMMENT "Running gcovr to build coverage report." ) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 24a4f19727721613a4bca0c70744c29b4523fc54..4eef6c18771aa6768877e9b24a3afe8e91296911 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -40,7 +40,11 @@ enable_testing() ParseAndAddCatchTests(unit_tests) if(${PUGS_HAS_MPI}) -set(OptionalCatchTestLauncher ${MPIEXEC} ${MPIEXEC_NUMPROC_FLAG} 3 --oversubscribe --path ${PUGS_BINARY_DIR}) + set(MPIEXEC_OPTION_FLAGS --oversubscribe) + if (NOT "$ENV{GITLAB_CI}" STREQUAL "") + set(MPIEXEC_OPTION_FLAGS ${MPIEXEC_OPTION_FLAGS} --allow-run-as-root) + endif() + set(OptionalCatchTestLauncher ${MPIEXEC} ${MPIEXEC_NUMPROC_FLAG} 3 ${MPIEXEC_OPTION_FLAGS} --path ${PUGS_BINARY_DIR}) endif() ParseAndAddCatchTests(mpi_unit_tests) unset(OptionalCatchTestLauncher)