Add clang-format check to CI#1683
Merged
aheejin merged 7 commits intoWebAssembly:mainfrom Aug 6, 2021
Merged
Conversation
This adds clang-format check to the CI. This only checks the diff so it doesn't affect the other parts of the codebase. Also generated files in src/prebuilt/ directories are excluded from the check. A new src/prebuilt/.clang-format is added to disable the check in the directory. scripts/clang-format-diff.sh is copied from the same file we are using in Binaryen. Two clang-format errors are added to test if CI correctly errors out; one within a normal source file in src/, and the other in src/prebuilt. The latter should not be shown in the error, because the directory is excluded.
Member
Author
|
It looks the CI correct displays the clang-format error I introduced: https://github.com/WebAssembly/wabt/pull/1683/checks?check_run_id=2923646482 |
aheejin
added a commit
to aheejin/wabt
that referenced
this pull request
Jun 27, 2021
This applies clang-format to the whole codebase. I noticed we have .clang-format in wabt but the codebase is not very well formatted. This kind of mass-formatting PR has fans and skeptics because it can mess with `git blame`, but we did a similar thing in Binaryen a few years ago (WebAssembly/binaryen#2048, which was merged in WebAssembly/binaryen#2059) and it was not very confusing after all. If we are going to ever format the codebase, I think it is easier to do it in a single big PR than dozens of smaller PRs. This does not include files in src/prebuilt, because they are generated. This PR is mainly to listen to opinions and it is OK we end up not merging this. (Also even if we end up merging this, I'm not sure if I am the right person to change this many lines of code, given that I am not a frequent contributor in this repo.) I also added a clang-format check hook in the Github CI in WebAssembly#1683, which I think can be less controversial, given that it only checks the diff.
aheejin
added a commit
to aheejin/wabt
that referenced
this pull request
Jun 27, 2021
This applies clang-format to the whole codebase. I noticed we have .clang-format in wabt but the codebase is not very well formatted. This kind of mass-formatting PR has fans and skeptics because it can mess with `git blame`, but we did a similar thing in Binaryen a few years ago (WebAssembly/binaryen#2048, which was merged in WebAssembly/binaryen#2059) and it was not very confusing after all. If we are going to ever format the codebase, I think it is easier to do it in a single big PR than dozens of smaller PRs. This is using the existing .clang-format file in this repo, which follows the style of Chromium. If we think this does not suit the current formatting style, we can potentially tweak .clang-format too. For example, I noticed the current codebase puts many `case` statements within a single line when they are short, but the current .clang-format does not allow that. This does not include files in src/prebuilt, because they are generated. This also manually fixes some comment lines, because mechanically applying clang-format to long inline comments can look weird. This PR is mainly to listen to opinions and it is OK we end up not merging this. (Also even if we end up merging this, I'm not sure if I am the right person to change this many lines of code, given that I am not a frequent contributor in this repo.) I also added a clang-format check hook in the Github CI in WebAssembly#1683, which I think can be less controversial, given that it only checks the diff.
Merged
Member
Author
|
@sbc100 Can you LG this? |
sbc100
approved these changes
Aug 6, 2021
aheejin
added a commit
that referenced
this pull request
Dec 21, 2021
This applies clang-format to the whole codebase. I noticed we have .clang-format in wabt but the codebase is not very well formatted. This kind of mass-formatting PR has fans and skeptics because it can mess with `git blame`, but we did a similar thing in Binaryen a few years ago (WebAssembly/binaryen#2048, which was merged in WebAssembly/binaryen#2059) and it was not very confusing after all. If we are ever going to format the codebase, I think it is easier to do it in a single big PR than dozens of smaller PRs. This is using the existing .clang-format file in this repo, which follows the style of Chromium. If we think this does not suit the current formatting style, we can potentially tweak .clang-format too. For example, I noticed the current codebase puts many `case` statements within a single line when they are short, but the current .clang-format does not allow that. This does not include files in src/prebuilt, because they are generated. This also manually fixes some comment lines, because mechanically applying clang-format to long inline comments can look weird. I also added a clang-format check hook in the Github CI in #1683, which I think can be less controversial, given that it only checks the diff. --- After discussions, we ended up reverting many changes, especially one-liner functions and switch-cases, which are too many to wrap in `// clang-format off` and `// clang-format on`. I also considered fixing `.clang-format` to allow those one-liners but it caused a larger churn in other parts. So currently the codebase does not conform to `.clang-format` 100%, but we decided it's fine.
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This adds clang-format check to the CI. This only checks the diff so it
doesn't affect the other parts of the codebase. Also generated files in
src/prebuilt/ directories are excluded from the check. A new
src/prebuilt/.clang-format is added to disable the check in the
directory.
scripts/clang-format-diff.sh is copied from the same file we are using in
Binaryen.
Two clang-format errors are added to test if CI correctly errors out;
one within a normal source file in src/, and the other in src/prebuilt.
The latter should not be shown in the error, because the directory is
excluded. The errors will be removed before merging.