Add coverage build to post merge
authorPaul Bauer <paul.bauer.q@gmail.com>
Fri, 26 Feb 2021 14:36:45 +0000 (14:36 +0000)
committerMark Abraham <mark.j.abraham@gmail.com>
Fri, 26 Feb 2021 14:36:45 +0000 (14:36 +0000)
Every merged commit will be checked for changes to code coverage with
this addition.

Small change to flags added when building for coverage.

Build can be extended for other metrics later as well.

CMakeLists.txt
admin/gitlab-ci/gromacs.matrix.gitlab-ci.yml
admin/gitlab-ci/gromacs.matrix/gromacs.gcc-10-coverage.gitlab-ci.yml [new file with mode: 0644]

index 27a74208a859d4989dd381687510ba9b0a3d5ade..5bb59a08a9e4bc2ea1ea69b7f746404b069ef5f9 100644 (file)
@@ -685,6 +685,12 @@ if (GMX_BUILD_HELP AND SOURCE_IS_SOURCE_DISTRIBUTION AND BUILD_IS_INSOURCE)
         "Set GMX_BUILD_HELP=OFF or do an out-of-source build to proceed.")
 endif()
 
+if (GMX_BUILD_FOR_COVERAGE)
+    # Set flags for coverage build here instead having to do so manually
+    set(CMAKE_C_FLAGS "-g --coverage")
+    set(CMAKE_CXX_FLAGS "-g --coverage")
+endif()
+
 # # # # # # # # # # NO MORE TESTS AFTER THIS LINE! # # # # # # # # # # #
 # these are set after everything else
 if (NOT GMX_SKIP_DEFAULT_CFLAGS)
@@ -739,15 +745,6 @@ endif()
 #Simpler to always install.
 install(FILES COPYING DESTINATION ${GMX_INSTALL_GMXDATADIR} COMPONENT data)
 
-if (GMX_BUILD_FOR_COVERAGE)
-    # Code heavy with asserts makes conditional coverage close to useless metric,
-    # as by design most of the false branches are impossible to trigger in
-    # correctly functioning code.  And the benefit of testing those that could
-    # be triggered by using an API against its specification isn't usually
-    # worth the effort.
-    add_definitions(-DNDEBUG -DGMX_DISABLE_ASSERTS)
-endif()
-
 if (BUILD_TESTING)
     include(tests/CheckTarget.cmake)
 endif()
index 44fcdc7be607d2abfc014a695bac016673ec8c98..75d9cac850dd0f984719bf7cee74337d8f984019 100644 (file)
@@ -266,6 +266,7 @@ include:
   - local: '/admin/gitlab-ci/gromacs.matrix/gromacs.clang-TSAN.gitlab-ci.yml'
   - local: '/admin/gitlab-ci/gromacs.matrix/gromacs.clang-UBSAN.gitlab-ci.yml'
   - local: '/admin/gitlab-ci/gromacs.matrix/gromacs.gcc-10.gitlab-ci.yml'
+  - local: '/admin/gitlab-ci/gromacs.matrix/gromacs.gcc-10-coverage.gitlab-ci.yml'  
   - local: '/admin/gitlab-ci/gromacs.matrix/gromacs.gcc-7-cuda-10.2.gitlab-ci.yml'
   - local: '/admin/gitlab-ci/gromacs.matrix/gromacs.gcc-8-cuda-11.0.gitlab-ci.yml'
   - local: '/admin/gitlab-ci/gromacs.matrix/gromacs.gcc-8-cuda-11.0-release.gitlab-ci.yml'
