[librsvg: 4/6] CI: move the coverage script to a standalone shell script




commit 007cb72328c672fbfb74c702b3c7ed9567a117a2
Author: Federico Mena Quintero <federico gnome org>
Date:   Tue Jun 14 16:54:28 2022 -0500

    CI: move the coverage script to a standalone shell script
    
    This way it's easier to split each argument to grcov in a separate
    line, to make the command line easier to read.
    
    Part-of: <https://gitlab.gnome.org/GNOME/librsvg/-/merge_requests/709>

 .gitlab-ci.yml     |  5 +----
 ci/gen-coverage.sh | 27 +++++++++++++++++++++++++++
 2 files changed, 28 insertions(+), 4 deletions(-)
---
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 52ad5bc7f..68d1e3cb4 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -287,10 +287,7 @@ coverage:
     - make -k check
   after_script:
     - source ./ci/env.sh
-    - mkdir -p public
-    - grcov coverage-profiles _build --binary-path ./_build/target/debug/ --source-dir . --prefix-dir ../../ 
--output-type cobertura --branch --ignore-not-existing --ignore "build.rs" --ignore 'cargo_cache/*' -o 
coverage.xml
-    - grcov coverage-profiles _build --binary-path ./_build/target/debug/ --source-dir . --prefix-dir ../../ 
--output-type html --branch --ignore-not-existing --ignore "build.rs" --ignore 'cargo_cache/*' --output-path 
public/coverage
-    - grep -Eo 'line-rate="[^"]+"' coverage.xml | head -n 1 | grep -Eo '[0-9.]+' | awk '{ print "Coverage:", 
$1 * 100 }'
+    - bash -x ./ci/gen-coverage.sh
   coverage: '/Coverage: \d+\.\d+/'
   artifacts:
     name: ${CI_JOB_NAME}-${CI_COMMIT_REF_NAME}-${CI_COMMIT_SHA}
diff --git a/ci/gen-coverage.sh b/ci/gen-coverage.sh
new file mode 100644
index 000000000..871b22038
--- /dev/null
+++ b/ci/gen-coverage.sh
@@ -0,0 +1,27 @@
+#!/bin/sh
+
+set -eu
+
+mkdir -p public
+
+call_grcov() {
+    output_type=$1
+    output_path=$2
+
+    grcov coverage-profiles _build               \
+          --binary-path ./_build/target/debug/   \
+          --source-dir .                         \
+          --prefix-dir ../../                    \
+          --branch                               \
+          --ignore build.rs                      \
+          --ignore '**/build/markup5ever*'       \
+          --ignore '**/build/cssparser*'         \
+          --output-type $output_type             \
+          --output-path $output_path
+}
+
+call_grcov cobertura coverage.xml
+call_grcov html public/coverage
+
+# Print "Coverage: 42.42" so .gitlab-ci.yml will pick it up with a regex
+grep -Eo 'line-rate="[^"]+"' coverage.xml | head -n 1 | grep -Eo '[0-9.]+' | awk '{ print "Coverage:", $1 * 
100 }'


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