diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..f01f570 --- /dev/null +++ b/.clang-format @@ -0,0 +1,10 @@ +# Our style is based on the Google style +# https://google.github.io/styleguide/cppguide.html +BasedOnStyle: Google + +# we use left pointer alignment +DerivePointerAlignment: false +PointerAlignment: Left + +IndentWidth: 4 +ColumnLimit: 110 diff --git a/.cmake-format.yaml b/.cmake-format.yaml new file mode 100644 index 0000000..5b703c9 --- /dev/null +++ b/.cmake-format.yaml @@ -0,0 +1,6 @@ +# https://cmake-format.readthedocs.io/en/latest/configuration.html + +format: + tab_size: 4 + separate_ctrl_name_with_space: true + separate_fn_name_with_space: false diff --git a/.github/workflows/validation.yml b/.github/workflows/validation.yml index e6412a8..989e01c 100644 --- a/.github/workflows/validation.yml +++ b/.github/workflows/validation.yml @@ -34,10 +34,13 @@ jobs: with: cmake-flags: "-DCMAKE_INSTALL_PREFIX=${{ env.REST_PATH }} -DCMAKE_BUILD_TYPE=${{ env.CMAKE_BUILD_TYPE }} -DREST_WELCOME=ON -DRESTLIB_WIMP=ON" branch: ${{ env.BRANCH_NAME }} + - name: Verify pre-commit config files match + run: | + cd $GITHUB_WORKSPACE + curl https://raw.githubusercontent.com/rest-for-physics/framework/master/scripts/validatePreCommitConfig.py | python - name: Cache framework installation id: wimplib-install-cache uses: actions/cache@v3 with: key: ${{ env.BRANCH_NAME }}-${{ github.sha }} path: ${{ env.REST_PATH }} - diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..87c5b7f --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,35 @@ +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.4.0 + hooks: + - id: check-added-large-files + - id: check-case-conflict + - id: check-merge-conflict + - id: check-symlinks + - id: check-yaml + - id: check-xml + - id: requirements-txt-fixer + - id: end-of-file-fixer + exclude: external/.*$ + - id: mixed-line-ending + exclude: external/.*$ + - id: trailing-whitespace + exclude: external/.*$ + + - repo: https://github.com/pre-commit/mirrors-clang-format + rev: v15.0.6 + hooks: + - id: clang-format + exclude: external/.*$ + + - repo: https://github.com/cheshirekow/cmake-format-precommit + rev: v0.6.13 + hooks: + - id: cmake-format + additional_dependencies: [ pyyaml ] + # - id: cmake-lint + + - repo: https://github.com/psf/black + rev: 22.12.0 + hooks: + - id: black diff --git a/CMakeLists.txt b/CMakeLists.txt index b0fdb85..aaf8c77 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,12 +1,12 @@ set(LibraryVersion "1.0") add_definitions(-DLIBRARY_VERSION="${LibraryVersion}") -COMPILELIB("") +compilelib("") file(GLOB_RECURSE MAC "${CMAKE_CURRENT_SOURCE_DIR}/macros/*") -INSTALL(FILES ${MAC} DESTINATION ./macros/wimp) +install(FILES ${MAC} DESTINATION ./macros/wimp) file(GLOB_RECURSE MAC "${CMAKE_CURRENT_SOURCE_DIR}/examples/*") -INSTALL(FILES ${MAC} DESTINATION ./examples/wimp) +install(FILES ${MAC} DESTINATION ./examples/wimp) -ADD_LIBRARY_TEST() +add_library_test() diff --git a/inc/TRestWimpNucleus.h b/inc/TRestWimpNucleus.h index b1efc65..de2267a 100644 --- a/inc/TRestWimpNucleus.h +++ b/inc/TRestWimpNucleus.h @@ -23,10 +23,10 @@ #ifndef RestCore_TRestWimpNucleus #define RestCore_TRestWimpNucleus -#include - #include +#include + /// A class to store different nucleus parameters class TRestWimpNucleus { public: diff --git a/inc/TRestWimpSensitivity.h b/inc/TRestWimpSensitivity.h index 1b2e611..e7e7479 100644 --- a/inc/TRestWimpSensitivity.h +++ b/inc/TRestWimpSensitivity.h @@ -23,11 +23,10 @@ #ifndef RestCore_TRestWimpSensitivity #define RestCore_TRestWimpSensitivity +#include #include #include -#include - /// Container class for WIMP metadata /// class TRestWimpSensitivity : public TRestMetadata { diff --git a/src/TRestWimpNucleus.cxx b/src/TRestWimpNucleus.cxx index b7eb2ec..48b1fd7 100644 --- a/src/TRestWimpNucleus.cxx +++ b/src/TRestWimpNucleus.cxx @@ -40,6 +40,7 @@ /// #include "TRestWimpNucleus.h" + #include "TRestMetadata.h" ClassImp(TRestWimpNucleus); diff --git a/src/TRestWimpSensitivity.cxx b/src/TRestWimpSensitivity.cxx index 428e7a6..d60cad9 100644 --- a/src/TRestWimpSensitivity.cxx +++ b/src/TRestWimpSensitivity.cxx @@ -112,6 +112,7 @@ /// #include "TRestWimpSensitivity.h" + #include "TRestWimpUtils.h" ClassImp(TRestWimpSensitivity);