[llvm] [workflow] Don't add a comment when the first run of the formatter passes (PR #86335)

Tom Stellard via llvm-commits llvm-commits at lists.llvm.org
Sat Mar 23 15:25:23 PDT 2024


https://github.com/tstellar updated https://github.com/llvm/llvm-project/pull/86335

>From 6538914d0b71c98db4ab7d8bffb5d60814cbaacf Mon Sep 17 00:00:00 2001
From: Tom Stellard <tstellar at redhat.com>
Date: Fri, 22 Mar 2024 12:56:00 -0700
Subject: [PATCH 1/3] [workflow] Don't add a comment when the first run of the
 formatter passes

This was inadvertently changed in
2120f574103c487787390263b3692c4b167f6bdf.
---
 llvm/utils/git/code-format-helper.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/llvm/utils/git/code-format-helper.py b/llvm/utils/git/code-format-helper.py
index af1bb3b5aec58d..f1207026704e88 100755
--- a/llvm/utils/git/code-format-helper.py
+++ b/llvm/utils/git/code-format-helper.py
@@ -124,7 +124,8 @@ def update_pr(self, comment_text: str, args: FormatArgs, create_new: bool) -> No
         existing_comment = self.find_comment(pr)
 
         if args.write_comment_to_file:
-            self.comment = {"body": comment_text}
+            if create_new or existing_comment:
+                self.comment = {"body": comment_text}
             if existing_comment:
                 self.comment["id"] = existing_comment.id
             return

>From 2f69fe4b374203f0ddc2ea9f3e10b3253dfe181b Mon Sep 17 00:00:00 2001
From: Tom Stellard <tstellar at redhat.com>
Date: Fri, 22 Mar 2024 13:33:55 -0700
Subject: [PATCH 2/3] Create empty comments file

---
 .github/workflows/pr-code-format.yml | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/.github/workflows/pr-code-format.yml b/.github/workflows/pr-code-format.yml
index 2ed9b05cac120f..f89fd6e6a47175 100644
--- a/.github/workflows/pr-code-format.yml
+++ b/.github/workflows/pr-code-format.yml
@@ -73,7 +73,9 @@ jobs:
         # to take advantage of the new --diff_from_common_commit option
         # explicitly in code-format-helper.py and not have to diff starting at
         # the merge base.
+        # Create an empty comments file so the pr-write job doesn't fail.
         run: |
+          touch comments &&
           python ./code-format-tools/llvm/utils/git/code-format-helper.py \
             --write-comment-to-file \
             --token ${{ secrets.GITHUB_TOKEN }} \

>From 4cab9590eab39983e7921e3183263078e75db7f4 Mon Sep 17 00:00:00 2001
From: Tom Stellard <tstellar at redhat.com>
Date: Fri, 22 Mar 2024 13:41:09 -0700
Subject: [PATCH 3/3] Put valid json in dummy comments file

---
 .github/workflows/pr-code-format.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.github/workflows/pr-code-format.yml b/.github/workflows/pr-code-format.yml
index f89fd6e6a47175..54dfe3aadbb423 100644
--- a/.github/workflows/pr-code-format.yml
+++ b/.github/workflows/pr-code-format.yml
@@ -75,7 +75,7 @@ jobs:
         # the merge base.
         # Create an empty comments file so the pr-write job doesn't fail.
         run: |
-          touch comments &&
+          echo "[]" > comments &&
           python ./code-format-tools/llvm/utils/git/code-format-helper.py \
             --write-comment-to-file \
             --token ${{ secrets.GITHUB_TOKEN }} \



More information about the llvm-commits mailing list