Skip to content

Commit 8e628c4

Browse files
Merge #7263: ci: replace PR comment with job summary for clang-format check
1682e71 ci: fix grep pattern to match literal parentheses in BRE (UdjinM6) eb7554a ci: replace PR comment with job summary for clang-format check (UdjinM6) Pull request description: ## Issue being fixed or feature implemented The PR comment approach #7251 fails on fork PRs because `pull_request` events get a read-only `GITHUB_TOKEN`. Switching to `pull_request_target` #7262 would fix permissions but introduces its own issues: the checkout is the base branch so `git ls-files` misses files added by the PR, and the three-dot merge-base diff requires deeper clone history. ## What was done? Keep `pull_request` (correct checkout, full file coverage), remove the comment machinery, and write a short summary to `GITHUB_STEP_SUMMARY`. The full diff remains visible in the job log. ## How Has This Been Tested? ## Breaking Changes ## Checklist: - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have added or updated relevant unit/integration/functional/e2e tests - [ ] I have made corresponding changes to the documentation - [ ] I have assigned this pull request to a milestone _(for repository code-owners and collaborators only)_ ACKs for top commit: PastaPastaPasta: utACK 1682e71 Tree-SHA512: e1b9a1e5a6af6e40492cd611a7af8bde0ee8c7681f76df742725d30fd78fdb100347ee5f9d8181d3021dccaf7242b06a53a21c187339cd8aa090518212490938
2 parents 8a9522f + 1682e71 commit 8e628c4

1 file changed

Lines changed: 5 additions & 54 deletions

File tree

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

Lines changed: 5 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -7,69 +7,20 @@ on:
77
jobs:
88
ClangFormat:
99
runs-on: ubuntu-latest
10-
permissions:
11-
pull-requests: write
1210
steps:
1311
- name: Checkout
1412
uses: actions/checkout@v6
1513
- name: Fetch git
1614
run: git fetch --no-tags -fu origin develop:develop
1715
- name: Run Clang-Format-Diff.py
18-
id: clang-format
1916
run: |
2017
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
2118
if [ -s diff_output.txt ]; then
22-
echo "::warning::Clang format differences found. See PR comment for details."
23-
echo "has_diff=true" >> "$GITHUB_OUTPUT"
19+
echo "Clang format differences found:"
20+
cat diff_output.txt
21+
file_count=$(grep -c '^--- .*(before formatting)' diff_output.txt || true)
22+
echo "## ℹ️ Clang Format Style Notes" >> "$GITHUB_STEP_SUMMARY"
23+
echo "Formatting differences found in ${file_count} file(s). See job log for details." >> "$GITHUB_STEP_SUMMARY"
2424
else
2525
echo "No Clang format differences found."
26-
echo "has_diff=false" >> "$GITHUB_OUTPUT"
2726
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)