-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[WIP] Formatting suggestions in CI #158779
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
b5faa24
to
5a51327
Compare
@llvm/pr-subscribers-clang-tidy @llvm/pr-subscribers-github-workflow Author: Victor Chernyakin (localspook) ChangesFull diff: https://github.com/llvm/llvm-project/pull/158779.diff 2 Files Affected:
diff --git a/.github/workflows/pr-code-format.yml b/.github/workflows/pr-code-format.yml
index 9396bf019e1ac..607b6cf3bdfb0 100644
--- a/.github/workflows/pr-code-format.yml
+++ b/.github/workflows/pr-code-format.yml
@@ -2,6 +2,7 @@ name: "Check code formatting"
permissions:
contents: read
+ pull-requests: write
on:
pull_request:
@@ -71,6 +72,7 @@ jobs:
run: pip install -r code-format-tools/llvm/utils/git/requirements_formatting.txt
- name: Run code formatter
+ id: run-code-formatter
env:
GITHUB_PR_NUMBER: ${{ github.event.pull_request.number }}
CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
@@ -91,3 +93,9 @@ jobs:
name: workflow-args
path: |
comments
+
+ - uses: parkerbxyz/suggest-changes@00f556dcc0c9454336b598b8872fdc11d77984d9 #v3.0.0
+ if: steps.run-code-formatter.outcome == "failure"
+ with:
+ comment: "Formatting can be fixed by applying the following changes:"
+ event: "REQUEST_CHANGES"
diff --git a/clang-tools-extra/clang-tidy/ClangTidy.cpp b/clang-tools-extra/clang-tidy/ClangTidy.cpp
index 4c36bbccf44d9..ca50e9bffd591 100644
--- a/clang-tools-extra/clang-tidy/ClangTidy.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidy.cpp
@@ -491,8 +491,11 @@ std::vector<std::string> ClangTidyASTConsumerFactory::getCheckNames() {
ClangTidyOptions::OptionMap ClangTidyASTConsumerFactory::getCheckOptions() {
ClangTidyOptions::OptionMap Options;
std::vector<std::unique_ptr<ClangTidyCheck>> Checks =
- CheckFactories->createChecks(&Context);
- for (const auto &Check : Checks)
+ CheckFactories->createChecks
+ (&Context);
+ for (const
+
+ auto &Check : Checks)
Check->storeOptions(Options);
return Options;
}
|
10fcc7b
to
f77b63d
Compare
You can test this locally with the following command:git-clang-format HEAD~1 --extensions cpp -- clang-tools-extra/clang-tidy/ClangTidy.cpp
View the diff from clang-format here.changed files:
clang-tools-extra/clang-tidy/ClangTidy.cpp
|
6dfbfde
to
f42346f
Compare
f42346f
to
166a570
Compare
|
||
permissions: | ||
contents: read | ||
contents: write |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The base permission is "read" due to security concerns. There is a different job that reads output from "comments" file and posts giithub comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"issue-write.yaml"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, I saw in the debug output that the token only had read permissions, but I really couldn’t understand how, despite that, the workflow was able to create comments
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually LLM's can do a pretty good job finding this. I had the same question and claude code found it and explained very quickly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe free-ones with code knowledge like deepwiki can do it too.
No description provided.