[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
Fri Mar 22 13:41:27 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/4] [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 6f2463cef42eda6e27522b888fa229af71f1ff47 Mon Sep 17 00:00:00 2001
From: Tom Stellard <tstellar at redhat.com>
Date: Fri, 22 Mar 2024 12:57:59 -0700
Subject: [PATCH 2/4] XXX: debug
---
.github/workflows/pr-code-format.yml | 1 -
1 file changed, 1 deletion(-)
diff --git a/.github/workflows/pr-code-format.yml b/.github/workflows/pr-code-format.yml
index 2ed9b05cac120f..7adca02930237d 100644
--- a/.github/workflows/pr-code-format.yml
+++ b/.github/workflows/pr-code-format.yml
@@ -34,7 +34,6 @@ jobs:
uses: actions/checkout at v4
with:
reository: ${{ github.repository }}
- ref: ${{ github.base_ref }}
sparse-checkout: |
llvm/utils/git/requirements_formatting.txt
llvm/utils/git/code-format-helper.py
>From c4e9aaf3eef69e35eb0d29b0eece66182044cff4 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 3/4] 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 7adca02930237d..1c9f78eafb2857 100644
--- a/.github/workflows/pr-code-format.yml
+++ b/.github/workflows/pr-code-format.yml
@@ -72,7 +72,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 f728b21b3d5486aebb2bf2ca9e301f1ee9a430b1 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 4/4] 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 1c9f78eafb2857..d1723cf1914da9 100644
--- a/.github/workflows/pr-code-format.yml
+++ b/.github/workflows/pr-code-format.yml
@@ -74,7 +74,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