-
Notifications
You must be signed in to change notification settings - Fork 19
[WIP] CI checks improvement: add clang-format check #7
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
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,6 +7,26 @@ on: | |
| branches: [ main ] | ||
|
|
||
| jobs: | ||
| lint: | ||
| name: Lint C++ | ||
| runs-on: ubuntu-24.04 | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v3 | ||
neatudarius marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| - name: Install Clang Format | ||
| run: | | ||
| sudo apt-get update | ||
| sudo apt-get install clang-format | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. clang-format gets stale fast for contemporary C++, we should make sure we're getting a current one. |
||
|
|
||
| - name: Run Clang Format | ||
| run: | | ||
| git diff --name-only main | grep -E '\.(h|hpp|hxx|c|cpp|cxx)$' | xargs clang-format -i | ||
|
|
||
| - name: Check Clang Format | ||
| run: | | ||
| git diff --name-only main | grep -E '\.(h|hpp|hxx|c|cpp|cxx)$' | xargs clang-format -output-replacements-xml | grep "<replacement " && exit 1 || exit 0 | ||
|
|
||
| build: | ||
| name: ${{ matrix.config.name }} | ||
| runs-on: ${{ matrix.config.os }} | ||
|
|
@@ -17,30 +37,30 @@ jobs: | |
| matrix: | ||
| config: | ||
| - { | ||
| name: "Ubuntu Clang 17", | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For consistency with other blocks in the file. |
||
| os: ubuntu-24.04, | ||
| toolchain: "clang-17-toolchain.cmake", | ||
| clang_version: 17, | ||
| installed_clang_version: 14, | ||
| cmake_args: "-G \"Ninja Multi-Config\" -DCMAKE_CONFIGURATION_TYPES=\"RelWithDebInfo;Asan\" " | ||
| name: "Ubuntu Clang 17", | ||
| os: ubuntu-24.04, | ||
| toolchain: "clang-17-toolchain.cmake", | ||
| clang_version: 17, | ||
| installed_clang_version: 14, | ||
| cmake_args: "-G \"Ninja Multi-Config\" -DCMAKE_CONFIGURATION_TYPES=\"RelWithDebInfo;Asan\" " | ||
| } | ||
|
|
||
| - { | ||
| name: "Ubuntu Clang 18", | ||
| os: ubuntu-24.04, | ||
| toolchain: "clang-18-toolchain.cmake", | ||
| clang_version: 18, | ||
| installed_clang_version: 14, | ||
| cmake_args: "-G \"Ninja Multi-Config\" -DCMAKE_CONFIGURATION_TYPES=\"RelWithDebInfo;Asan\" " | ||
| name: "Ubuntu Clang 18", | ||
| os: ubuntu-24.04, | ||
| toolchain: "clang-18-toolchain.cmake", | ||
| clang_version: 18, | ||
| installed_clang_version: 14, | ||
| cmake_args: "-G \"Ninja Multi-Config\" -DCMAKE_CONFIGURATION_TYPES=\"RelWithDebInfo;Asan\" " | ||
| } | ||
|
|
||
| - { | ||
| name: "Ubuntu Clang 19", | ||
| os: ubuntu-24.04, | ||
| toolchain: "clang-19-toolchain.cmake", | ||
| clang_version: 19, | ||
| installed_clang_version: 14, | ||
| cmake_args: "-G \"Ninja Multi-Config\" -DCMAKE_CONFIGURATION_TYPES=\"RelWithDebInfo;Asan\" " | ||
| name: "Ubuntu Clang 19", | ||
| os: ubuntu-24.04, | ||
| toolchain: "clang-19-toolchain.cmake", | ||
| clang_version: 19, | ||
| installed_clang_version: 14, | ||
| cmake_args: "-G \"Ninja Multi-Config\" -DCMAKE_CONFIGURATION_TYPES=\"RelWithDebInfo;Asan\" " | ||
| } | ||
|
|
||
| - { | ||
|
|
@@ -95,14 +115,12 @@ jobs: | |
| sudo ./llvm.sh ${{matrix.config.clang_version}} all | ||
| sudo apt-get install libc++-dev libc++1 libc++abi-dev libc++abi1 | ||
|
|
||
|
|
||
| - name: Install GCC 14 | ||
| if: matrix.config.name == 'Ubuntu GCC 14' | ||
| run: | | ||
| sudo apt update | ||
| sudo apt-get install g++-14 | ||
|
|
||
|
|
||
| - name: Configure | ||
| run: | | ||
| mkdir -p .build | ||
|
|
||
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.
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 https://cpp-linter.github.io/cpp-linter-action/ might be a friendlier linter interface?
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 tried your suggestion. I couldn't make it work and also it uses clang-12 https://github.com/beman-project/Optional26/actions/runs/9494415629/job/26164716972 :( .
I was also thinking about an market Git action, but then I realized this doesn't help me to apply changes locally. Do you think it's better to have a script (e.g.,
lint-all.sh- cpp, sh, md, yaml etc) and be able to run locally and from github workflow?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 talking with some other developers locally about how they handle this for public github projects. We have a much nicer internal workflow tool, of course.
The weak consensus seems to be that for clang-format it's hard to justify a separate action that needs to build a docker image, and it's better to get the clang-format that you want, and then apply something like https://github.com/bloomberg/blazingmq/blob/d3bf9637db34a91455c9d83354c4844c178c3f1e/.github/workflows/formatting-check.yaml#L22
Which is hard coded to clang-format-14 which is so ancient it may not understand C++ anymore. But we've already got some infrastructure for getting LLVM current added.
clang-tidy may be more complicated, since it often needs review to confirm applicability? One suggestion has been
https://github.com/marketplace/actions/clang-tidy-review
Which does allow current clang-tidy to be used.
Making anything we do in automated checks something that can be straightforwardly done locally is important to me, as well. There's little as frustrating as finding out 30 minutes later that you've done something that would have been trivial to fix as you were coding it. Shifting left in the business process vernacular.