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 #23

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
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-connectorslib:
name: Build only connectorslib
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_CONNECTORS=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
1 change: 0 additions & 1 deletion .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,3 @@ Validate Library:
except:
variables:
- $CRONJOB == "YES"

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
16 changes: 11 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@ set(excludes)
set(deps detector geant4 track raw)
if (NOT ${RESTLIB_RAW} MATCHES "ON")
list(REMOVE_ITEM deps raw)
set(excludes ${excludes} TRestDetectorSignalToRawSignalProcess TRestRawReadoutAnalysisProcess TRestRawToDetectorSignalProcess)
set(excludes ${excludes} TRestDetectorSignalToRawSignalProcess
TRestRawReadoutAnalysisProcess TRestRawToDetectorSignalProcess)
endif ()
if (NOT ${RESTLIB_TRACK} MATCHES "ON")
list(REMOVE_ITEM deps track)
set(excludes ${excludes} TRestDetectorHitsToTrackProcess TRestDetectorHitsToTrackFastProcess TRestTrackToDetectorHitsProcess)
set(excludes
${excludes} TRestDetectorHitsToTrackProcess
TRestDetectorHitsToTrackFastProcess TRestTrackToDetectorHitsProcess)
endif ()
if (NOT ${RESTLIB_GEANT4} MATCHES "ON")
list(REMOVE_ITEM deps geant4)
Expand All @@ -19,9 +22,12 @@ endif ()

list(LENGTH deps ndeps)
if (NOT ${ndeps} MATCHES 1)
COMPILELIB(deps)
compilelib(deps)
else ()
message(WARNING "Library RESTConnectors requires at least one active library (${deps})")
message(
WARNING
"Library RESTConnectors requires at least one active library (${deps})"
)
endif ()

ADD_LIBRARY_TEST()
add_library_test()
4 changes: 2 additions & 2 deletions inc/TRestDetectorHitsToTrackFastProcess.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ class TRestDetectorHitsToTrackFastProcess : public TRestEventProcess {

RESTMetadata << " Cell resolution : " << fCellResolution << " mm " << RESTendl;
RESTMetadata << " Net size : " << fNetSize << " mm " << RESTendl;
RESTMetadata << " Net origin : ( " << fNetOrigin.X() << " , " << fNetOrigin.Y() << " , " << fNetOrigin.Z()
<< " ) mm " << RESTendl;
RESTMetadata << " Net origin : ( " << fNetOrigin.X() << " , " << fNetOrigin.Y() << " , "
<< fNetOrigin.Z() << " ) mm " << RESTendl;
RESTMetadata << " Number of nodes (per axis) : " << fNodes << RESTendl;

EndPrintProcess();
Expand Down
2 changes: 1 addition & 1 deletion inc/TRestRawReadoutAnalysisProcess.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

#include <TH1D.h>

//#include <TCanvas.h>
// #include <TCanvas.h>

#include <TRestDetectorGas.h>
#include <TRestDetectorHitsEvent.h>
Expand Down
8 changes: 4 additions & 4 deletions inc/TRestRawToDetectorSignalProcess.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,10 @@ class TRestRawToDetectorSignalProcess : public TRestEventProcess {
RESTMetadata << "Gain : " << fGain << RESTendl;

if (fZeroSuppression) {
RESTMetadata << "Base line range definition : ( " << fBaseLineRange.X() << " , " << fBaseLineRange.Y()
<< " ) " << RESTendl;
RESTMetadata << "Integral range : ( " << fIntegralRange.X() << " , " << fIntegralRange.Y() << " ) "
<< RESTendl;
RESTMetadata << "Base line range definition : ( " << fBaseLineRange.X() << " , "
<< fBaseLineRange.Y() << " ) " << RESTendl;
RESTMetadata << "Integral range : ( " << fIntegralRange.X() << " , " << fIntegralRange.Y()
<< " ) " << RESTendl;
RESTMetadata << "Point Threshold : " << fPointThreshold << " sigmas" << RESTendl;
RESTMetadata << "Signal threshold : " << fSignalThreshold << " sigmas" << RESTendl;
RESTMetadata << "Number of points over threshold : " << fNPointsOverThreshold << RESTendl;
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