gitlab CI: drop the manual meson to junit conversion
authorPeter Hutterer <peter.hutterer@who-t.net>
Mon, 13 Jun 2022 04:07:56 +0000 (14:07 +1000)
committerPeter Hutterer <peter.hutterer@who-t.net>
Tue, 14 Jun 2022 03:11:14 +0000 (13:11 +1000)
Meson supports this natively since version 0.55 which is available in
all our tested distributions.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
.gitlab-ci.yml
.gitlab-ci/ci.template
.gitlab-ci/meson-build.sh
.gitlab-ci/meson-junit-report.py [deleted file]

index e024288295d020cccc25cd1782b53c6d5e1745ca..f33c24887cbce99b1a6e042cf20c61c02d0b3f16 100644 (file)
@@ -137,7 +137,7 @@ variables:
     paths:
       - $MESON_BUILDDIR/meson-logs
     reports:
-      junit: $MESON_BUILDDIR/junit-*.xml
+      junit: $MESON_BUILDDIR/*junit*.xml
 
 
 #################################################################
@@ -485,7 +485,7 @@ alpine:latest@container-clean:
       - $MESON_BUILDDIR/meson-logs
       - console.out
     reports:
-      junit: $MESON_BUILDDIR/junit-*.xml
+      junit: $MESON_BUILDDIR/*junit*.xml
 
 
 # Run in a test suite. Special variables:
index 61faf67da6f6b50f67c3a38583a1b1d83b731317..b5844afb175816c9c848d96f69618e551f87ce77 100644 (file)
@@ -118,7 +118,7 @@ variables:
     paths:
       - $MESON_BUILDDIR/meson-logs
     reports:
-      junit: $MESON_BUILDDIR/junit-*.xml
+      junit: $MESON_BUILDDIR/*junit*.xml
 
 
 #################################################################
@@ -343,7 +343,7 @@ check-commit:
       - $MESON_BUILDDIR/meson-logs
       - console.out
     reports:
-      junit: $MESON_BUILDDIR/junit-*.xml
+      junit: $MESON_BUILDDIR/*junit*.xml
 
 
 # Run in a test suite. Special variables:
index 56b1abccf8e7e97484a7be51c838aa6160e227a2..cde92ba975e3326e1def42321f4bfb56a80773dd 100755 (executable)
@@ -44,18 +44,4 @@ if [[ -z "$MESON_TEST_ARGS" ]]; then
     exit 0
 fi
 
-# we still want to generate the reports, even if meson test fails
-set +e
 meson test -C "$MESON_BUILDDIR" $MESON_TEST_ARGS --print-errorlogs
-exit_code=$?
-set -e
-
-# We need the glob for the testlog so that it picks up those suffixed by a
-# suite (e.g. testlog-valgrind.json)
-./.gitlab-ci/meson-junit-report.py \
-       --project-name=libinput \
-       --job-id="$CI_JOB_ID" \
-       --output="$MESON_BUILDDIR/junit-$CI_JOB_NAME-report.xml" \
-       "$MESON_BUILDDIR"/meson-logs/testlog*.json; \
-
-exit $exit_code
diff --git a/.gitlab-ci/meson-junit-report.py b/.gitlab-ci/meson-junit-report.py
deleted file mode 100755 (executable)
index ec7f317..0000000
+++ /dev/null
@@ -1,117 +0,0 @@
-#!/usr/bin/env python3
-#
-# meson-junit-report.py: Turns a Meson test log into a JUnit report
-#
-# Copyright 2019  GNOME Foundation
-#
-# SPDX-License-Identifier: LGPL-2.1-or-later
-
-import argparse
-import datetime
-import json
-import sys
-import xml.etree.ElementTree as ET
-
-aparser = argparse.ArgumentParser(
-    description="Turns a Meson test log into a JUnit report"
-)
-aparser.add_argument(
-    "--project-name", metavar="NAME", help="The project name", default="unknown"
-)
-aparser.add_argument(
-    "--job-id", metavar="ID", help="The job ID for the report", default="Unknown"
-)
-aparser.add_argument(
-    "--branch",
-    metavar="NAME",
-    help="Branch of the project being tested",
-    default="main",
-)
-aparser.add_argument(
-    "--output",
-    metavar="FILE",
-    help="The output file, stdout by default",
-    type=argparse.FileType("w", encoding="UTF-8"),
-    default=sys.stdout,
-)
-aparser.add_argument(
-    "infile",
-    metavar="FILE",
-    help="The input testlog.json, stdin by default",
-    type=argparse.FileType("r", encoding="UTF-8"),
-    default=sys.stdin,
-)
-
-args = aparser.parse_args()
-
-outfile = args.output
-
-testsuites = ET.Element("testsuites")
-testsuites.set("id", "{}/{}".format(args.job_id, args.branch))
-testsuites.set("package", args.project_name)
-testsuites.set("timestamp", datetime.datetime.utcnow().isoformat(timespec="minutes"))
-
-suites = {}
-for line in args.infile:
-    data = json.loads(line)
-    (full_suite, unit_name) = data["name"].split(" / ")
-    (project_name, suite_name) = full_suite.split(":")
-
-    duration = data["duration"]
-    return_code = data["returncode"]
-    log = data["stdout"]
-
-    unit = {
-        "suite": suite_name,
-        "name": unit_name,
-        "duration": duration,
-        "returncode": return_code,
-        "stdout": log,
-    }
-
-    units = suites.setdefault(suite_name, [])
-    units.append(unit)
-
-for name, units in suites.items():
-    print("Processing suite {} (units: {})".format(name, len(units)))
-
-    def if_failed(unit):
-        if unit["returncode"] != 0:
-            return True
-        return False
-
-    def if_succeded(unit):
-        if unit["returncode"] == 0:
-            return True
-        return False
-
-    successes = list(filter(if_succeded, units))
-    failures = list(filter(if_failed, units))
-    print(" - {}: {} pass, {} fail".format(name, len(successes), len(failures)))
-
-    testsuite = ET.SubElement(testsuites, "testsuite")
-    testsuite.set("name", "{}/{}".format(args.project_name, name))
-    testsuite.set("tests", str(len(units)))
-    testsuite.set("errors", str(len(failures)))
-    testsuite.set("failures", str(len(failures)))
-
-    for unit in successes:
-        testcase = ET.SubElement(testsuite, "testcase")
-        testcase.set("classname", "{}/{}".format(args.project_name, unit["suite"]))
-        testcase.set("name", unit["name"])
-        testcase.set("time", str(unit["duration"]))
-
-    for unit in failures:
-        testcase = ET.SubElement(testsuite, "testcase")
-        testcase.set("classname", "{}/{}".format(args.project_name, unit["suite"]))
-        testcase.set("name", unit["name"])
-        testcase.set("time", str(unit["duration"]))
-
-        failure = ET.SubElement(testcase, "failure")
-        failure.set("classname", "{}/{}".format(args.project_name, unit["suite"]))
-        failure.set("name", unit["name"])
-        failure.set("type", "error")
-        failure.text = unit["stdout"]
-
-output = ET.tostring(testsuites, encoding="unicode")
-outfile.write(output)