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
core: Add coding style enforcement and update selected code areas #8595
Conversation
.clang-format
Outdated
# git grep -h '^#define [^[:space:]]*for_each[^[:space:]]*(' include/ tools/ \ | ||
# | sed "s,^#define \([^[:space:]]*for_each[^[:space:]]*\)(.*$, - '\1'," \ | ||
# | LC_ALL=C sort -u | ||
ForEachMacros: |
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'm guessing these are kernel macros that can be removed from this 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.
Agree. We can add our own foreach macros defined in ofi_list.h
.
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.
done
Some providers will never pass these checks. |
I formatted every provider in this PR with Do we like this idea? |
Err.. apparently I messed it up a bit... but will fix |
I don't want to reformat all existing providers or force those providers to a specific coding style. This needs to be more selective. I want loosely enforced style for any of the core code, plus specific providers that are close to following the standard (tcp, ucx, shm, util, udp, verbs, rxm, rxd, mrail). I would not modify psmX, opx, bqg, or gni. And there's 0 chance of anyone reviewing a 100k line patch. |
Btw, these sort of changes end up making it difficult to cherry-pick patches to stable branches. |
@shefty Would you be ok with me adding this... and only modifying include and source? |
and we can have separate PR's for each provider who wants to opt-in... we can choose which directories the CI checker looks in too (so we can keep that) |
I think the long term benefits of not wasting time on style comments outweigh the temporary pain of a few hard re-bases. |
Signed-off-by: Seth Zegelstein <szegel@amazon.com>
89cd20d
to
3441cad
Compare
something is wrong with how I setup the clang format file, or how I am calling clang-format |
after spinning up an ubuntu instance and running clang, format with no changes... it is the job that is broken |
Signed-off-by: Seth Zegelstein <szegel@amazon.com>
Signed-off-by: Seth Zegelstein <szegel@amazon.com>
CI was using clang format version 13, I was using clang format version 14... apparently version matters |
@@ -0,0 +1,121 @@ | |||
# copied from: https://github.com/torvalds/linux/blob/master/.clang-format | |||
# | |||
# SPDX-License-Identifier: GPL-2.0 |
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.
Can we include with GPL-2.0 license?
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.
No - we need dual license or one usable with BSD., such as MIT.
Let's leave this as-is and discuss in next week's ofiwg call to get more input. |
Mon opinion probably doesn't matter much, but the fact that the PR breaks cherry-picking is definitely a big concern. It's not only about "a few rebases" as you say.
If your concern is about detecting coding style issues during reviews, why not implement a GitHub action that would do a quick check on the lines changed by the PR when it's submitted? |
I agree with @sydidelot and @shefty. Furthermore, I don't think giving formatting comments at reviewing time is a bad thing. It helps people proactively adopt the recommended coding style instead of relying on automatic tools. |
From the ofiwg: There's not support for widespread updates to the code formatting. People are okay with having a check per PR to verify the formatting, as long as we can ignore the results and still commit changes. (So, we don't end up with weird formatting trying to force a coding style on part of a function that has a different style.) |
Can I get rid of the formatting commit and keep the CI + the file? What do we want to do about the license? |
Yes, the consensus was that that would be acceptable. We would need a new version of the file without the GPL only license, which means creating our own, basically from scratch, unless you can find another project or base template that's usable. |
We can generate a template format file using a command similar to this:
There are a few options for We could start with a fairly minimal set and expand as needed. |
I am going to make SM2 the first provider to follow these rules.... Will re-open this when I am ready |
Lets enforce a style guide across the project to save everyone time (no more giving or getting formatting comments).
Adds the clang format file from linux kernel.
Adds CI to make sure future PR's are formatted (tested on this PR, it works).
Formatted all files in the project.
To format the entire project:
To format just the files you have changed: