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
CI: Add git-clang-format #595
CI: Add git-clang-format #595
Conversation
Avoid bash only "[[" and "]]", access variables with curly braces and quote them.
Checkpatch is not even used in this project.
cd86c52
to
100c732
Compare
I like that we get a detailed description on how to fix any problem, but shouldn't we add to the readme.md (and/or other documentation) how to run the check locally (or actually how to contribute). It is not a very nice experience if someone makes an effort to contribute, and then get the feedback, you have erred, for something that they possible can not now beforehand. |
100c732
to
a5aa7a7
Compare
@tuve Just adapted the PR accordingly. While doing, I felt like having to add an example commit, causing the PR to grow quite a bit. You might want to check each commit separately. |
Looks fine to me |
Can you please approve the PR then? @qleisan @mlasch @sbertin-telular Any objections/feedback now, before you will be ruled by clang-format once merged? |
Go ahead! We can always tweak settings later on if something is turns out to be "wrong". |
I think we need improved documentation for running the CI tests in general and this specifically. At the very least we need a list of prerequisites. Trying to run it based on the instructions in README.md doesn't work for me:
I could probably get it to work with some effort, but right now it raises a barrier to contributing. |
+1
I'd like to go with the minimum for this PR, adding this to the readme. Everything else then as part of #586. |
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.
@sbertin-telular I had the same issue. I was missing clang-format-10
in order to get it working.
I agree, with the growing number, the prerequisites should be listed in the readme.
a5aa7a7
to
ab4ceba
Compare
I just pushed changes to fulfill this need. What do you think about it? |
I think we still need instruction for adding the git alias.
I do get output from |
ab4ceba
to
90c5d28
Compare
I needed to install one more package to get it working: |
I added to the |
@rettichschnidi I saw you added |
|
Looking at the content of clang-format-10 I can not see anything that would be missing:
But testing it within a Ubuntu 20.04 Docker container agrees with you - the package I will add it to the readme. I'd like to leave |
git-clang-format ensures that all *new* code being submitted adheres to the format dictated by clang-format. The code style is based on LLVM (the creator of clang-format), but with 4 instead of 2 spaces indent width and a maximum of 120 instead of 80 characters per line in order to blend in well with existing code. Please note: - The er-coap-13 code gets exempt, as at some point, we probably want to to interact with whatever upstream there might be. For those files, just do what existing code does (which varies every few lines). - Default is clang-format-10, which is available in the Ubuntu 20.04 GitHub runner.
I used the following script: for f in $(find . -type f \( -name '*.c' -or -name '*.h' \) \ -not -path '*/examples/shared/tinydtls/*' \ -not -path '*/coap/er-coap-13/*'); do end="$(grep --line-number --extended-regexp "\\*{70}/" "${f}" | awk -F: '{print $1}')" echo "Formatting ${f}, line 1 to ${end}" clang-format-10 -i --lines="1:${end}" "${f}" done
The last commit was purely cosmetic. Therefore, adding it to .git-blame-ignore-revs.
Doing so gives the developer feedback early on, before the changes hit the GitHub CI infrastructure. This would be a good candidate for using a Git pre-hook. Unfortunately, gitlint is a bit tricky to be used in a pre-push hook: jorisroovers/gitlint#55
90c5d28
to
132e152
Compare
@sbertin-telular Done |
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.
LGTM. Tried out latest greatest PR version and followed README.md instructions successfully
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.
LGTM
git-clang-format ensures that all new code being submitted adheres to the format dictated by clang-format.
The code style is based on LLVM (the creator of clang-format), but with 4 instead of 2 spaces indent width and a maximum of 120 instead of 80 characters per line in order to blend in well with existing code.
Please note:
Suggestions on how to test this functionality locally:
master
: