Skip to content

Commit

Permalink
Add pyproject.toml and more pre-commit hooks
Browse files Browse the repository at this point in the history
and fix all issues
  • Loading branch information
gipert committed Dec 19, 2024
1 parent 8eca75b commit f0e9635
Show file tree
Hide file tree
Showing 20 changed files with 502 additions and 303 deletions.
34 changes: 17 additions & 17 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ BreakBeforeTernaryOperators: true
BreakConstructorInitializers: BeforeColon
BreakStringLiterals: true
ColumnLimit: 100
CommentPragmas: '^ IWYU pragma:'
CommentPragmas: "^ IWYU pragma:"
CompactNamespaces: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Expand All @@ -49,20 +49,20 @@ ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: true
IncludeBlocks: Regroup
IncludeCategories:
- Regex: '<[[:alnum:]._/]+>'
Priority: 1
CaseSensitive: false
- Regex: '^"(G4|globals\.hh|Randomize\.hh|CLHEP)'
Priority: 2
CaseSensitive: false
- Regex: '^"RMG'
Priority: 3
CaseSensitive: false
- Regex: '.*'
Priority: 4
CaseSensitive: false
IncludeIsMainRegex: '(Test)?$'
IncludeIsMainSourceRegex: ''
- Regex: "<[[:alnum:]._/]+>"
Priority: 1
CaseSensitive: false
- Regex: '^"(G4|globals\.hh|Randomize\.hh|CLHEP)'
Priority: 2
CaseSensitive: false
- Regex: '^"RMG'
Priority: 3
CaseSensitive: false
- Regex: ".*"
Priority: 4
CaseSensitive: false
IncludeIsMainRegex: "(Test)?$"
IncludeIsMainSourceRegex: ""
IndentAccessModifiers: true
IndentCaseLabels: true
IndentCaseBlocks: false
Expand All @@ -75,8 +75,8 @@ IndentWrappedFunctionNames: false
InsertTrailingCommas: None
KeepEmptyLinesAtTheStartOfBlocks: true
LambdaBodyIndentation: Signature
MacroBlockBegin: ''
MacroBlockEnd: ''
MacroBlockBegin: ""
MacroBlockEnd: ""
MaxEmptyLinesToKeep: 2
NamespaceIndentation: All
PenaltyBreakAssignment: 2
Expand Down
4 changes: 2 additions & 2 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ Checks: "-*, \
-readability-function-cognitive-complexity"

CheckOptions:
- key: modernize-use-override.IgnoreDestructors
value: true
- key: modernize-use-override.IgnoreDestructors
value: true

FormatStyle: file
HeaderFilterRegex: 'include/.*\.(hh|icc)'
7 changes: 4 additions & 3 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ Before opening a PR:
After the CI has run:

- fix all reported problems, if any
- navigate to the ReadTheDocs documentation build (linked in the GitHub
actions report for the PR) and check that the docs are properly rendered
- navigate to the ReadTheDocs documentation build (linked in the GitHub actions
report for the PR) and check that the docs are properly rendered
- download and check the test outputs from the GitHub actions interface

