Skip to content

Commit 4125131

Browse files
authored
test: add more fields to xml report for test aggregation tool (#519)
1 parent 4aabcec commit 4125131

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed

.github/workflows/e2e-suite.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,20 @@ jobs:
4646
env:
4747
LINODE_CLI_TOKEN: ${{ secrets.LINODE_TOKEN }}
4848

49+
- name: Set release version env
50+
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
51+
52+
- name: Add additional information to XML report
53+
run: |
54+
echo $RELEASE_VERSION
55+
echo ${{ env.RELEASE_VERSION }}
56+
filename=$(ls | grep -E '^[0-9]{12}_cli_test_report\.xml$')
57+
python scripts/add_to_xml_test_report.py \
58+
--branch_name "${{ env.RELEASE_VERSION }}" \
59+
--gha_run_id "$GITHUB_RUN_ID" \
60+
--gha_run_number "$GITHUB_RUN_NUMBER" \
61+
--xmlfile "${filename}"
62+
4963
- name: Upload test results
5064
run: |
5165
filename=$(ls | grep -E '^[0-9]{12}_cli_test_report\.xml$')

scripts/add_to_xml_test_report.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import argparse
2+
import xml.etree.ElementTree as ET
3+
4+
# Parse command-line arguments
5+
parser = argparse.ArgumentParser(description='Modify XML with workflow information')
6+
parser.add_argument('--branch_name', required=True)
7+
parser.add_argument('--gha_run_id', required=True)
8+
parser.add_argument('--gha_run_number', required=True)
9+
parser.add_argument('--xmlfile', required=True) # Added argument for XML file path
10+
11+
args = parser.parse_args()
12+
13+
# Open and parse the XML file
14+
xml_file_path = args.xmlfile
15+
tree = ET.parse(xml_file_path)
16+
root = tree.getroot()
17+
18+
# Create new elements for the information
19+
branch_name_element = ET.Element('branch_name')
20+
branch_name_element.text = args.branch_name
21+
22+
gha_run_id_element = ET.Element('gha_run_id')
23+
gha_run_id_element.text = args.gha_run_id
24+
25+
gha_run_number_element = ET.Element('gha_run_number')
26+
gha_run_number_element.text = args.gha_run_number
27+
28+
# Add the new elements to the root of the XML
29+
root.append(branch_name_element)
30+
root.append(gha_run_id_element)
31+
root.append(gha_run_number_element)
32+
33+
# Save the modified XML
34+
modified_xml_file_path = xml_file_path # Overwrite it
35+
tree.write(modified_xml_file_path)
36+
37+
print(f'Modified XML saved to {modified_xml_file_path}')

0 commit comments

Comments
 (0)