Skip to content

Commit 166a570

Browse files
committed
[WIP] Formatting suggestions in CI
1 parent 2837370 commit 166a570

File tree

3 files changed

+21
-8
lines changed

3 files changed

+21
-8
lines changed

.github/workflows/pr-code-format.yml

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
name: "Check code formatting"
22

33
permissions:
4-
contents: read
4+
contents: write
5+
pull-requests: write
6+
repository-projects: write
57

68
on:
79
pull_request:
@@ -37,8 +39,8 @@ jobs:
3739
- name: Fetch code formatting utils
3840
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
3941
with:
40-
repository: ${{ github.repository }}
41-
ref: ${{ github.base_ref }}
42+
repository: localspook/llvm-project
43+
ref: ${{ github.event.pull_request.head.ref }}
4244
sparse-checkout: |
4345
llvm/utils/git/requirements_formatting.txt
4446
llvm/utils/git/code-format-helper.py
@@ -71,6 +73,7 @@ jobs:
7173
run: pip install -r code-format-tools/llvm/utils/git/requirements_formatting.txt
7274

7375
- name: Run code formatter
76+
id: run-code-formatter
7477
env:
7578
GITHUB_PR_NUMBER: ${{ github.event.pull_request.number }}
7679
CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
@@ -91,3 +94,10 @@ jobs:
9194
name: workflow-args
9295
path: |
9396
comments
97+
98+
- uses: parkerbxyz/suggest-changes@00f556dcc0c9454336b598b8872fdc11d77984d9 #v3.0.0
99+
if: failure()
100+
with:
101+
token: ${{ secrets.GITHUB_TOKEN }}
102+
comment: "Formatting can be fixed by applying the following changes:"
103+
event: "REQUEST_CHANGES"

clang-tools-extra/clang-tidy/ClangTidy.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -491,8 +491,11 @@ std::vector<std::string> ClangTidyASTConsumerFactory::getCheckNames() {
491491
ClangTidyOptions::OptionMap ClangTidyASTConsumerFactory::getCheckOptions() {
492492
ClangTidyOptions::OptionMap Options;
493493
std::vector<std::unique_ptr<ClangTidyCheck>> Checks =
494-
CheckFactories->createChecks(&Context);
495-
for (const auto &Check : Checks)
494+
CheckFactories->createChecks
495+
(&Context);
496+
for (const
497+
498+
auto &Check : Checks)
496499
Check->storeOptions(Options);
497500
return Options;
498501
}

llvm/utils/git/code-format-helper.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,10 +182,10 @@ class ClangFormatHelper(FormatHelper):
182182
friendly_name = "C/C++ code formatter"
183183

184184
def _construct_command(self, diff_expression: list[str] | None):
185-
cf_cmd = [self.clang_fmt_path, "--diff"]
185+
cf_cmd = [self.clang_fmt_path, "HEAD~1"]
186186

187-
if diff_expression:
188-
cf_cmd.extend(diff_expression)
187+
# if diff_expression:
188+
# cf_cmd.extend(diff_expression)
189189

190190
# Gather the extension of all modified files and pass them explicitly to git-clang-format.
191191
# This prevents git-clang-format from applying its own filtering rules on top of ours.

0 commit comments

Comments
 (0)