forked from Open-CMSIS-Pack/cmsis-toolbox
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
173 additions
and
182 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
name: Robot Tests | ||
name: E2E Tests | ||
|
||
on: | ||
pull_request: | ||
|
@@ -83,79 +83,32 @@ jobs: | |
pip install --upgrade pip | ||
pip install -r test/requirements.txt | ||
- name: Download reports windows amd64 | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: reports-win-amd64 | ||
path: reports-win-amd64 | ||
|
||
- name: Download reports windows arm64 | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: reports-win-arm64 | ||
path: reports-win-arm64 | ||
|
||
- name: Download reports linux amd64 | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: reports-lin-amd64 | ||
path: reports-lin-amd64 | ||
|
||
- name: Download reports linux arm64 | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: reports-lin-arm64 | ||
path: reports-lin-arm64 | ||
|
||
- name: Download reports darwin amd64 | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: reports-mac-amd64 | ||
path: reports-mac-amd64 | ||
|
||
- name: Download reports darwin arm64 | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: reports-mac-arm64 | ||
path: reports-mac-arm64 | ||
path: artifacts | ||
pattern: reports-* | ||
|
||
- name: Consolidate robot test results | ||
continue-on-error: true | ||
working-directory: artifacts | ||
run: | | ||
python -m robot.rebot --name Collective_Robot_Results --outputdir Collective_Robot_Results --output output.xml \ | ||
./reports-win-amd64/output.xml ./reports-win-amd64/output.xml \ | ||
./reports-lin-arm64/output.xml ./reports-lin-arm64/output.xml \ | ||
python -m robot.rebot --name Collective_Robot_Results --outputdir collective_robot_results --output output.xml \ | ||
./reports-win-amd64/output.xml ./reports-win-arm64/output.xml \ | ||
./reports-lin-amd64/output.xml ./reports-lin-arm64/output.xml \ | ||
./reports-mac-amd64/output.xml ./reports-mac-arm64/output.xml | ||
- name: Convert xml to junit xml | ||
- name: Generate Summary report | ||
if: always() | ||
run: | | ||
python -m robot.rebot -x test_results_junit.xml Collective_Robot_Results/output.xml | ||
python ./test/lib/execution_summary.py artifacts/collective_robot_results/output.xml | ||
- name: Publish Test Results | ||
- name: Print E2E Report | ||
if: always() | ||
uses: EnricoMi/publish-unit-test-result-action@v2 | ||
with: | ||
report_individual_runs: true | ||
files: "test_results_junit.xml" | ||
|
||
- name: HTML Preview | ||
if: always() | ||
id: html_preview | ||
uses: pavi2410/html-preview-action@v2 | ||
with: | ||
html_file: 'Collective_Robot_Results/log.html' | ||
run: cat summary_report.md >> $GITHUB_STEP_SUMMARY | ||
|
||
- name: Archieve consolidated test results | ||
if: always() | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: consolidated-reports | ||
path: Collective_Robot_Results | ||
|
||
- name: Send report to commit | ||
if: always() | ||
uses: joonvena/[email protected] | ||
with: | ||
report_path: Collective_Robot_Results | ||
gh_access_token: ${{ secrets.GITHUB_TOKEN }} | ||
path: artifacts/collective_robot_results |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,7 @@ | ||
build | ||
# Directories | ||
/build*/ | ||
**/build | ||
**/__pycache__ | ||
|
||
# Files | ||
**/stdout.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
# This script is designed to process the output.xml file generated by Robot | ||
# Framework, extract the test statuses, and create a markdown file based | ||
# on the parsed information. | ||
# | ||
# execution_summary.py <path to input output.xml> [output file summary.md] | ||
|
||
import os | ||
import re | ||
import shutil | ||
import subprocess | ||
import sys | ||
from robot.api import ExecutionResult, ResultVisitor | ||
from robot.result.model import TestCase | ||
from robot.result.executionresult import Result | ||
|
||
class ResultVisitorEx(ResultVisitor): | ||
def __init__(self, markdown_file='summary_report.md'): | ||
self.failed_tests = {} | ||
self.passed_tests = {} | ||
self.skipped_tests = {} | ||
self.markdown_file = markdown_file | ||
|
||
# Remove existing markdown file if it exists | ||
if os.path.exists(markdown_file): | ||
os.remove(markdown_file) | ||
|
||
def visit_test(self, test: TestCase): | ||
tags = ", ".join(test.tags) | ||
duration = "{:.2f} s".format(test.elapsed_time.total_seconds()) | ||
status = (test.name, test.message, duration, test.parent.name) | ||
test_status = self.failed_tests if test.status == 'FAIL' else ( | ||
self.passed_tests if test.status == 'PASS' else self.skipped_tests) | ||
if tags not in test_status: | ||
test_status[tags] = [] | ||
test_status[tags].append(status) | ||
|
||
def end_result(self, result: Result): | ||
with open(self.markdown_file, "w") as f: | ||
f.write("# Robot Framework Report\n\n") | ||
self.__write_test_env(f) | ||
f.write("## Summary\n\n") | ||
f.write("|:white_check_mark: Passed|:x: Failed|:fast_forward: Skipped|Total|\n") | ||
f.write("|:----:|:----:|:-----:|:---:|\n") | ||
f.write(f"|{result.statistics.total.passed}|{result.statistics.total.failed}|{result.statistics.total.skipped}|{result.statistics.total.total}|\n") | ||
self.__write_test_section(f, self.passed_tests, "Passed Tests", "|Tag|Test|:clock1030: Duration|Suite|\n") | ||
self.__write_test_section(f, self.failed_tests, "Failed Tests", "|Tag|Test|Message|:clock1030: Duration|Suite|\n") | ||
self.__write_test_section(f, self.skipped_tests, "Skipped Tests", "|Tag|Test|Suite|\n") | ||
|
||
def __write_test_env(self, file): | ||
tool_dict = {"cbuild": shutil.which("cbuild"), | ||
"cpackget": shutil.which("cpackget"), | ||
"csolution": shutil.which("csolution")} | ||
|
||
file.write("## Test Environment\n\n") | ||
for tool, path in tool_dict.items(): | ||
version = "unknown" | ||
version_cmd = f"{tool} -V" | ||
try: | ||
output = subprocess.run(version_cmd, shell=True, check=True, text=True, capture_output=True) | ||
version_match = re.search(r"(\d+\.\d+\.\d+.*) \(C\)", output.stdout) | ||
if version_match: | ||
version = version_match.group(1) | ||
except subprocess.CalledProcessError: | ||
pass | ||
|
||
tool_info = f"- **{tool}**: `version {version}, {path}`" | ||
file.write(f"{tool_info}\n") | ||
file.write(f"- **CMSIS_PACK_ROOT**: `{os.getenv('CMSIS_PACK_ROOT')}`\n\n") | ||
|
||
|
||
def __write_test_section(self, file, test_dict, section_header, table_header): | ||
if len(test_dict) != 0: | ||
file.write(f"\n## {section_header}\n\n") | ||
file.write(table_header) | ||
tokens = table_header.split('|') | ||
table_sep = "|:-" | ||
num_req_sep = len(tokens) - 2 | ||
for i in range(num_req_sep): | ||
table_sep += "--:|" | ||
if i != (num_req_sep - 1): | ||
table_sep += ":-" | ||
file.write(table_sep + "\n") | ||
for key, value in test_dict.items(): | ||
for name, msg, duration, suite in value: | ||
if section_header.startswith("Pass"): | ||
file.write(f"|{key}|{name}|{duration}|{suite}|\n") | ||
elif section_header.startswith("Fail"): | ||
file.write(f"|{key}|{name}|{msg}|{duration}|{suite}|\n") | ||
elif section_header.startswith("Skip"): | ||
file.write(f"|{key}|{name}|{suite}|\n") | ||
|
||
if __name__ == '__main__': | ||
# Get output and markdown file paths from command line arguments | ||
output_file = sys.argv[1] if len(sys.argv) > 1 else "output.xml" | ||
markdown_file = sys.argv[2] if len(sys.argv) > 2 else "summary_report.md" | ||
|
||
# Parse the Robot Framework output file and generate the summary report | ||
result = ExecutionResult(output_file) | ||
result.visit(ResultVisitorEx(markdown_file)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
*** Variables *** | ||
${RESOURCES} ${CURDIR} # Path to the resource directory | ||
${Build} build # Directory name where example build files are copied | ||
${Data} data # Directory name of test data source | ||
${Data} data # Directory name of test data source | ||
${Pass} ${0} | ||
${Fail} ${1} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.