agora inbox for [email protected]  
help / color / mirror / Atom feed
From: Justin Pryzby <[email protected]>
Subject: [PATCH 4/6] wip: cirrus: code coverage
Date: Mon, 17 Jan 2022 00:54:28 -0600

XXX: lcov should be installed in the OS image

XXX: Use --num-spaces=4 like in src/Makefile.global.in ?

ci-os-only: linux
---
 .cirrus.yml           | 15 +++++++++++++--
 src/tools/ci/coverage | 18 ++++++++++++++++++
 2 files changed, 31 insertions(+), 2 deletions(-)
 create mode 100755 src/tools/ci/coverage

diff --git a/.cirrus.yml b/.cirrus.yml
index 1bb6463cb84..8d8c2203e01 100644
--- a/.cirrus.yml
+++ b/.cirrus.yml
@@ -174,6 +174,7 @@ task:
     cat /proc/cmdline
     ulimit -a -H && ulimit -a -S
     export
+    git diff --name-only HEAD~
   create_user_script: |
     useradd -m postgres
     chown -R postgres:postgres .
@@ -185,13 +186,14 @@ task:
     mkdir -m 770 /tmp/cores
     chown root:postgres /tmp/cores
     sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core'
-    #apt-get update
-    #apt-get -y install ...
+    apt-get update
+    apt-get -y install lcov
 
   configure_script: |
     su postgres <<-EOF
       ./configure \
         --enable-cassert --enable-debug --enable-tap-tests \
+        --enable-coverage \
         --enable-nls \
         \
         ${LINUX_CONFIGURE_FEATURES} \
@@ -211,6 +213,15 @@ task:
       make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS}
     EOF
 
+  # Build coverage report for files changed in the previous commit.
+  # This logic is sufficient for cfbot, but not otherwise.
+  generate_coverage_report_script: |
+    git log -1 --format='%an' |grep -Fxv 'Commitfest Bot' >/dev/null && echo skipping && exit
+    src/tools/ci/coverage
+
+  coverage_artifacts:
+    paths: ['coverage/**/*.html', 'coverage/**/*.png', 'coverage/**/*.gcov', 'coverage/**/*.css' ]
+
   on_failure:
     <<: *on_failure
     cores_script: src/tools/ci/cores_backtrace.sh linux /tmp/cores
diff --git a/src/tools/ci/coverage b/src/tools/ci/coverage
new file mode 100755
index 00000000000..fe4adfe5648
--- /dev/null
+++ b/src/tools/ci/coverage
@@ -0,0 +1,18 @@
+#! /bin/sh
+# Called during the linux CI task to generate a code coverage report.
+set -e
+
+mkdir coverage
+
+# Coverage only for changed files
+# This is useful to see coverage of newly-added code, but won't
+# show added/lost coverage in files which this patch doesn't modify.
+
+# This assumes a cfbot branch, which has all changes squished into a single patch.
+for f in `git diff --name-only HEAD~ '*.c'`
+do
+	lcov --quiet --capture --directory "$f"
+done >coverage/coverage.gcov
+
+genhtml coverage/coverage.gcov --output-directory coverage --show-details --legend --quiet
+cp coverage/index.html coverage/00-index.html
-- 
2.17.1


--MiFvc8Vo6wRSORdP
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
 filename="0005-wip-cirrus-windows-add-compiler_warnings_script.patch"



view thread (5+ messages)  latest in thread

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected]
  Subject: Re: [PATCH 4/6] wip: cirrus: code coverage
  In-Reply-To: <no-message-id-134012@localhost>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox