Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions .github/workflows/add_final_status.xsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<!-- Identity transform: copy everything as-is by default -->
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>

<!-- For testcase elements missing dd_tags[test.final_status] inside their properties block -->
<xsl:template match="testcase[not(properties/property[@name='dd_tags[test.final_status]'])]">
<xsl:copy>
<xsl:apply-templates select="@*"/>
<xsl:variable name="status">
<xsl:choose>
<xsl:when test="failure or error">fail</xsl:when>
<xsl:when test="skipped">skip</xsl:when>
<xsl:otherwise>pass</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:choose>
<xsl:when test="properties">
<!-- Inject into existing properties block, preserving child order -->
<xsl:for-each select="node()">
<xsl:choose>
<xsl:when test="self::properties">
<properties>
<xsl:apply-templates select="@*|node()"/>
<property name="dd_tags[test.final_status]" value="{$status}"/>
</properties>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="."/>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:when>
<xsl:otherwise>
<!-- No properties block: create one before other children -->
<properties>
<property name="dd_tags[test.final_status]" value="{$status}"/>
</properties>
<xsl:apply-templates select="node()"/>
</xsl:otherwise>
</xsl:choose>
</xsl:copy>
</xsl:template>

</xsl:stylesheet>
15 changes: 15 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,21 @@ jobs:
report_paths: "target/nextest/ci/junit.xml"
check_name: "[${{ matrix.platform }}:${{ matrix.rust_version }}] test report"
include_passed: true
# We're using not-that-ideal XSLT here as this change, because it must be done over 17+ repos.
# It's a workaround until this gets integrated into a better place, such as datadog-ci or the backend.
#
# * ticket: https://datadoghq.atlassian.net/browse/APMSP-2610
# * RFC: https://docs.google.com/document/d/1OaX_h09fCXWmK_1ADrwvilt8Yt5h4WjC7UUAdS3Y3uw/edit?pli=1&tab=t.0#heading=h.tfy5viz7rz2
- name: Add final_status property
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of adding a new step with a new way of modifying the junit.xml file, would it make more sense to incorporate it into the existing script we have that includes unit tests?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Definitly. I confess that since I need to do so for 17 repos (and maybe more), I went for a solution that works everywhere and use it regardless of the existing scripts.

But if you'd like to see an implementation in rust, I can give it a try, but I will very probably need your help, since I never write a single line of rust (Claude, be ready 😄 )

Let me know what you prefer !

Copy link
Contributor

@ekump ekump Mar 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is a blocker for you, I'm ok merging it as is and we can follow up later to merge it into the existing script. I can probably handle making the change.

if: success() || failure()
shell: bash
run: |
which xsltproc || sudo apt-get install -y xsltproc
echo "Fixing target/nextest/ci/junit.xml"
tmp_file="$(mktemp)"
xsltproc --output "$tmp_file" ".github/workflows/add_final_status.xsl" "target/nextest/ci/junit.xml"
mv "$tmp_file" "target/nextest/ci/junit.xml"

- name: Upload test results to Datadog
if: success() || failure()
shell: bash
Expand Down
Loading