Files
esp-matter/tools/ci/results_formatter.py
shripad621git 61d3c363a0 tools/ci : Added the support to execute python certification tests in CI.
- Added the support of the certification tests in CI for esp32c6.
- Added pytest_cert_helper script to execute certification tests.
- Added the json file to maintain and modify a list of tests to be run in the CI.
- Added the PICS file for extended_color_light for wifi for the certification tests.
- Added the support to post the test results on gitlab MR.
- Added the support to use certification test json file as an argument to pytests.
- Added support to use gitlab environment variables like ssid and password in pytests.
2025-07-14 16:45:04 +05:30

95 lines
3.6 KiB
Python

# SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
# SPDX-License-Identifier: CC0-1.0
import re
from tabulate import tabulate
class ResultsFormatter:
@staticmethod
def update_memory_results_title(description):
header_start = "<!-- START: Memory Header -->"
header_end = "<!-- END: Memory Header -->"
if header_start in description and header_end in description:
return description
header_section_content = "#### Gitlab CI Memory Numbers (Do Not Edit) \n"
header_section = f"{header_start}\n{header_section_content}{header_end}"
updated_description = description.strip() + "\n\n" + header_section
return updated_description
@staticmethod
def update_static_memory_results_section(description, chip_name, example, output):
marker_start = f"<!-- START: Memory Results for {chip_name} -->"
marker_end = f"<!-- END: Memory Results for {chip_name} -->"
chip_section_content = (
f"<details><summary><b>Static Memory Footprint for target: {chip_name}, example: {example}</b></summary>\n\n"
f"```{output}```\n"
f"</details>\n"
)
chip_section = f"{marker_start}\n{chip_section_content}{marker_end}"
if marker_start in description and marker_end in description:
updated_description = re.sub(
rf"{re.escape(marker_start)}.*?{re.escape(marker_end)}",
chip_section,
description,
flags=re.DOTALL,
)
else:
updated_description = description.strip() + "\n\n" + chip_section
return updated_description
@staticmethod
def update_heap_memory_results_section(description, chip_name, example, output):
marker_start = f"<!-- START: Heap Memory Results for {chip_name} -->"
marker_end = f"<!-- END: Heap Memory Results for {chip_name} -->"
chip_section_content = (
f"<details><summary><b>Dynamic Memory Footprint for target: {chip_name}, example: {example}</b></summary>\n\n"
f"```{output}\n```\n"
f"</details>\n"
)
chip_section = f"{marker_start}\n{chip_section_content}{marker_end}"
if marker_start in description and marker_end in description:
updated_description = re.sub(
rf"{re.escape(marker_start)}.*?{re.escape(marker_end)}",
chip_section,
description,
flags=re.DOTALL,
)
else:
updated_description = description.strip() + "\n\n" + chip_section
return updated_description
@staticmethod
def format_heap_dump(parsed_logs):
headers = ["State", "Current Free Memory", "Largest Free Block", "Min. Ever Free Size"]
return tabulate(parsed_logs, headers=headers, tablefmt="grid")
@staticmethod
def update_cert_test_results_section(description, markdown_content, chunk_id=None):
# Use chunk-specific markers
marker_id = f" {chunk_id}" if chunk_id else ""
marker_start = f"<!-- START: Cert Test Results{marker_id} -->"
marker_end = f"<!-- END: Cert Test Results{marker_id} -->"
cert_section = f"{marker_start}\n{markdown_content}\n{marker_end}"
if marker_start in description and marker_end in description:
updated_description = re.sub(
rf"{re.escape(marker_start)}.*?{re.escape(marker_end)}",
cert_section,
description,
flags=re.DOTALL,
)
else:
updated_description = description.strip() + "\n\n" + cert_section
return updated_description