diff --git a/.clang-format-check.sh b/.clang-format-check.sh index 1146107..0489752 100755 --- a/.clang-format-check.sh +++ b/.clang-format-check.sh @@ -1,5 +1,6 @@ #! /bin/bash test "$1" == "--autofix" && AUTOFIX=1 && shift +test "$1" == "--ci" && AUTOFIX=1 && CI=1 && shift CLANG_FORMAT=${1:-clang-format} @@ -12,7 +13,6 @@ if [ 0 != $? ]; then exit 1 fi -# Not in a pull request, so compare against parent commit git fetch --all base_commit="origin/dev" echo "Checking against parent commit $(git rev-parse $base_commit)" @@ -24,7 +24,7 @@ echo "---" FMT_FILE=$(mktemp) -filesToCheck="$(git diff --name-only ${base_commit} | grep -e '.(\x\|\.cxx\|\x)&&.(\x\|\.h\|\x)$&&.(\x\|\.C\|\x)$' || true)" +filesToCheck="$(git diff --name-only ${base_commit} | grep -E '[.](cxx|h|C)$' || true)" for f in $filesToCheck; do if test -n "$AUTOFIX" then @@ -40,7 +40,9 @@ for f in $filesToCheck; do fi done -if test -n "$fail" ; then +if test -n "$CI" +then + if test -n "$fail" ; then echo -e "\033[1;31mYou must pass the clang-format checks before submitting a pull request for the files: \033[0m" for f in $filesToCheck; do d=$(diff -u "$f" <($CLANG_FORMAT -style=file "$f") || true) @@ -49,6 +51,12 @@ if test -n "$fail" ; then fi done exit 1 -else + else echo -e "\033[1;32m\xE2\x9C\x93 passed clang-format checks\033[0m $1"; + fi +else + + if test -n "$fail"; then + echo "Clang-format check failed. Try --autofix to fix it in the code." + fi fi diff --git a/.github/actions/cache-save/action.yml b/.github/actions/cache-save/action.yml index b21e344..874c7fc 100644 --- a/.github/actions/cache-save/action.yml +++ b/.github/actions/cache-save/action.yml @@ -15,7 +15,7 @@ runs: steps: - name: cache ucesb id: cache-ucesb - uses: actions/cache/save@v3 + uses: actions/cache/save@v4 with: path: | ${{ env.UCESB_DIR }} @@ -25,7 +25,7 @@ runs: - name: cache r3b if: matrix.save != 'false' id: cache-r3b - uses: actions/cache/save@v3 + uses: actions/cache/save@v4 with: path: .ccache key: r3b-build-${{ inputs.cache-name }}-${{ inputs.r3b-dev-key }} diff --git a/.github/actions/install-deps/action.yml b/.github/actions/install-deps/action.yml index 2fc3c97..dbd40ef 100644 --- a/.github/actions/install-deps/action.yml +++ b/.github/actions/install-deps/action.yml @@ -17,7 +17,7 @@ runs: - name: cache ucesb if: github.event_name == 'pull_request' id: cache-ucesb - uses: actions/cache/restore@v3 + uses: actions/cache/restore@v4 with: path: | ${{ env.UCESB_DIR }} @@ -27,7 +27,7 @@ runs: - name: cache r3b if: inputs.cache-name != 'false' && github.event_name == 'pull_request' id: cache-r3b - uses: actions/cache/restore@v3 + uses: actions/cache/restore@v4 with: path: .ccache key: r3b-build-${{ inputs.cache-name }}-${{ inputs.r3b-dev-key }} diff --git a/.github/workflows/first-timer.yml b/.github/workflows/first-timer.yml deleted file mode 100644 index c3fabaf..0000000 --- a/.github/workflows/first-timer.yml +++ /dev/null @@ -1,16 +0,0 @@ -name: Verify user -on: - pull_request: - branches: [ master, dev ] - - # Allows you to run this workflow manually from the Actions tab - workflow_dispatch: - -jobs: - first_timer: - runs-on: ubuntu-latest - steps: - - uses: actions/first-interaction@v1 - with: - repo-token: ${{ secrets.GITHUB_TOKEN }} - pr-message: 'This seems to be your first PR. You will need a positive review in order for tests to start.' diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d28f076..9007a43 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -79,7 +79,7 @@ jobs: # another github repo or a self-defined one in .github/actions. steps: # Fetch updates from pull request branches using a public github action. - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: # This allows all commits of all branches to be fetched. fetch-depth: 0 diff --git a/.github/workflows/static_analysis.yml b/.github/workflows/static_analysis.yml index c136bb9..e4c445d 100644 --- a/.github/workflows/static_analysis.yml +++ b/.github/workflows/static_analysis.yml @@ -15,7 +15,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Code formatting run: | cd $GITHUB_WORKSPACE diff --git a/README.md b/README.md index aec96cc..7ea1ebe 100644 --- a/README.md +++ b/README.md @@ -1,19 +1,26 @@ -# Purpose +# GLAD-TPC Software + +[![static analysis](https://github.com/R3BRootGroup/glad-tpc/actions/workflows/static_analysis.yml/badge.svg)](https://github.com/R3BRootGroup/glad-tpc/actions/workflows/static_analysis.yml) [![CI-CD](https://github.com/R3BRootGroup/glad-tpc/actions/workflows/main.yml/badge.svg)](https://github.com/R3BRootGroup/glad-tpc/actions/workflows/main.yml) + +## The GLAD-TPC Framework GLAD-TPC (HYDRA) is part of the R3BRoot software, the Monte Carlo simulation and experimental data analysis of the R3B (Reactions with Relativistic Radioactive Beams) nuclear physics experiments at the FAIR research center (Facility for Antiproton and Ion Research). For the software-related user support you can post a new topic on our [forum](https://forum.gsi.de/index.php?t=index&cat=40&). -# Download +## Release Information +Please visit [releases](https://github.com/R3BRootGroup/glad-tpc/releases) + +## Contributing +Please ask your questions, request features, and report issues by [creating a github issue](https://github.com/R3BRootGroup/glad-tpc/issues/new/choose). +## Code Formatting +The GLAD-TPC project (as part of R3BRoot) uses clang-format-15 to ensure a common code formatting. The script "apply-format.sh" can be used for this purpose: ~~~bash -git clone https://github.com/R3BRootGroup/R3BRoot.git -cd R3BRoot -git clone https://github.com/R3BRootGroup/glad-tpc.git -cd glad-tpc +source apply-format.sh ~~~ -# Install +## Step by Step Installation ### Required software @@ -24,12 +31,12 @@ Newer versions will not work properly with the simulation. ### Configure and compile -Follow the instructions in the [R3BRoot README](https://github.com/R3BRootGroup/R3BRoot/blob/master/README.md). +Follow the instructions in the [R3BRoot README](https://github.com/R3BRootGroup/R3BRoot/blob/dev/README.md). -# Simulations +## Simulations -For the general R3BRoot simulations, follow the instructions in [R3BRoot README](https://github.com/R3BRootGroup/R3BRoot/blob/master/README.md). +For the general R3BRoot simulations, follow the instructions in [R3BRoot README](https://github.com/R3BRootGroup/R3BRoot/blob/dev/README.md). The steps to properly run the glad-tpc simulation: @@ -54,11 +61,11 @@ The steps to properly run the glad-tpc simulation: 6. Electronics response, in the folder `/glad-tpc/macro/electronics` there is the macro `Electronics_MT.C`: This macro simulate the electronics response. -#How to run the simulations +## How to run the simulations It is possible to use the bash script `run_full.sh` to run all these steps at once. BE CAREFUL, set first the wanted parameters in the different folders. -# Data Analysis +## Data Analysis > ...Under development... diff --git a/apply-format.sh b/apply-format.sh new file mode 100644 index 0000000..5b59698 --- /dev/null +++ b/apply-format.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +CLANG_FORMAT_BIN="clang-format-15" + +FILES=$(find . -type f \( -iname "*.h" ! -iname "*.pb.h" ! -iname "*LinkDef.h" ! -iname "ext_h101_*.h" -o -iname "*.hpp" -o -iname "*.cxx" -o -iname "*.cpp" -o -iname "*.tpl" -o -iname "*.c" -o -iname "*.C" \) -not \( -path "./macros/*" -prune \)) + +$CLANG_FORMAT_BIN -i $FILES +echo "Clang-format has been applied over all files. Use git add -A ; git commit -m \"clang-format all files\""