forked from abacusmodeling/abacus-develop
-
Notifications
You must be signed in to change notification settings - Fork 134
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CI: add pre-commit.ci to apply clang-format and clang-tidy fixes (#4225)
* CI: add pre-commit.ci to apply clang-format and clang-tidy fixes * do pre-commit fixes first * install clang utils * apply fixes only on changed files * fetch historical commits to get the changed files * test if pre-commit could fix sabotaged format * update pre-commit config * apply fixes * commit changes after apply them * commit changes using pre-commit.ci lite * try to fix SSL error using pre-commit.ci lite * [pre-commit.ci lite] apply automatic fixes * format arguments * add docs on pre-commit hook * Update clang-format config. ABACUS uses some functions with a long function name and a long parameter list. Current setup will generates ugly parameter list with each parameters indented by many spaces. Plus, it is unable to use a customized layout for e.g. putting x, y, and z value in the same line. After discussion, we agree to disable those settings, leaving developers free to chose their own flavor. * Update clang-tidy config. #4015 * [pre-commit.ci lite] apply automatic fixes * Update .pre-commit-config.yaml * Update .clang-tidy according to the meeting --------- Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com> Co-authored-by: Mohan Chen <[email protected]> Co-authored-by: Haozhi Han <[email protected]>
- Loading branch information
1 parent
f7a75d2
commit 10c5281
Showing
7 changed files
with
116 additions
and
67 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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 |
---|---|---|
@@ -1,35 +1,44 @@ | ||
--- | ||
Checks: ' | ||
-*, | ||
bugprone-*, | ||
clang-analyzer-*, | ||
clang-diagnostic-*, | ||
cppcoreguidelines-avoid-non-const-global-variables, | ||
cppcoreguidelines-macro-usage, | ||
cppcoreguidelines-pro-type-member-init, | ||
fuchsia-multiple-inheritance, | ||
google-*, | ||
-google-runtime-references, | ||
llvm-header-guard, | ||
misc-*, | ||
modernize-deprecated-headers, | ||
modernize-redundant-void-arg, | ||
modernize-use-nullptr, | ||
modernize-use-bool-literals, | ||
modernize-use-auto, | ||
modernize-use-std-numbers, | ||
modernize-pass-by-value, | ||
modernize-shrink-to-fit, | ||
mpi-*, | ||
performance-*, | ||
-performance-avoid-endl, | ||
readability-*, | ||
-readability-magic-numbers, | ||
-readability-isolate-declaration, | ||
-readability-braces-around-statements, | ||
-readability-implicit-bool-conversion, | ||
-google-readability-braces-around-statements, | ||
-misc-unused-parameters, | ||
modernize-use-nullptr, | ||
readability-avoid-return-with-void-value | ||
# bugprone-*, | ||
# clang-analyzer-*, | ||
# clang-diagnostic-*, | ||
# cppcoreguidelines-avoid-non-const-global-variables, | ||
# cppcoreguidelines-macro-usage, | ||
# cppcoreguidelines-pro-type-member-init, | ||
# fuchsia-multiple-inheritance, | ||
# google-*, | ||
# -google-runtime-references, | ||
# misc-*, | ||
# modernize-shrink-to-fit, | ||
# modernize-use-starts-ends-with, | ||
# mpi-*, | ||
# performance-*, | ||
# -performance-avoid-endl, | ||
# readability-*, | ||
# -readability-else-after-return, | ||
# -readability-magic-numbers, | ||
# -readability-isolate-declaration, | ||
# -readability-braces-around-statements, | ||
# -readability-implicit-bool-conversion, | ||
# -google-readability-braces-around-statements, | ||
# -misc-unused-parameters, | ||
# -modernize-pass-by-value, | ||
# -modernize-use-auto, | ||
# -google-readability-casting, | ||
# -readability-make-member-function-const, | ||
# -cppcoreguidelines-avoid-non-const-global-variables, | ||
# -readability-function-cognitive-complexity, | ||
# -google-build-using-namespace, | ||
# -bugprone-narrowing-conversions, | ||
' | ||
FormatStyle: file | ||
... |
This file contains 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 |
---|---|---|
|
@@ -21,19 +21,30 @@ jobs: | |
uses: actions/checkout@v4 | ||
with: | ||
submodules: recursive | ||
fetch-depth: 0 | ||
|
||
- name: Install Ccache | ||
- name: Install CI tools | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install -y ccache | ||
sudo apt-get install -y ccache clang-format clang-tidy ca-certificates | ||
- name: Build | ||
- name: Configure | ||
run: | | ||
cmake -B build -DBUILD_TESTING=ON -DENABLE_DEEPKS=ON -DENABLE_LIBXC=ON -DENABLE_LIBRI=ON -DENABLE_PAW=ON -DENABLE_GOOGLEBENCH=ON -DENABLE_RAPIDJSON=ON -DCMAKE_EXPORT_COMPILE_COMMANDS=1 | ||
- uses: actions/setup-python@v3 | ||
- uses: pre-commit/[email protected] | ||
with: | ||
extra_args: | ||
--from-ref ${{ github.event.pull_request.base.sha }} | ||
--to-ref ${{ github.event.pull_request.head.sha }} | ||
continue-on-error: true | ||
- uses: pre-commit-ci/[email protected] | ||
|
||
cmake -B build -DBUILD_TESTING=ON -DENABLE_DEEPKS=ON -DENABLE_LIBXC=ON -DENABLE_LIBRI=ON -DENABLE_PAW=ON -DENABLE_GOOGLEBENCH=ON -DENABLE_RAPIDJSON=ON | ||
- name: Build | ||
run: | | ||
cmake --build build -j8 | ||
cmake --install build | ||
- name: Test | ||
env: | ||
GTEST_COLOR: 'yes' | ||
|
This file contains 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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
fail_fast: false | ||
repos: | ||
- repo: https://github.com/pocc/pre-commit-hooks | ||
rev: v1.3.5 | ||
hooks: | ||
- id: clang-format | ||
args: [-i] | ||
# - id: clang-tidy | ||
# args: [-p=build, --fix-errors] | ||
# - id: oclint | ||
# - id: uncrustify | ||
# - id: cppcheck | ||
# - id: cpplint | ||
# - id: include-what-you-use |
This file contains 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
This file contains 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
This file contains 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