Skip to content

Commit

Permalink
Update github workflows and clang-format-15
Browse files Browse the repository at this point in the history
Clang-format

Again v3 to v4

Update .clang-format-check.sh

Recover previous version for fitter

Recover previous version for gtpc
  • Loading branch information
jose-luis-rs committed Apr 18, 2024
1 parent e71e609 commit c82d4a4
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 38 deletions.
16 changes: 12 additions & 4 deletions .clang-format-check.sh
Original file line number Diff line number Diff line change
@@ -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}

Expand All @@ -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)"
Expand All @@ -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
Expand All @@ -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)
Expand All @@ -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
4 changes: 2 additions & 2 deletions .github/actions/cache-save/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand All @@ -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 }}
4 changes: 2 additions & 2 deletions .github/actions/install-deps/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand All @@ -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 }}
Expand Down
16 changes: 0 additions & 16 deletions .github/workflows/first-timer.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/static_analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
31 changes: 19 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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:

Expand All @@ -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...
8 changes: 8 additions & 0 deletions apply-format.sh
Original file line number Diff line number Diff line change
@@ -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\""

0 comments on commit c82d4a4

Please sign in to comment.