Skip to content
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

Implement pre-commit checks and format files #67

Merged
merged 5 commits into from
Feb 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
8 changes: 6 additions & 2 deletions .github/workflows/validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ defaults:
jobs:
framework-validation:
uses: rest-for-physics/framework/.github/workflows/validation.yml@master

libCheck:
name: Validate library
runs-on: ubuntu-latest
container:
image: ghcr.io/lobis/root-geant4-garfield:rest-for-physics
steps:
- uses: actions/checkout@v3
- run: python3 pipeline/validateLibrary.py .
- run: python3 pipeline/validateLibrary.py .

build-detectorlib:
name: Build only detectorlib
Expand All @@ -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_DETECTOR=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
2 changes: 0 additions & 2 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,5 +80,3 @@ Load REST Libraries:
except:
variables:
- $CRONJOB


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
28 changes: 17 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
set(LibraryVersion "1.9")
add_definitions(-DLIBRARY_VERSION="${LibraryVersion}")

#find garfield libs and includes
IF (NOT DEFINED REST_GARFIELD)
# find garfield libs and includes
if (NOT DEFINED REST_GARFIELD)
set(REST_GARFIELD OFF)
ENDIF ()
endif ()

if (${REST_GARFIELD} MATCHES "ON")
add_definitions(-DUSE_Garfield)
Expand All @@ -14,9 +14,11 @@ if (${REST_GARFIELD} MATCHES "ON")
message(STATUS "Using new Garfield CMake")
set(GARFIELD_INSTALL $ENV{GARFIELD_INSTALL})
find_package(Garfield REQUIRED)
set(external_include_dirs ${external_include_dirs} ${GARFIELD_INSTALL}/include/Garfield)
set(external_include_dirs ${external_include_dirs}
${GARFIELD_INSTALL}/include/Garfield)
set(external_libs ${external_libs} Garfield::Garfield)
# recommended CMake way does not work, we need to delete the "FindGarfield.cmake" script
# recommended CMake way does not work, we need to delete the
# "FindGarfield.cmake" script
elseif (DEFINED ENV{GARFIELD_HOME})
# Old way, for backwards compatibility
message(STATUS "Using old Garfield CMake")
Expand All @@ -25,8 +27,10 @@ if (${REST_GARFIELD} MATCHES "ON")
message(STATUS Garfield_INCLUDE_DIRS ${Garfield_INCLUDE_DIRS})
message(STATUS Garfield_INCLUDE_DIRS ${Garfield_INCLUDE_Heed_DIRS})
message(STATUS Garfield_LIBRARIES ${Garfield_LIBRARIES})
set(external_include_dirs ${external_include_dirs} ${Garfield_INCLUDE_DIRS})
set(external_include_dirs ${external_include_dirs} ${Garfield_INCLUDE_Heed_DIRS})
set(external_include_dirs ${external_include_dirs}
${Garfield_INCLUDE_DIRS})
set(external_include_dirs ${external_include_dirs}
${Garfield_INCLUDE_Heed_DIRS})
set(external_libs ${external_libs} ${Garfield_LIBRARIES})
add_definitions(-DUSE_Garfield_OLD)
else ()
Expand All @@ -36,7 +40,9 @@ if (${REST_GARFIELD} MATCHES "ON")
message(STATUS "GARFIELD INSTALLATION: ${GARFIELD_INSTALL}")

set(feature_added "Garfield")
set(feature_added ${feature_added} PARENT_SCOPE)
set(feature_added
${feature_added}
PARENT_SCOPE)
else ()
set(REST_GARFIELD OFF)
endif (${REST_GARFIELD} MATCHES "ON")
Expand All @@ -45,9 +51,9 @@ if (NOT ${REST_EVE} MATCHES "ON")
set(excludes ${excludes} TRestDetectorHitsEventViewer)
endif ()

COMPILELIB("")
compilelib("")

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

