-
Notifications
You must be signed in to change notification settings - Fork 240
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[GHA] summary for test examples (#3079)
### Changes - Add summary for jobs - Fix pytest argumets `-ra -s` - Dont fail job if run workflow manually for less 4 examples (catch return code 5) ### Tests [test_examples](https://github.com/openvinotoolkit/nncf/actions/runs/11798937213)
- Loading branch information
1 parent
1744c3d
commit 8555c86
Showing
2 changed files
with
71 additions
and
8 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 |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# Copyright (c) 2024 Intel Corporation | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
""" | ||
This script generates a summary table in Markdown format from an XML report generated by pytest. | ||
Usage in GitHub workflow: | ||
- name: Test Summary | ||
if: ${{ !cancelled() }} | ||
run: | | ||
python .github/scripts/generate_examples_summary.py pytest-results.xml >> $GITHUB_STEP_SUMMARY | ||
""" | ||
|
||
import sys | ||
import xml.etree.ElementTree as ET | ||
|
||
# Load the XML report generated by pytest | ||
xml_file = sys.argv[1] | ||
|
||
try: | ||
tree = ET.parse(xml_file) | ||
except FileNotFoundError: | ||
sys.exit(1) | ||
|
||
root = tree.getroot() | ||
|
||
# Build the summary table in Markdown format | ||
table_lines = [] | ||
table_lines.append("| Test Name | Status | Time | Message |") | ||
table_lines.append("|:----------|:------:|-----:|:--------|") | ||
|
||
# Iterate over test cases | ||
for testcase in root.findall(".//testcase"): | ||
test_name = testcase.get("name") | ||
time_duration = float(testcase.get("time", "0")) | ||
message = "" | ||
if testcase.find("failure") is not None: | ||
status = "$${\color{red}Failed}$$" | ||
message = testcase.find("failure").get("message", "") | ||
elif testcase.find("error") is not None: | ||
status = "$${\color{red}Error}$$" | ||
elif testcase.find("skipped") is not None: | ||
status = "$${\color{orange}Skipped}$$" | ||
message = testcase.find("skipped").get("message", "") | ||
else: | ||
status = "$${\color{green}Ok}$$" | ||
|
||
# Append each row to the table | ||
table_lines.append(f"| {test_name} | {status} | {time_duration:.0f} | {message} |") | ||
|
||
print("\n".join(table_lines)) |
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