For more details, refer to the [developer's guide](https://remage.readthedocs.io/en/stable/developer.html).
For more details, refer to the
[developer's guide](https://remage.readthedocs.io/en/stable/developer.html).
89 changes: 44 additions & 45 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ on:
push:
branches:
- main
- 'releases/**'
- "releases/**"
paths-ignore:
- '**.md'
- "**.md"
pull_request:
release:

Expand All @@ -15,7 +15,6 @@ concurrency:
cancel-in-progress: true

jobs:

test_on_linux:
name: Test on remage image
runs-on: ubuntu-latest
Expand All @@ -25,57 +24,57 @@ jobs:
matrix:
# guideline: only test on latest patch releases (and maybe previous one)
container_version:
- G4.11.3
- G4.11.2
- slim
- G4.11.3
- G4.11.2
- slim

container: docker://gipert/remage-base:${{ matrix.container_version }}

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v4

- name: Build project
run: |
mkdir build
cd build
cmake -DRMG_BUILD_EXAMPLES=1 ..
make
make install
- name: Build project
run: |
mkdir build
cd build
cmake -DRMG_BUILD_EXAMPLES=1 ..
make
make install
- name: Setup and start xvfb (enables Geant4 visualization)
run: |
Xvfb :99 -screen 0 1920x1080x24 &
- name: Setup and start xvfb (enables Geant4 visualization)
run: |
Xvfb :99 -screen 0 1920x1080x24 &
- name: Run full test suite
if: ${{ matrix.container_version != 'slim' }}
env:
DISPLAY: :99
run: |
cd build
ctest --output-on-failure
- name: Run full test suite
if: ${{ matrix.container_version != 'slim' }}
env:
DISPLAY: :99
run: |
cd build
ctest --output-on-failure
- name: Upload test suite outputs to GitHub
if: ${{ matrix.container_version != 'slim' }}
uses: actions/upload-artifact@v4
with:
name: test-output-${{ matrix.container_version }}
# artifacts must have a ".output*" extension
path: build/tests/**/*.output*.*
- name: Upload test suite outputs to GitHub
if: ${{ matrix.container_version != 'slim' }}
uses: actions/upload-artifact@v4
with:
name: test-output-${{ matrix.container_version }}
# artifacts must have a ".output*" extension
path: build/tests/**/*.output*.*

- name: Run minimal test suite
if: ${{ matrix.container_version == 'slim' }}
env:
DISPLAY: :99
run: |
cd build
ctest --output-on-failure --label-exclude 'extra|vis'
- name: Run minimal test suite
if: ${{ matrix.container_version == 'slim' }}
env:
DISPLAY: :99
run: |
cd build
ctest --output-on-failure --label-exclude 'extra|vis'
- name: Compare checked-in doc dump with current result
if: ${{ matrix.container_version != 'slim' }}
run: |
cd build
cp ../docs/rmg-commands.md ../docs/rmg-commands.md.bak
make remage-doc-dump
diff ../docs/rmg-commands.md ../docs/rmg-commands.md.bak
- name: Compare checked-in doc dump with current result
if: ${{ matrix.container_version != 'slim' }}
run: |
cd build
cp ../docs/rmg-commands.md ../docs/rmg-commands.md.bak
make remage-doc-dump
diff ../docs/rmg-commands.md ../docs/rmg-commands.md.bak
# vim: expandtab tabstop=2 shiftwidth=2
117 changes: 73 additions & 44 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,48 +2,77 @@ ci:
autoupdate_commit_msg: "chore: update pre-commit hooks"
autofix_commit_msg: "style: pre-commit fixes"

exclude: ^include/(fmt|magic_enum|CLI11|EcoMug)/
exclude: ^include/(fmt|magic_enum|CLI11|EcoMug)/|^docs/rmg-commands.md|^docs/extensions/remage/warnings_filter.py
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: check-added-large-files
args: ['--maxkb=600']
- id: check-case-conflict
- id: check-executables-have-shebangs
- id: check-merge-conflict
- id: check-symlinks
- id: check-yaml
- id: check-json
- id: debug-statements
- id: end-of-file-fixer
- id: forbid-new-submodules
- id: mixed-line-ending
- id: trailing-whitespace

- repo: https://github.com/cheshirekow/cmake-format-precommit
rev: v0.6.13
hooks:
- id: cmake-format
additional_dependencies: [pyyaml]

- repo: https://github.com/codespell-project/codespell
rev: v2.3.0
hooks:
- id: codespell
args: ["-L", "hist,manuel"]

- repo: local
hooks:
- id: clang-tidy
name: clang-tidy
entry: bash -c 'command -V run-clang-tidy >&- 2>&-; if [[ $? == 0 && -d build ]]; then run-clang-tidy -fix -quiet -p=build; fi'
language: system
pass_filenames: false
types_or: [c++]

- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v19.1.5
hooks:
- id: clang-format
types_or: [c++]
- repo: https://github.com/adamchainz/blacken-docs
rev: "1.19.1"
hooks:
- id: blacken-docs
additional_dependencies: [black==24.*]

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: check-added-large-files
args: ["--maxkb=600"]
- id: check-case-conflict
- id: check-executables-have-shebangs
- id: check-merge-conflict
- id: check-symlinks
- id: check-yaml
- id: check-json
- id: debug-statements
- id: end-of-file-fixer
- id: forbid-new-submodules
- id: mixed-line-ending
- id: trailing-whitespace

- repo: https://github.com/pre-commit/pygrep-hooks
rev: "v1.10.0"
hooks:
- id: rst-backticks
- id: rst-directive-colons
- id: rst-inline-touching-normal

- repo: https://github.com/rbubley/mirrors-prettier
rev: "v3.3.3"
hooks:
- id: prettier
types_or: [yaml, markdown, html, css, scss, javascript, json]
args: [--prose-wrap=always]

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.7.4"
hooks:
- id: ruff
args: ["--fix", "--show-fixes"]
- id: ruff-format

- repo: https://github.com/cheshirekow/cmake-format-precommit
rev: v0.6.13
hooks:
- id: cmake-format
additional_dependencies: [pyyaml]

- repo: https://github.com/codespell-project/codespell
rev: v2.3.0
hooks:
- id: codespell
args: ["-L", "hist,manuel"]

- repo: local
hooks:
- id: clang-tidy
name: clang-tidy
entry:
bash -c 'command -V run-clang-tidy >&- 2>&-; if [[ $? == 0 && -d build
]]; then run-clang-tidy -fix -quiet -p=build; fi'
language: system
pass_filenames: false
types_or: [c++]

- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v19.1.5
hooks:
- id: clang-format
types_or: [c++]
3 changes: 2 additions & 1 deletion .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ build:
- git fetch --unshallow || true
pre_build: # prepare Doxyfile, run Doxygen, prepare Sphinx
- export DOXYGEN_DOT_PATH=$(which dot)
- sed s/@DOXYGEN_INPUT_DIR@/../g\;s/@DOXYGEN_OUTPUT_DIR@/_doxygen/g docs/Doxyfile.in > docs/Doxyfile
- sed s/@DOXYGEN_INPUT_DIR@/../g\;s/@DOXYGEN_OUTPUT_DIR@/_doxygen/g
docs/Doxyfile.in > docs/Doxyfile
- cat docs/Doxyfile
- cd docs && doxygen
- mkdir -p docs/extra/doxygen
Expand Down
38 changes: 19 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,37 +16,37 @@ Simulation framework for germanium detector experiments

<br/>

The *remage* project aims to deliver a modern Geant4-based C++ library designed
The _remage_ project aims to deliver a modern Geant4-based C++ library designed
for efficient simulation of particle physics processes in typical germanium
detector experiments. The library is setup-agnostic, requiring users only to
define the experimental setup's geometry. Supported specification languages
include C++, GDML, and others. Once the geometry is provided, users can access
a comprehensive suite of tools for common tasks, such as physics generation and
include C++, GDML, and others. Once the geometry is provided, users can access a
comprehensive suite of tools for common tasks, such as physics generation and
standard output handling.

Get started with our [documentation pages](https://remage.readthedocs.io)!

### Main features

* Low entry barrier: Most simulations can be executed directly using the
`remage` executable and a macro file, eliminating the need to write or
compile C++ code.
* Various pre-compiled *remage* versions available on
- Low entry barrier: Most simulations can be executed directly using the
`remage` executable and a macro file, eliminating the need to write or compile
C++ code.
- Various pre-compiled _remage_ versions available on
[Docker Hub](https://hub.docker.com/repository/docker/legendexp/remage)
* Support for modern [Geant4](https://geant4.web.cern.ch), including:
* Multithreading
* [GDML](https://gdml.web.cern.ch/GDML) support
* Multiple output file formats ([ROOT](https://root.cern.ch),
- Support for modern [Geant4](https://geant4.web.cern.ch), including:
- Multithreading
- [GDML](https://gdml.web.cern.ch/GDML) support
- Multiple output file formats ([ROOT](https://root.cern.ch),
[HDF5](https://www.hdfgroup.org/solutions/hdf5)...)
* [LEGEND HDF5 (LH5)](https://legend-exp.github.io/legend-data-format-specs/dev/hdf5/)
- [LEGEND HDF5 (LH5)](https://legend-exp.github.io/legend-data-format-specs/dev/hdf5/)
output format
* Fast third-party cosmic muon generator (through
- Fast third-party cosmic muon generator (through
[EcoMug](https://doi.org/10.1016/j.nima.2021.165732))
* Support for external generators:
* [MUSUN](https://doi.org/10.1016/j.cpc.2008.10.013)
* [MAURINA](https://doi.org/10.1140/epja/s10050-024-01336-0)
* Third-party double-beta decay generator (through
- Support for external generators:
- [MUSUN](https://doi.org/10.1016/j.cpc.2008.10.013)
- [MAURINA](https://doi.org/10.1140/epja/s10050-024-01336-0)
- Third-party double-beta decay generator (through
[bxdecay0](https://github.com/BxCppDev/bxdecay0))
* Advanced vertex confinement on physical volumes, geometrical solids, surfaces
- Advanced vertex confinement on physical volumes, geometrical solids, surfaces
and intersections
* Sensible output schemes for HPGe and optical detectors
- Sensible output schemes for HPGe and optical detectors
Loading

0 comments on commit f0e9635

Please sign in to comment.