Skip to content

Commit

Permalink
Merge new reporting features (#22)
Browse files Browse the repository at this point in the history
* Aggregate all junit reports

* Display summary instead of report

* Add repository name for checkout action
  • Loading branch information
dariusstefan authored Jan 16, 2025
1 parent a8f58ca commit 389a5f8
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 0 deletions.
23 changes: 23 additions & 0 deletions .github/scripts/aggregate_junit_reports.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import os
import glob
from junitparser import JUnitXml, TestSuite

def aggregate_junit_reports(report_dir, output_report):
aggregated = JUnitXml()
aggregated.name = "Aggregated Tests"

for file_path in glob.glob(os.path.join(report_dir, "**/report.xml"), recursive=True):
xml = JUnitXml.fromfile(file_path)
for suite in xml:
if isinstance(suite, TestSuite):
aggregated.add_testsuite(suite)

aggregated.write(output_report)
print(f"Aggregated report saved to {output_report}")

if __name__ == "__main__":
import os
report_dir = os.getenv("REPORT_DIR", "./junit-reports")
output_report = os.getenv("OUTPUT_FILE", "aggregated-report.xml")
aggregate_junit_reports(report_dir, output_report)

42 changes: 42 additions & 0 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,45 @@ jobs:
uses: OpenSIPS/SIPssert/.github/actions/Run_Tests@main
with:
tests: ${{ matrix.tests }}

aggregate:
needs: test
runs-on: ubuntu-latest
if: always()
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
repository: OpenSIPS/sipssert-opensips-tests
path: tests

- name: Download All Artifacts
uses: actions/download-artifact@v4
with:
path: junit-reports

- name: Aggregate JUnit Reports
run: |
pip install junitparser
python tests/.github/scripts/aggregate_junit_reports.py
env:
REPORTS_DIR: junit-reports
OUTPUT_FILE: junit-final-report.xml

- name: Upload JUnit XML
uses: actions/upload-artifact@v4
with:
name: junit-final-report
path: junit-final-report.xml

- name: Print tests summary
uses: mikepenz/action-junit-report@v5
id: summary
if: success() || failure()
with:
check_name: 'SIPssert tests report'
report_paths: junit-final-report.xml
annotate_only: true
fail_on_failure: true
detailed_summary: true
include_passed: true

0 comments on commit 389a5f8

Please sign in to comment.