diff --git a/admin/gitlab-ci/gromacs.matrix/gromacs.gcc-10-coverage.gitlab-ci.yml b/admin/gitlab-ci/gromacs.matrix/gromacs.gcc-10-coverage.gitlab-ci.yml
new file mode 100644 (file)
index 0000000..b8e2190
--- /dev/null
@@ -0,0 +1,90 @@
+# Test goal: code coverage with newest GCC
+# Test intents (should change rarely and conservatively):
+#   OS: Ubuntu newest supported
+#   Compiler: GCC newest supported
+#   GPU: no
+#   Scope: configure, build, unit tests, coverage
+# Test implementation choices (free to change as needed):
+#   OS: Ubuntu 20.04
+#   Build type: Debug
+#   Compiler: GCC 10
+#   MPI: thread_MPI
+#   SIMD: AVX2_256
+#   Parallelism nt/ntomp: 4/2 (unit tests)
+
+gromacs:gcc-10:coverage:configure:
+  extends:
+    - .gromacs:base:configure
+    - .use-gcc:base
+    - .rules:post-merge-acceptance
+  image: ${CI_REGISTRY}/gromacs/gromacs/ci-ubuntu-20.04-gcc-10
+  variables:
+    CMAKE: /usr/local/cmake-3.18.4/bin/cmake
+    CMAKE_SIMD_OPTIONS: "-DGMX_SIMD=AVX2_256"
+    CMAKE_EXTRA_OPTIONS: "-DGMX_BUILD_FOR_COVERAGE=ON"
+    COMPILER_MAJOR_VERSION: 10
+
+gromacs:gcc-10:coverage:build:
+  extends:
+    - .variables:default
+    - .gromacs:base:build
+    - .before_script:default
+    - .use-ccache
+    - .rules:post-merge-acceptance
+  image: ${CI_REGISTRY}/gromacs/gromacs/ci-ubuntu-20.04-gcc-10
+  variables:
+    CMAKE: /usr/local/cmake-3.18.4/bin/cmake
+  needs:
+    - job: gromacs:gcc-10:coverage:configure
+
+gromacs:gcc-10:coverage:test:
+  extends:
+    - .gromacs:base:test
+    - .rules:post-merge-acceptance
+  image: ${CI_REGISTRY}/gromacs/gromacs/ci-ubuntu-20.04-gcc-10
+  variables:
+    CMAKE: /usr/local/cmake-3.18.4/bin/cmake
+  tags:
+    - k8s-scilifelab
+  needs:
+    - job: gromacs:gcc-10:coverage:build
+  artifacts:
+    paths:
+      - $BUILD_DIR
+
+gromacs:coverage:analyse:
+  variables:
+    CMAKE: /usr/local/cmake-3.18.4/bin/cmake
+    VENVPATH: "/root/venv/py3.7"
+    GCOVR_GENERAL_OPTIONS: "-r ../ /. --gcov-executable=gcov-10 --exclude-unreachable-branches --exclude-throw-branches -j$KUBERNETES_CPU_LIMIT"
+    GCOVR_EXCLUDE_OPTIONS: "--exclude-directories '^src/external/.*' --exclude-directories '^src/gromacs/selection/.*' --exclude-directories '.*tests.*" 
+  extends:
+    - .variables:default
+    - .rules:post-merge-acceptance
+  stage: post-test
+  image: ${CI_REGISTRY}/gromacs/gromacs/ci-ubuntu-20.04-gcc-10
+  needs:
+    - job: gromacs:gcc-10:coverage:build
+    - job: gromacs:gcc-10:coverage:test
+
+  tags:
+    - k8s-scilifelab
+  script:
+    - echo ${GCOVR_GENERAL_OPTIONS}
+    - echo ${GCOVR_EXCLUDE_OPTIONS}
+    - source $VENVPATH/bin/activate
+    - mkdir public
+    - outputdir=`pwd`/public
+    - cd $BUILD_DIR
+    # run gcovr to write to stdout for GitLab pipeline grep.
+    - gcovr ${GCOVR_GENERAL_OPTIONS} ${GCOVR_EXCLUDE_OPTIONS}
+    # run gcovr to generate xml output. keep the generated files to produce the html output later.
+    # the invocations need to be separate due to a crash in gcovr where files can not be found.
+    - gcovr ${GCOVR_GENERAL_OPTIONS} ${GCOVR_EXCLUDE_OPTIONS} --xml $outputdir/cobertura-coverage.xml --xml-pretty --keep
+    # final gcovr run, using the generated files to produce nice looking html output
+    - gcovr ${GCOVR_GENERAL_OPTIONS} ${GCOVR_EXCLUDE_OPTIONS} --html $outputdir/coverage.html --use-gcov-files
+  artifacts:
+    paths:
+      - public/
+    reports:
+      cobertura: public/cobertura-coverage.xml