diff mbox series

[3/3] CI: transform testimage reports into JUnit XML reports

Message ID 20240927155705.1121586-3-ross.burton@arm.com
State New
Headers show
Series [1/3] CI: add KAS_BUILD_DIR variable | expand

Commit Message

Ross Burton Sept. 27, 2024, 3:57 p.m. UTC
Using resulttool we can transform the oeqa JSON reports into JUnit XML,
which GitLab can display in pipelines and merge requests.

Signed-off-by: Ross Burton <ross.burton@arm.com>
---
 .gitlab-ci.yml |  4 ++++
 ci/junit.sh    | 15 +++++++++++++++
 2 files changed, 19 insertions(+)
 create mode 100755 ci/junit.sh
diff mbox series

Patch

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 01f3539f..e37f9d20 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -77,12 +77,16 @@  stages:
     - kas dump --update --force-checkout --resolve-refs --resolve-env $KASFILES
     - kas build $KASFILES
     - ./ci/check-warnings $KAS_BUILD_DIR/warnings.log
+    - kas shell ci/base.yml:lockfile.yml --command "$CI_PROJECT_DIR/ci/junit.sh $KAS_WORK_DIR/build"
+
   artifacts:
     name: "logs"
     when: always
     paths:
       - $KAS_BUILD_DIR/tmp*/work*/**/temp/log.do_*.*
       - $KAS_BUILD_DIR/tmp*/work*/**/testimage/*
+    reports:
+      junit: $KAS_BUILD_DIR/tmp/log/oeqa/junit.xml
 
 #
 # Prep stage, update repositories once.
diff --git a/ci/junit.sh b/ci/junit.sh
new file mode 100755
index 00000000..6262c34b
--- /dev/null
+++ b/ci/junit.sh
@@ -0,0 +1,15 @@ 
+#! /bin/bash
+
+# $ ci/junit.sh <build directory>
+#
+# If there is a OEQA test report in JSON format present in the build directory,
+# transform it to JUnit XML using resulttool.
+
+set -e -u
+
+BUILDDIR=$1
+JSON=$BUILDDIR/tmp/log/oeqa/testresults.json
+
+if test -f $JSON; then
+    resulttool junit $JSON
+fi