mirror of
https://github.com/esphome/esphome.git
synced 2025-10-21 11:13:46 +01:00
update test
This commit is contained in:
@@ -371,15 +371,16 @@ def main():
|
|||||||
|
|
||||||
idedata = None
|
idedata = None
|
||||||
for idedata_path in idedata_candidates:
|
for idedata_path in idedata_candidates:
|
||||||
if idedata_path.exists():
|
if not idedata_path.exists():
|
||||||
try:
|
continue
|
||||||
with open(idedata_path, encoding="utf-8") as f:
|
try:
|
||||||
raw_data = json.load(f)
|
with open(idedata_path, encoding="utf-8") as f:
|
||||||
idedata = IDEData(raw_data)
|
raw_data = json.load(f)
|
||||||
print(f"Loaded idedata from: {idedata_path}", file=sys.stderr)
|
idedata = IDEData(raw_data)
|
||||||
break
|
print(f"Loaded idedata from: {idedata_path}", file=sys.stderr)
|
||||||
except (json.JSONDecodeError, OSError) as e:
|
break
|
||||||
print(f"Warning: Failed to load idedata: {e}", file=sys.stderr)
|
except (json.JSONDecodeError, OSError) as e:
|
||||||
|
print(f"Warning: Failed to load idedata: {e}", file=sys.stderr)
|
||||||
|
|
||||||
if not idedata:
|
if not idedata:
|
||||||
print(
|
print(
|
||||||
|
@@ -409,6 +409,54 @@ def find_existing_comment(pr_number: str) -> str | None:
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
def update_existing_comment(comment_id: str, comment_body: str) -> None:
|
||||||
|
"""Update an existing comment.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
comment_id: Comment ID to update
|
||||||
|
comment_body: New comment body text
|
||||||
|
|
||||||
|
Raises:
|
||||||
|
subprocess.CalledProcessError: If gh command fails
|
||||||
|
"""
|
||||||
|
print(f"DEBUG: Updating existing comment {comment_id}", file=sys.stderr)
|
||||||
|
result = subprocess.run(
|
||||||
|
[
|
||||||
|
"gh",
|
||||||
|
"api",
|
||||||
|
f"/repos/{{owner}}/{{repo}}/issues/comments/{comment_id}",
|
||||||
|
"-X",
|
||||||
|
"PATCH",
|
||||||
|
"-f",
|
||||||
|
f"body={comment_body}",
|
||||||
|
],
|
||||||
|
check=True,
|
||||||
|
capture_output=True,
|
||||||
|
text=True,
|
||||||
|
)
|
||||||
|
print(f"DEBUG: Update response: {result.stdout}", file=sys.stderr)
|
||||||
|
|
||||||
|
|
||||||
|
def create_new_comment(pr_number: str, comment_body: str) -> None:
|
||||||
|
"""Create a new PR comment.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
pr_number: PR number
|
||||||
|
comment_body: Comment body text
|
||||||
|
|
||||||
|
Raises:
|
||||||
|
subprocess.CalledProcessError: If gh command fails
|
||||||
|
"""
|
||||||
|
print(f"DEBUG: Posting new comment on PR #{pr_number}", file=sys.stderr)
|
||||||
|
result = subprocess.run(
|
||||||
|
["gh", "pr", "comment", pr_number, "--body", comment_body],
|
||||||
|
check=True,
|
||||||
|
capture_output=True,
|
||||||
|
text=True,
|
||||||
|
)
|
||||||
|
print(f"DEBUG: Post response: {result.stdout}", file=sys.stderr)
|
||||||
|
|
||||||
|
|
||||||
def post_or_update_comment(pr_number: str, comment_body: str) -> None:
|
def post_or_update_comment(pr_number: str, comment_body: str) -> None:
|
||||||
"""Post a new comment or update existing one.
|
"""Post a new comment or update existing one.
|
||||||
|
|
||||||
@@ -423,39 +471,9 @@ def post_or_update_comment(pr_number: str, comment_body: str) -> None:
|
|||||||
existing_comment_id = find_existing_comment(pr_number)
|
existing_comment_id = find_existing_comment(pr_number)
|
||||||
|
|
||||||
if existing_comment_id and existing_comment_id != "None":
|
if existing_comment_id and existing_comment_id != "None":
|
||||||
# Update existing comment
|
update_existing_comment(existing_comment_id, comment_body)
|
||||||
print(
|
|
||||||
f"DEBUG: Updating existing comment {existing_comment_id}",
|
|
||||||
file=sys.stderr,
|
|
||||||
)
|
|
||||||
result = subprocess.run(
|
|
||||||
[
|
|
||||||
"gh",
|
|
||||||
"api",
|
|
||||||
f"/repos/{{owner}}/{{repo}}/issues/comments/{existing_comment_id}",
|
|
||||||
"-X",
|
|
||||||
"PATCH",
|
|
||||||
"-f",
|
|
||||||
f"body={comment_body}",
|
|
||||||
],
|
|
||||||
check=True,
|
|
||||||
capture_output=True,
|
|
||||||
text=True,
|
|
||||||
)
|
|
||||||
print(f"DEBUG: Update response: {result.stdout}", file=sys.stderr)
|
|
||||||
else:
|
else:
|
||||||
# Post new comment
|
create_new_comment(pr_number, comment_body)
|
||||||
print(
|
|
||||||
f"DEBUG: Posting new comment (existing_comment_id={existing_comment_id})",
|
|
||||||
file=sys.stderr,
|
|
||||||
)
|
|
||||||
result = subprocess.run(
|
|
||||||
["gh", "pr", "comment", pr_number, "--body", comment_body],
|
|
||||||
check=True,
|
|
||||||
capture_output=True,
|
|
||||||
text=True,
|
|
||||||
)
|
|
||||||
print(f"DEBUG: Post response: {result.stdout}", file=sys.stderr)
|
|
||||||
|
|
||||||
print("Comment posted/updated successfully", file=sys.stderr)
|
print("Comment posted/updated successfully", file=sys.stderr)
|
||||||
|
|
||||||
|
@@ -25,6 +25,8 @@ import sys
|
|||||||
sys.path.insert(0, str(Path(__file__).parent.parent))
|
sys.path.insert(0, str(Path(__file__).parent.parent))
|
||||||
|
|
||||||
# pylint: disable=wrong-import-position
|
# pylint: disable=wrong-import-position
|
||||||
|
from esphome.analyze_memory import MemoryAnalyzer
|
||||||
|
from esphome.platformio_api import IDEData
|
||||||
from script.ci_helpers import write_github_output
|
from script.ci_helpers import write_github_output
|
||||||
|
|
||||||
# Regex patterns for extracting memory usage from PlatformIO output
|
# Regex patterns for extracting memory usage from PlatformIO output
|
||||||
@@ -85,9 +87,6 @@ def run_detailed_analysis(build_dir: str) -> dict | None:
|
|||||||
Returns:
|
Returns:
|
||||||
Dictionary with analysis results or None if analysis fails
|
Dictionary with analysis results or None if analysis fails
|
||||||
"""
|
"""
|
||||||
from esphome.analyze_memory import MemoryAnalyzer
|
|
||||||
from esphome.platformio_api import IDEData
|
|
||||||
|
|
||||||
build_path = Path(build_dir)
|
build_path = Path(build_dir)
|
||||||
if not build_path.exists():
|
if not build_path.exists():
|
||||||
print(f"Build directory not found: {build_dir}", file=sys.stderr)
|
print(f"Build directory not found: {build_dir}", file=sys.stderr)
|
||||||
@@ -120,18 +119,19 @@ def run_detailed_analysis(build_dir: str) -> dict | None:
|
|||||||
|
|
||||||
idedata = None
|
idedata = None
|
||||||
for idedata_path in idedata_candidates:
|
for idedata_path in idedata_candidates:
|
||||||
if idedata_path.exists():
|
if not idedata_path.exists():
|
||||||
try:
|
continue
|
||||||
with open(idedata_path, encoding="utf-8") as f:
|
try:
|
||||||
raw_data = json.load(f)
|
with open(idedata_path, encoding="utf-8") as f:
|
||||||
idedata = IDEData(raw_data)
|
raw_data = json.load(f)
|
||||||
print(f"Loaded idedata from: {idedata_path}", file=sys.stderr)
|
idedata = IDEData(raw_data)
|
||||||
break
|
print(f"Loaded idedata from: {idedata_path}", file=sys.stderr)
|
||||||
except (json.JSONDecodeError, OSError) as e:
|
break
|
||||||
print(
|
except (json.JSONDecodeError, OSError) as e:
|
||||||
f"Warning: Failed to load idedata from {idedata_path}: {e}",
|
print(
|
||||||
file=sys.stderr,
|
f"Warning: Failed to load idedata from {idedata_path}: {e}",
|
||||||
)
|
file=sys.stderr,
|
||||||
|
)
|
||||||
|
|
||||||
analyzer = MemoryAnalyzer(elf_path, idedata=idedata)
|
analyzer = MemoryAnalyzer(elf_path, idedata=idedata)
|
||||||
components = analyzer.analyze()
|
components = analyzer.analyze()
|
||||||
|
Reference in New Issue
Block a user