Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: comment is duplicated on dry runs and not dry runs #2897

Merged
merged 1 commit into from
Jan 22, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 17 additions & 10 deletions .github/scripts/tests/generate-summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import argparse
import dataclasses
import os
import re
import json
import sys
from github import Github, Auth as GithubAuth
Expand Down Expand Up @@ -360,20 +359,21 @@ def update_pr_comment(
test_history_url: str,
is_dry_run: bool,
):
header = f"<!-- status pr={pr.number}, run={{}} -->"
header_re = re.compile(header.format(r"(\d+)"))
header = f"<!-- status pr={pr.number}, run={run_number}, build_preset={build_preset}, dry_run={is_dry_run} -->"

body = None
comment = None

for c in pr.get_issue_comments():
if matches := header_re.match(c.body):
if int(matches[1]) == run_number:
body = [c.body, "", "---", ""]
if c.body.startswith(header):
print(f"Found comment with id={c.id}")
comment = c
body = [c.body]
break

if body is None:
body = [
header.format(run_number),
]
body = [header]

if is_dry_run:
body.extend(
[
Expand All @@ -389,12 +389,19 @@ def update_pr_comment(
"",
]
)
else:
body.extend(["", ""])

body.extend(get_comment_text(pr, summary, build_preset, test_history_url))

body = "\n".join(body)

pr.create_issue_comment(body)
if comment is None:
print("Creating new comment")
pr.create_issue_comment(body)
else:
print("Updating existing comment")
comment.edit(body)


def main():
Expand Down
Loading