Skip to content

Commit 8b4302a

Browse files
cbeauchesnesarahchen6devflow.devflow-routing-intake
authored
chore(ci) : add final_status property on junit XML (APMSP-2610) (#10741)
chore(ci) : add final_status property on junit XML [APMSP-2610] Add echo in script debug Update build image Merge branch 'master' into cbeauchesne/final_status Simplify and remove debug instruction Merge branch 'master' into cbeauchesne/final_status Use collect results Merge branch 'master' into cbeauchesne/final_status Merge branch 'master' into cbeauchesne/final_status Merge branch 'master' into cbeauchesne/final_status lint Merge branch 'master' into cbeauchesne/final_status Add comment in XSLT file Merge branch 'master' into cbeauchesne/final_status Co-authored-by: sarahchen6 <sarah.chen@datadoghq.com> Co-authored-by: devflow.devflow-routing-intake <devflow.devflow-routing-intake@kubernetes.us1.ddbuild.io>
1 parent 7cff994 commit 8b4302a

File tree

2 files changed

+65
-0
lines changed

2 files changed

+65
-0
lines changed

.gitlab/add_final_status.xsl

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<!--
4+
We're using not-that-ideal XSLT here as this change, because it must be done over 17+ repos.
5+
It's a workaround until this gets integrated into a better place, such as datadog-ci or the backend.
6+
* ticket: https://datadoghq.atlassian.net/browse/APMSP-2610
7+
* RFC: https://docs.google.com/document/d/1OaX_h09fCXWmK_1ADrwvilt8Yt5h4WjC7UUAdS3Y3uw/edit?pli=1&tab=t.0#heading=h.tfy5viz7rz2
8+
-->
9+
10+
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
11+
12+
<!-- Identity transform: copy everything as-is by default -->
13+
<xsl:template match="@*|node()">
14+
<xsl:copy>
15+
<xsl:apply-templates select="@*|node()"/>
16+
</xsl:copy>
17+
</xsl:template>
18+
19+
<!-- For testcase elements missing dd_tags[test.final_status] inside their properties block -->
20+
<xsl:template match="testcase[not(properties/property[@name='dd_tags[test.final_status]'])]">
21+
<xsl:copy>
22+
<xsl:apply-templates select="@*"/>
23+
<xsl:variable name="status">
24+
<xsl:choose>
25+
<xsl:when test="failure or error">fail</xsl:when>
26+
<xsl:when test="skipped">skip</xsl:when>
27+
<xsl:otherwise>pass</xsl:otherwise>
28+
</xsl:choose>
29+
</xsl:variable>
30+
<xsl:choose>
31+
<xsl:when test="properties">
32+
<!-- Inject into existing properties block, preserving child order -->
33+
<xsl:for-each select="node()">
34+
<xsl:choose>
35+
<xsl:when test="self::properties">
36+
<properties>
37+
<xsl:apply-templates select="@*|node()"/>
38+
<property name="dd_tags[test.final_status]" value="{$status}"/>
39+
</properties>
40+
</xsl:when>
41+
<xsl:otherwise>
42+
<xsl:apply-templates select="."/>
43+
</xsl:otherwise>
44+
</xsl:choose>
45+
</xsl:for-each>
46+
</xsl:when>
47+
<xsl:otherwise>
48+
<!-- No properties block: create one before other children -->
49+
<properties>
50+
<property name="dd_tags[test.final_status]" value="{$status}"/>
51+
</properties>
52+
<xsl:apply-templates select="node()"/>
53+
</xsl:otherwise>
54+
</xsl:choose>
55+
</xsl:copy>
56+
</xsl:template>
57+
58+
</xsl:stylesheet>

.gitlab/collect_results.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,13 @@ do
7777
sed -i '/<testcase/ s/@[0-9a-f]\{5,\}/@HASHCODE/g' "$TARGET_DIR/$AGGREGATED_FILE_NAME"
7878
# Replace random port numbers by marker in testcase XML nodes to get stable test names
7979
sed -i '/<testcase/ s/localhost:[0-9]\{2,5\}/localhost:PORT/g' "$TARGET_DIR/$AGGREGATED_FILE_NAME"
80+
81+
# Add dd_tags[test.final_status] property to each testcase
82+
xsl_file="$(dirname "$0")/add_final_status.xsl"
83+
tmp_file="$(mktemp)"
84+
xsltproc --output "$tmp_file" "$xsl_file" "$TARGET_DIR/$AGGREGATED_FILE_NAME"
85+
mv "$tmp_file" "$TARGET_DIR/$AGGREGATED_FILE_NAME"
86+
8087
if cmp -s "$RESULT_XML_FILE" "$TARGET_DIR/$AGGREGATED_FILE_NAME"; then
8188
echo ""
8289
else

0 commit comments

Comments
 (0)