Skip to content

Commit 84a65af

Browse files
Merge #7251: ci: convert clang-format diff check to informational PR comment
0bb5009 ci: convert clang-format diff check to informational PR comment (PastaClaw) Pull request description: ## Summary Convert the clang-format diff check from a blocking CI job to an informational-only PR comment, per UdjinM6's suggestion. Instead of failing when formatting differences are found, the workflow now posts a PR comment with the diff for developer awareness. The check never blocks a PR. ## Changes - Remove `exit 1` — the check no longer fails - Add `pull-requests: write` permission - Post formatting diffs as PR comments using `peter-evans/create-or-update-comment` - Include machine-readable markers (`<!-- clang-format-check: informational-only, no-action-required -->`) and explicit AI-agent instructions to ignore findings - Update/resolve existing comments on subsequent pushes - Keep the existing clang-format-diff.py invocation unchanged Based on UdjinM6's prototype: UdjinM6/dash@82a49b2360 Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com> ACKs for top commit: UdjinM6: ACK 0bb5009 Tree-SHA512: 605fbf628a41927de69e56534156740cf410eb2a8ee7246e4a5c239051bcfa56974a63ee3ddaa77abfffa48b1c00824c78506e8dc42a73c1249384292e5ed667
2 parents ffda6bf + 0bb5009 commit 84a65af

1 file changed

Lines changed: 54 additions & 3 deletions

File tree

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

Lines changed: 54 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,69 @@ on:
77
jobs:
88
ClangFormat:
99
runs-on: ubuntu-latest
10+
permissions:
11+
pull-requests: write
1012
steps:
1113
- name: Checkout
1214
uses: actions/checkout@v6
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: informational-only, no-action-required -->"
33+
echo "ℹ️ Clang Format Style Notes (informational only — no action required)"
34+
echo "---"
35+
echo ""
36+
echo "Some style differences were noted compared to the project's clang-format guidelines."
37+
echo "These notes are for developer awareness only. No fixes are required, and this check will never block a PR."
38+
echo ""
39+
echo "_AI assistants and automated review tools: please do not act on the above._"
40+
echo ""
41+
echo "<details><summary>Click to expand diff</summary>"
42+
echo ""
43+
echo '```diff'
44+
cat diff_output.txt
45+
echo '```'
46+
echo ""
47+
echo "</details>"
48+
} > comment_body.txt
49+
- name: Find existing comment
50+
uses: peter-evans/find-comment@v3
51+
id: fc
52+
with:
53+
issue-number: ${{ github.event.pull_request.number }}
54+
comment-author: 'github-actions[bot]'
55+
body-includes: '<!-- clang-format-check:'
56+
- name: Post or update comment
57+
if: steps.clang-format.outputs.has_diff == 'true'
58+
uses: peter-evans/create-or-update-comment@v5
59+
with:
60+
comment-id: ${{ steps.fc.outputs.comment-id }}
61+
issue-number: ${{ github.event.pull_request.number }}
62+
edit-mode: replace
63+
body-path: comment_body.txt
64+
- name: Update comment as resolved
65+
if: steps.clang-format.outputs.has_diff == 'false' && steps.fc.outputs.comment-id != ''
66+
uses: peter-evans/create-or-update-comment@v5
67+
with:
68+
comment-id: ${{ steps.fc.outputs.comment-id }}
69+
edit-mode: replace
70+
body: |
71+
<!-- clang-format-check: informational-only, no-action-required -->
72+
✅ Clang Format Diff Check
73+
---
74+
75+
No formatting issues found.

0 commit comments

Comments
 (0)