Skip to content

Commit 992baa6

Browse files
committed
remove xom prerebotmodifier and add gha reporter
1 parent 477a209 commit 992baa6

File tree

3 files changed

+118
-7
lines changed

3 files changed

+118
-7
lines changed

.github/workflows/ci.yml

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,23 @@ jobs:
5555
results/*.xml
5656
results/*.prof
5757
results/*.txt
58-
- name: Test Report
59-
uses: dorny/test-reporter@main
60-
if: success() || failure() # run this step even if previous step failed
58+
# - name: Test Report
59+
# uses: dorny/test-reporter@main
60+
# if: success() || failure() # run this step even if previous step failed
61+
# with:
62+
# name: xUnit Tests ${{ matrix.python-version }} # Name of the check run which will be created
63+
# path: results/pytest.xml,results/xunit.xml # Path to test results
64+
# reporter: java-junit # Format of test results
65+
- name: Store Artifact
66+
uses: actions/upload-artifact@v3
67+
if: success() || failure()
6168
with:
62-
name: xUnit Tests ${{ matrix.python-version }} # Name of the check run which will be created
63-
path: results/pytest.xml,results/xunit.xml # Path to test results
64-
reporter: java-junit # Format of test results
69+
name: test-results ${{ matrix.python-version }} # Choose a descriptive name for your artifact
70+
path: |
71+
results
72+
- name: Report results
73+
if: success() || failure()
74+
run: |
75+
poetry shell
76+
pip install pytablewriter
77+
python utilities/gha_reporter.py utilities/output.xml $GITHUB_STEP_SUMMARY

tasks.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ def atests(context):
3838
"--listener RobotStackTracer",
3939
"--exclude appiumORnot_readyORnot_ci"
4040
"-d results",
41-
f"--prerebotmodifier utilities.xom.XUnitOut:results/xunit.xml",
4241
f"{ROOT}/tests/atest"
4342
]
4443
global atests_completed_process

utilities/gha_reporter.py

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
from robot.api import ExecutionResult, ResultVisitor
2+
from pytablewriter import MarkdownTableWriter
3+
import sys
4+
5+
6+
class SuitesWithTestsVisitor(ResultVisitor):
7+
def __init__(self):
8+
self.suites_with_tests = []
9+
10+
def start_suite(self, suite):
11+
if suite.tests:
12+
self.suites_with_tests.append(suite)
13+
14+
15+
def main():
16+
output_file = sys.argv[1]
17+
markdown_file = sys.argv[2]
18+
19+
f = open(markdown_file, "w")
20+
21+
result = ExecutionResult(output_file)
22+
23+
# Write PieChart as Markdown
24+
stats = result.statistics
25+
f.write("```mermaid\n")
26+
f.write(
27+
"%%{init: {'theme': 'base', 'themeVariables': { 'pie1': '#00FF00', 'pie2': '#FF0000', 'pie3': '#FFFF00'}}}%%\n"
28+
)
29+
f.write("pie title Test Status\n")
30+
f.write(f' "Passed" : {stats.total.passed}\n')
31+
f.write(f' "Failed" : {stats.total.failed}\n')
32+
f.write(f' "Skipped" : {stats.total.skipped}\n')
33+
f.write("```\n")
34+
35+
# Get all suites with Tests
36+
suite_visitor = SuitesWithTestsVisitor()
37+
result.visit(suite_visitor)
38+
suites_with_tests = suite_visitor.suites_with_tests
39+
40+
suite_results = []
41+
for suite in suites_with_tests:
42+
suite_results.append(
43+
[
44+
suite.name,
45+
suite.statistics.passed,
46+
suite.statistics.failed,
47+
suite.statistics.skipped,
48+
suite.statistics.total,
49+
suite.elapsed_time.total_seconds(),
50+
]
51+
)
52+
53+
# Write Table with Results for each Suite as Markdown
54+
table_columns = [
55+
"Test Suite",
56+
"Passed ✅",
57+
"Failed ❌",
58+
"Skipped 🛑",
59+
"Total",
60+
"Elapsed Time ⏱️",
61+
]
62+
writer = MarkdownTableWriter(
63+
table_name="Test Suite Status",
64+
headers=table_columns,
65+
value_matrix=suite_results,
66+
)
67+
writer.stream = f
68+
writer.write_table()
69+
f.write("\n")
70+
status_emoji = {
71+
"PASS": "✅PASS",
72+
"FAIL": "❌FAIL",
73+
"SKIP": "🛑SKIP",
74+
"NOT RUN": "NOT RUN",
75+
"NOT SET": "❓NOT SET",
76+
}
77+
for suite in suites_with_tests:
78+
tests_in_suite = []
79+
for test in suite.tests:
80+
tests_in_suite.append(
81+
[
82+
test.name,
83+
status_emoji.get(test.status, "unknown"),
84+
test.elapsed_time.total_seconds(),
85+
]
86+
)
87+
88+
# Write Table with Results for each Test Case for a Suite as Markdown
89+
table_columns = ["Test Case", "Status", "Elapsed Time ⏱️"]
90+
writer = MarkdownTableWriter(
91+
table_name=suite.name, headers=table_columns, value_matrix=tests_in_suite
92+
)
93+
writer.stream = f
94+
writer.write_table()
95+
f.write("\n")
96+
97+
98+
if __name__ == "__main__":
99+
main()

0 commit comments

Comments
 (0)