-
Notifications
You must be signed in to change notification settings - Fork 164
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
chore: scaffolding for enabling code formatting #2038
Conversation
As you can see the format job is failing, and it has uploaded the diff in the github summary https://github.com/falcosecurity/libs/actions/runs/10618227746/artifacts/1870627029 |
Perf diff from master - unit tests
Heap diff from master - unit tests
Heap diff from master - scap file
Benchmarks diff from master
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #2038 +/- ##
=======================================
Coverage 74.31% 74.31%
=======================================
Files 253 253
Lines 30966 30966
Branches 5403 5421 +18
=======================================
Hits 23011 23011
- Misses 7942 7951 +9
+ Partials 13 4 -9
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Signed-off-by: Andrea Terzolo <andreaterzolo3@gmail.com>
65ee2da
to
9b7a066
Compare
BreakBeforeBraces: Allman | ||
BasedOnStyle: Google | ||
AccessModifierOffset: -4 | ||
BreakBeforeBraces: Attach |
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.
this would mean:
struct finfo {
file_info_t info;
char16_t filename[256];
};
Instead of:
struct finfo
{
file_info_t info;
char16_t filename[256];
};
IMO this should improve our code readability. Moreover, it would also avoid noisy frictions when we switch from other languages like Go/Rust. But this is just my opinion, let me know :)
AllowShortLoopsOnASingleLine: false | ||
BinPackArguments: false | ||
BinPackParameters: false | ||
ColumnLimit: 100 |
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.
Seems reasonable but again let me know
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.
You can see an example of our repo formatted with this style here https://github.com/Andreagit97/tmp_libs/blob/master
"_help_line_width": [ | ||
"How wide to allow formatted cmake files" | ||
], | ||
"line_width": 100, | ||
"_help_tab_size": [ | ||
"How many spaces to tab for indent" | ||
], | ||
"tab_size": 4, | ||
"_help_use_tabchars": [ | ||
"If true, lines are indented using tab characters (utf-8", | ||
"0x09) instead of <tab_size> space characters (utf-8 0x20).", | ||
"In cases where the layout would require a fractional tab", | ||
"character, the behavior of the fractional indentation is", | ||
"governed by <fractional_tab_policy>" | ||
], | ||
"use_tabchars": true, |
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.
these are the most important ones
@@ -0,0 +1,3 @@ | |||
# This commit has completely rewritten the history of file `userspace/libscap/engine/savefile/scap_savefile.c`. | |||
# https://github.com/falcosecurity/libs/commit/a6df8fc90e3be0209c5a5f9bb0443077cd5d0967 |
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.
I figured out that this commit completely overwrites the blame of userspace/libscap/engine/savefile/scap_savefile.c, so it seems reasonable to put it here
|
||
- name: Upload the git diff artifact 📦 | ||
if: failure() | ||
uses: actions/upload-artifact@v3 |
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.
at the moment we just upload the patch file.
Makefile
Outdated
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.
this should be used locally if we want to run the tools manually without pre-commit
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.
do you have in mind other files that we need to exclude?
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.
Yes all the driver syscalls tables for all architectures. Also we need to update syscalls-bumper to add the autogenerated tag to those files.
Isn't there s way to specify a lost of "DO NOT FORMAT" files in the main clang formatter config file instead? It would be much easier.
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.
when I initially worked on that 2 years ago there was no way to do that, but maybe today is our lucky day because i found this llvm/llvm-project#76327, but before saying this is a lucky day I need to check the supported clang-version for this...
Signed-off-by: Andrea Terzolo <andreaterzolo3@gmail.com>
7b0e22d
to
c466f5c
Compare
.clang-format-ignore
Outdated
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.
Thanks!
Ok now we use |
Signed-off-by: Andrea Terzolo <andreaterzolo3@gmail.com>
Added the new line config at the end of each file |
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.
/approve
This is GREAT!
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: Andreagit97, FedeDP The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
LGTM label has been added. Git tree hash: c2d923a09862a4ba71942dca24552d236f8a644c
|
What type of PR is this?
/kind feature
Any specific area of the project related to this PR?
/area CI
Does this PR require a change in the driver versions?
No
What this PR does / why we need it:
This PR is the first step to introduce code formatting in this repo.
These are the steps that I see to have code formatting ready and working on this repo.
pre-commit run --all-files
(same check used in CI)..git-blame-ignore-revs
file (this will ignore this commit in the git blame)This workstream is pretty delicate because it requires:
Since the clang-tidy support can be done at any point in time during the dev cycle, I removed its support from this PR, hoping to simplify this formatting workstream as much as possible. BTW you can see here a possible clang-tidy integration with our repo Andreagit97/tmp_libs#3 (review) (with the corresponding job https://github.com/Andreagit97/tmp_libs/blob/master/.github/workflows/lint.yml)
Which issue(s) this PR fixes:
Fixes #381
Special notes for your reviewer:
Does this PR introduce a user-facing change?: