Skip to content

Commit

Permalink
Merge pull request #89 from rest-for-physics/lobis-pre-commit
Browse files Browse the repository at this point in the history
Implement pre-commit checks and format files
  • Loading branch information
lobis authored Feb 10, 2023
2 parents 8e64f35 + 95b5bca commit 9fe965f
Show file tree
Hide file tree
Showing 11 changed files with 189 additions and 137 deletions.
2 changes: 1 addition & 1 deletion .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ DerivePointerAlignment: false
PointerAlignment: Left

IndentWidth: 4
ColumnLimit : 110
ColumnLimit: 110
6 changes: 6 additions & 0 deletions .cmake-format.yaml
Original file line number Diff line number Diff line change
@@ -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
4 changes: 4 additions & 0 deletions .github/workflows/validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ jobs:
with:
cmake-flags: "-DCMAKE_INSTALL_PREFIX=${{ env.REST_PATH }} -DCMAKE_BUILD_TYPE=${{ env.CMAKE_BUILD_TYPE }} -DREST_WELCOME=ON -DRESTLIB_GEANT4=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: Load REST libraries
run: |
source ${{ env.REST_PATH }}/thisREST.sh
Expand Down
35 changes: 35 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -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
45 changes: 24 additions & 21 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,29 @@ add_definitions(-DLIBRARY_VERSION="${LibraryVersion}")
if (${REST_DECAY0} MATCHES "ON")
add_definitions(-DUSE_Decay0)
# TODO Issue #6 at rest-framework
#----------------------------------------------------------------------------
# Find package Decay0 and ROOT
# find_package(BxDecay0 1.0.9 CONFIG COMPONENTS manager REQUIRED)
# ----------------------------------------------------------------------------
# Find package Decay0 and ROOT find_package(BxDecay0 1.0.9 CONFIG COMPONENTS
# manager REQUIRED)
#
# find_package was not working properly for me in 1.0.9. So I was using
# bxdecay0-config. But in case Decay0 flag is enabled and we do not
# have a bxdecay0 installation we might run into problems
# find_package was not working properly for me in 1.0.9. So I was using
# bxdecay0-config. But in case Decay0 flag is enabled and we do not have a
# bxdecay0 installation we might run into problems
#

execute_process(
COMMAND bxdecay0-config --version
OUTPUT_VARIABLE BxDecay0_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE)
COMMAND bxdecay0-config --version
OUTPUT_VARIABLE BxDecay0_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE)

execute_process(
COMMAND bxdecay0-config --incdir
OUTPUT_VARIABLE BxDecay0_INCLUDE_DIRS
OUTPUT_STRIP_TRAILING_WHITESPACE)
COMMAND bxdecay0-config --incdir
OUTPUT_VARIABLE BxDecay0_INCLUDE_DIRS
OUTPUT_STRIP_TRAILING_WHITESPACE)

execute_process(
COMMAND bxdecay0-config --libdir
OUTPUT_VARIABLE BxDecay0_LIBRARY_DIRS
OUTPUT_STRIP_TRAILING_WHITESPACE)

COMMAND bxdecay0-config --libdir
OUTPUT_VARIABLE BxDecay0_LIBRARY_DIRS
OUTPUT_STRIP_TRAILING_WHITESPACE)

if (NOT DEFINED BxDecay0_VERSION)
message(FATAL_ERROR "bxdecay0 not found! Put its binary dir to PATH!")
Expand All @@ -41,7 +40,9 @@ if (${REST_DECAY0} MATCHES "ON")
set(external_libs "${external_libs} -L${BxDecay0_LIBRARY_DIRS} -lBxDecay0")

set(feature_added "Decay0")
set(feature_added ${feature_added} PARENT_SCOPE)
set(feature_added
${feature_added}
PARENT_SCOPE)
else ()
set(REST_DECAY0 OFF)
set(excludes ${excludes} TRestGeant4ParticleSourceDecay0)
Expand All @@ -51,13 +52,15 @@ if (NOT ${REST_EVE} MATCHES "ON")
set(excludes ${excludes} TRestGeant4EventViewer)
endif ()

COMPILELIB("")
compilelib("")

file(GLOB_RECURSE MAC "${CMAKE_CURRENT_SOURCE_DIR}/macros/*")
INSTALL(FILES ${MAC} DESTINATION ./macros/geant4)
install(FILES ${MAC} DESTINATION ./macros/geant4)

set(rest_macros ${rest_macros} "restGeant4_ViewEvent")
set(rest_macros ${rest_macros} "restGeant4_ViewGeometry")
set(rest_macros ${rest_macros} PARENT_SCOPE)
set(rest_macros
${rest_macros}
PARENT_SCOPE)

ADD_LIBRARY_TEST()
add_library_test()
2 changes: 1 addition & 1 deletion inc/TRestGeant4ParticleSourceDecay0.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ class TRestGeant4ParticleSourceDecay0 : public TRestGeant4ParticleSource {
~TRestGeant4ParticleSourceDecay0() { delete fDecay0Model; }
ClassDefOverride(TRestGeant4ParticleSourceDecay0, 1);
};
#endif
#endif
4 changes: 2 additions & 2 deletions macros/REST_Geant4_ListIsotopes.C
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ Int_t REST_Geant4_ListIsotopes(TString fName, TString fOutName) {
}
}
if (kaux != 1) {
// cout<<"new isotope "<<event->GetTrack(i).GetParticleName()<<" in track "<<i<<"and
// entry"<<n<<endl;
// cout<<"new isotope "<<event->GetTrack(i).GetParticleName()<<" in track
// "<<i<<"and entry"<<n<<endl;
isotope[k] = event->GetTrack(i).GetParticleName();
ni[k] = 1;
// cout<<"k "<<k<<" isotope "<<isotope[k]<<endl;
Expand Down
1 change: 0 additions & 1 deletion pipeline/clang-format/clang-format.sh
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,3 @@ if [ "-" = "$1" ] ; then
}"' '"${file}"'
done
fi

1 change: 0 additions & 1 deletion pipeline/clang-format/clangformattest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,3 @@ fi
git reset HEAD --hard

exit 1

Loading

0 comments on commit 9fe965f

Please sign in to comment.