Skip to content

Commit 59084cb

Browse files
UdjinM6claude
andcommitted
ci: make clang-format check informational instead of blocking
Replace the hard CI failure with a warning annotation and a PR comment containing the formatting diff. Uses peter-evans/find-comment and create-or-update-comment to post (or update) a single collapsible comment per PR. Also bumps actions/checkout to v4. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 2f1d59e commit 59084cb

1 file changed

Lines changed: 52 additions & 4 deletions

File tree

.github/workflows/clang-diff-format.yml

Lines changed: 52 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,66 @@ on:
77
jobs:
88
ClangFormat:
99
runs-on: ubuntu-latest
10+
permissions:
11+
pull-requests: write
1012
steps:
1113
- name: Checkout
12-
uses: actions/checkout@v3
14+
uses: actions/checkout@v4
1315
- name: Fetch git
1416
run: git fetch --no-tags -fu origin develop:develop
1517
- name: Run Clang-Format-Diff.py
18+
id: clang-format
1619
run: |
1720
git diff -U0 origin/develop -- $(git ls-files -- $(cat test/util/data/non-backported.txt)) | ./contrib/devtools/clang-format-diff.py -p1 > diff_output.txt
1821
if [ -s diff_output.txt ]; then
19-
echo "Clang format differences found:"
20-
cat diff_output.txt
21-
exit 1
22+
echo "::warning::Clang format differences found. See PR comment for details."
23+
echo "has_diff=true" >> "$GITHUB_OUTPUT"
2224
else
2325
echo "No Clang format differences found."
26+
echo "has_diff=false" >> "$GITHUB_OUTPUT"
2427
fi
28+
- name: Build comment body
29+
if: steps.clang-format.outputs.has_diff == 'true'
30+
run: |
31+
{
32+
echo "<!-- clang-format-check -->"
33+
echo "⚠️ Clang Format Diff Check"
34+
echo "---"
35+
echo ""
36+
echo "Formatting issues were found in this PR."
37+
echo ""
38+
echo "<details><summary>Click to expand diff</summary>"
39+
echo ""
40+
echo '```diff'
41+
cat diff_output.txt
42+
echo '```'
43+
echo ""
44+
echo "</details>"
45+
} > comment_body.txt
46+
- name: Find existing comment
47+
uses: peter-evans/find-comment@v3
48+
id: fc
49+
with:
50+
issue-number: ${{ github.event.pull_request.number }}
51+
comment-author: 'github-actions[bot]'
52+
body-includes: '<!-- clang-format-check -->'
53+
- name: Post or update comment
54+
if: steps.clang-format.outputs.has_diff == 'true'
55+
uses: peter-evans/create-or-update-comment@v5
56+
with:
57+
comment-id: ${{ steps.fc.outputs.comment-id }}
58+
issue-number: ${{ github.event.pull_request.number }}
59+
edit-mode: replace
60+
body-path: comment_body.txt
61+
- name: Update comment as resolved
62+
if: steps.clang-format.outputs.has_diff == 'false' && steps.fc.outputs.comment-id != ''
63+
uses: peter-evans/create-or-update-comment@v5
64+
with:
65+
comment-id: ${{ steps.fc.outputs.comment-id }}
66+
edit-mode: replace
67+
body: |
68+
<!-- clang-format-check -->
69+
✅ Clang Format Diff Check
70+
---
71+
72+
No formatting issues found.

0 commit comments

Comments
 (0)