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

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
10 changes: 10 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -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
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
5 changes: 4 additions & 1 deletion .github/workflows/validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}

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
8 changes: 4 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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()
4 changes: 2 additions & 2 deletions inc/TRestWimpNucleus.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@
#ifndef RestCore_TRestWimpNucleus
#define RestCore_TRestWimpNucleus

#include <iostream>

#include <TString.h>

#include <iostream>

/// A class to store different nucleus parameters
class TRestWimpNucleus {
public:
Expand Down
3 changes: 1 addition & 2 deletions inc/TRestWimpSensitivity.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,10 @@
#ifndef RestCore_TRestWimpSensitivity
#define RestCore_TRestWimpSensitivity

#include <TH1D.h>
#include <TRestMetadata.h>
#include <TRestWimpNucleus.h>

#include <TH1D.h>

/// Container class for WIMP metadata
///
class TRestWimpSensitivity : public TRestMetadata {
Expand Down
1 change: 1 addition & 0 deletions src/TRestWimpNucleus.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
///

#include "TRestWimpNucleus.h"

#include "TRestMetadata.h"

ClassImp(TRestWimpNucleus);
Expand Down
1 change: 1 addition & 0 deletions src/TRestWimpSensitivity.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@
///

#include "TRestWimpSensitivity.h"

#include "TRestWimpUtils.h"

ClassImp(TRestWimpSensitivity);
Expand Down