[tracker-miners/wip/carlosg/ci-coverage-all-tests: 1/2] ci: Collect coverage information from all tests




commit af5c5b21dcdaa663ec35e013329822385b67b200
Author: Carlos Garnacho <carlosg gnome org>
Date:   Sat Sep 3 11:39:39 2022 +0200

    ci: Collect coverage information from all tests
    
    Instead of doing a specific run to get testing coverage, collect the
    information of all tests being done. Since some of these will check for
    different build options, it's not possible to do that from a single run.
    
    This way we will get accurate information for all code that is being
    actually exercised by the tests.
    
    In consequence, using eatmydata to run the tests is no longer ok,
    since there is the possibility that it also eats the coverage reports
    that are generated during test runs.
    
    Also, since running tracker-extract in tests with seccomp enabled
    prevents coverage information from being written for the metadata
    extractors, this also means we now disable the seccomp jail on all
    tests (as opposed to just the coverage target).

 .gitlab-ci.yml | 30 ++++++++++++++++++------------
 1 file changed, 18 insertions(+), 12 deletions(-)
---
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 695b86bc4..7ace59cda 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -186,7 +186,7 @@ check-code-style:
     - echo "Building tracker.git commit $(git -C ./subprojects/tracker rev-parse HEAD)"
     - mkdir build
     - cd build
-    - meson .. --prefix=/usr -Dtracker_core=subproject -Db_lto=true -Db_coverage=true 
-Dtests_tap_protocol=true -Dtracker:docs=false --auto-features=enabled
+    - meson .. --prefix=/usr -Dtracker_core=subproject -Db_lto=true -Db_coverage=true -Dseccomp=false 
-Dtests_tap_protocol=true -Dtracker:docs=false --auto-features=enabled
     - ninja
   artifacts:
     expire_in: 1 day
@@ -233,16 +233,22 @@ build-ubuntu-rolling@x86_64:
   script:
     - .gitlab-ci/checkout-tracker.sh
     - cd build
+    - ninja clean
     - ninja
     - |
       # Remove the many "CI_" variables from the environment. Meson dumps the
       # whole environment for every failed test, and that gives a whole
       # screenful of junk each time unless we strip these.
       unset $(env|grep -o '^CI_[^=]*')
-
-      dbus-run-session -- env LANG=C.UTF-8 LC_ALL=C.UTF-8 eatmydata meson test --suite tracker-miners 
--print-errorlogs
+      dbus-run-session -- env LANG=C.UTF-8 LC_ALL=C.UTF-8 meson test --suite tracker-miners 
--print-errorlogs ${MESON_TEST_EXTRA_ARGS}
 
   after_script:
+    - pushd build
+    - gcovr --root=.. --exclude=../build --exclude=./build
+        --exclude=../tests --exclude=./subprojects --exclude=../subprojects
+        --exclude='\.\./build/.*\.[ch]$' --exclude='.*/tests/.*\.[ch]$'
+        --json --print-summary --output=../coverage-${CI_JOB_NAME}.json
+    - popd
     - |
       echo "Distribution: "
       echo
@@ -261,6 +267,7 @@ build-ubuntu-rolling@x86_64:
     when: always
     paths:
     - build/meson-logs/*.txt
+    - coverage-*.json
     reports:
       junit: "build/meson-logs/testlog.junit.xml"
 
@@ -298,27 +305,26 @@ test-ubuntu@x86_64:
     - build-ubuntu-rolling@x86_64
   <<: *test
 
-coverage-analysis:
+coverage:
   extends:
     - .fdo.distribution-image@fedora
     - .tracker-miners.fedora:36@x86_64
   stage: analysis
   allow_failure: true
   script:
-    - .gitlab-ci/checkout-tracker.sh
-    - mkdir -p coverage-build/coveragereport
-    - cd coverage-build
-    - meson .. --prefix=/usr -Dtracker_core=subproject -Db_lto=true -Db_coverage=true -Dseccomp=false 
-Dtracker:docs=false --auto-features=enabled
-    - ninja
-    - env LANG=C.UTF-8 LC_ALL=C.UTF-8 dbus-run-session eatmydata meson test --print-errorlogs 
${MESON_TEST_EXTRA_ARGS}
-    - gcovr --html-details --print-summary --root=.. --exclude=subprojects --exclude=../subprojects 
--exclude=../tests --output coveragereport/index.html
+    - mkdir coveragereport
+    - gcovr --add-tracefile 'coverage-*.json'
+        --html-details --print-summary --output coveragereport/index.html
   coverage: '/^lines: (\d+\.\d+\%)/'
   artifacts:
     when: always
     paths:
-    - coverage-build/coveragereport
+    - coveragereport
   needs:
     - test-fedora@x86_64
+    - test-fedora-rawhide@x86_64
+    - test-fedora@aarch64
+    - test-ubuntu@x86_64
 
 coverity:
   extends:


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]