ADD_LIBRARY_TEST()
add_library_test()
3 changes: 2 additions & 1 deletion inc/TRestDetectorDaqChannelSwitchingProcess.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ class TRestDetectorDaqChannelSwitchingProcess : public TRestEventProcess {
RESTMetadata << "module's daq channel re-definition: " << RESTendl;
auto iter = fFirstDaqChannelDef.begin();
while (iter != fFirstDaqChannelDef.end()) {
RESTMetadata << "module id: " << iter->first << " first daq channel: " << iter->second << RESTendl;
RESTMetadata << "module id: " << iter->first << " first daq channel: " << iter->second
<< RESTendl;
iter++;
}
RESTMetadata << RESTendl;
Expand Down
6 changes: 4 additions & 2 deletions inc/TRestDetectorHitsAnalysisProcess.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,10 @@ class TRestDetectorHitsAnalysisProcess : public TRestEventProcess {
RESTMetadata << " -------------------" << RESTendl;
RESTMetadata << " Fiducial parameters" << RESTendl;
RESTMetadata << " -------------------" << RESTendl;
RESTMetadata << " x0 : (" << fFid_x0.X() << " , " << fFid_x0.Y() << " , " << fFid_x0.Z() << ")" << RESTendl;
RESTMetadata << " x1 : (" << fFid_x1.X() << " , " << fFid_x1.Y() << " , " << fFid_x1.Z() << ")" << RESTendl;
RESTMetadata << " x0 : (" << fFid_x0.X() << " , " << fFid_x0.Y() << " , " << fFid_x0.Z() << ")"
<< RESTendl;
RESTMetadata << " x1 : (" << fFid_x1.X() << " , " << fFid_x1.Y() << " , " << fFid_x1.Z() << ")"
<< RESTendl;
RESTMetadata << " R : " << fFid_R << RESTendl;
RESTMetadata << " sX : " << fFid_sX << RESTendl;
RESTMetadata << " sY : " << fFid_sY << RESTendl;
Expand Down
6 changes: 3 additions & 3 deletions inc/TRestDetectorPositionMappingProcess.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ class TRestDetectorPositionMappingProcess : public TRestEventProcess {

RESTMetadata << "the mode is:" << RESTendl;
RESTMetadata << (fApplyGainCorrection ? "> " : " ")
<< "Apply position correction std::map for spectrum " << RESTendl;
RESTMetadata << (fCreateGainMap ? "> " : " ") << "Create new correction std::map for each position"
<< RESTendl;
<< "Apply position correction std::map for spectrum " << RESTendl;
RESTMetadata << (fCreateGainMap ? "> " : " ")
<< "Create new correction std::map for each position" << RESTendl;
RESTMetadata << "output mapping file: " << fMappingSave << RESTendl;
RESTMetadata << "Energy cut for Threshold integral: " << any(fEnergyCutRange) << RESTendl;
RESTMetadata << "Energy cut for NGoodSignals: " << any(fNHitsCutRange) << RESTendl;
Expand Down
2 changes: 1 addition & 1 deletion inc/TRestDetectorReadoutEventViewer.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

#include "TRestDetectorSignalEvent.h"
#include "TRestEventViewer.h"
//#include "TRestDecoding.h"
// #include "TRestDecoding.h"
#include "TH2Poly.h"
#include "TRestDetectorReadout.h"

Expand Down
6 changes: 3 additions & 3 deletions inc/TRestDetectorSingleChannelAnalysisProcess.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ class TRestDetectorSingleChannelAnalysisProcess : public TRestEventProcess {

RESTMetadata << "the mode is:" << RESTendl;
RESTMetadata << (fApplyGainCorrection ? "> " : " ")
<< "Apply channel correction std::map for spectrum " << RESTendl;
RESTMetadata << (fCreateGainMap ? "> " : " ") << "Create new correction std::map for each channel"
<< RESTendl;
<< "Apply channel correction std::map for spectrum " << RESTendl;
RESTMetadata << (fCreateGainMap ? "> " : " ")
<< "Create new correction std::map for each channel" << RESTendl;
RESTMetadata << "output mapping file: " << fCalibSave << RESTendl;
RESTMetadata << "Energy cut for Threshold integral: " << any(fThrIntegralCutRange) << RESTendl;
RESTMetadata << "Energy cut for NGoodSignals: " << any(fNGoodSignalsCutRange) << RESTendl;
Expand Down
2 changes: 1 addition & 1 deletion macros/REST_Detector_ViewHitsEvent.C
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "TRestBrowser.h"
#include "TRestTask.h"
#include "TRestDetectorHitsEvent.h"
#include "TRestTask.h"

#ifndef RestTask_ViewHitsEvents
#define RestTask_ViewHitsEvents
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