summaryrefslogtreecommitdiff
path: root/.gitlab-ci
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2021-04-15 11:27:30 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2021-04-23 13:38:47 +1000
commit54ca9223e605824229deab67437d82be6bb478ab (patch)
tree2412031372de16a8e8d028e485000b5885d6898b /.gitlab-ci
parentae2ff14aa0d2f440a2cfe7a39daf12a009f8f914 (diff)
downloadxkeyboard-config-54ca9223e605824229deab67437d82be6bb478ab.tar.gz
gitlab CI: parse through the YAML file to list failed keymap compilations
libxkbcommon (commit 1cae25005211) now provides the output of the layout tester format in YAML, with successful compilations on stdout and failed ones on stderr. This makes it easy to collect the results, extract and print the failures with yq but also parse the yaml file and leave a JUnit XML in place that will then show up as result on a MR page. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Diffstat (limited to '.gitlab-ci')
-rwxr-xr-x.gitlab-ci/yaml-to-junit-xml.py59
1 files changed, 59 insertions, 0 deletions
diff --git a/.gitlab-ci/yaml-to-junit-xml.py b/.gitlab-ci/yaml-to-junit-xml.py
new file mode 100755
index 0000000..b297290
--- /dev/null
+++ b/.gitlab-ci/yaml-to-junit-xml.py
@@ -0,0 +1,59 @@
+#!/usr/bin/env python3
+#
+# Converts the YAML format from the layout tester into JUnit XML
+#
+# This file is formatted with Python Black
+
+import yaml
+import sys
+from xml.dom import minidom
+
+with open(sys.argv[1]) as fd:
+ yml = yaml.safe_load(open(sys.argv[1]))
+
+ doc = minidom.Document()
+ suite = doc.createElement("testsuite")
+ suite.setAttribute("name", "XKB layout compilation tests")
+ doc.appendChild(suite)
+
+ # JUnit differs between test case failures
+ # and errors (something else blew up)
+ # We use failures for unrecognized keysyms and errors
+ # for everything else (i.e. keymap compilation errors)
+ ntests, nfailures, nerrors = 0, 0, 0
+
+ for testcase in yml:
+ ntests += 1
+ node = doc.createElement("testcase")
+ node.setAttribute("classname", f"{testcase['rmlvo'][0]} rules layout test")
+ # We don't care about rules and model here, LVO is enough
+ r, m, l, v, o = testcase["rmlvo"]
+ if v:
+ name = f"{l}({v})"
+ else:
+ name = l
+ if o:
+ name += f", {o}"
+ node.setAttribute("name", f"keymap compilation: {name}")
+ suite.appendChild(node)
+
+ if testcase["status"] != 0:
+ f = None
+ if testcase["status"] == 99: # missing keysym
+ nfailures += 1
+ f = doc.createElement("failure")
+ else: # everything else is an error
+ nerrors += 1
+ f = doc.createElement("error")
+ f.setAttribute("message", testcase["error"])
+ cdata = doc.createCDATASection(
+ f"Error message: {testcase['error']} in command {testcase['cmd']}"
+ )
+ f.appendChild(cdata)
+ node.appendChild(f)
+
+ suite.setAttribute("tests", str(ntests))
+ suite.setAttribute("errors", str(nerrors))
+ suite.setAttribute("failures", str(nfailures))
+
+ print(doc.toprettyxml(indent=" "))