Skip to content

Commit

Permalink
Merge branch 'main' into WilfS/feature_nestedTubes
Browse files Browse the repository at this point in the history
  • Loading branch information
WilfS authored Jan 9, 2025
2 parents a06b9d6 + 5d7039e commit 5214a26
Show file tree
Hide file tree
Showing 144 changed files with 6,299 additions and 7,632 deletions.
60 changes: 60 additions & 0 deletions .github/workflows/container.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Build Docker Image

on:
schedule:
- cron: '0 4 * * *' # Everyday at 4am UTC
push:
branches: [ main ]
tags:
- "v*.*.*"
workflow_dispatch:

jobs:
docker:
runs-on: ubuntu-latest
# Don't let forks build containers
if: github.repository == 'rat-pac/ratpac-two'
permissions:
packages: write
contents: read
attestations: write
id-token: write
steps:
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
ratpac/ratpac-two
ghcr.io/${{ github.repository }}
# generate Docker tags based on the following events/attributes
# Using default, which should generate tags for branchs and `nightly`
# tags: |
# type=schedule
# type=ref,event=branch
# type=ref,event=workflow_dispatch
# type=semver,pattern={{raw}}
# type=sha
-
name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

-
name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
-
name: Build and push
id: push
uses: docker/build-push-action@v5
with:
file: containers/Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
41 changes: 41 additions & 0 deletions .github/workflows/rattests-template.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
on:
workflow_call:
inputs:
rattest-name:
required: true
type: string

jobs:
rattest:
runs-on: ubuntu-latest
container:
image: ratpac/ratpac-two:latest-base
options: --user root
steps:
- name: Get build cache
id: cache
uses: actions/cache/restore@v4
with:
path: ratpac2
key: ${{ github.sha }}-install
- name: Run rattest
working-directory: ratpac2
shell: bash
run: |
source /ratpac-setup/env.sh
source ../ratpac2/ratpac.sh
rattest -t test/full/${{ inputs.rattest-name }}
id: test
continue-on-error: true
- name: upload-result
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.rattest-name }}-result
if-no-files-found: error
path: |
ratpac2/test/full/${{ inputs.rattest-name }}/*.png
ratpac2/test/full/${{ inputs.rattest-name }}/*.html
- name: check-test-result
if: steps.test.outcome != 'success'
run: exit 1

42 changes: 42 additions & 0 deletions .github/workflows/rattests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: rattests
on:
push:
branches: [ main ]
pull_request:
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
container:
image: ratpac/ratpac-two:latest-base
options: --user root
steps:
- name: Checkout Ratpac2
uses: actions/checkout@v4
with:
path: ratpac2
- name: Build Ratpac2
working-directory: ratpac2
shell: bash
run: |
source /ratpac-setup/env.sh
make -j$(nproc)
- name: Cache build output
id: cache
uses: actions/cache/save@v4
with:
key: ${{ github.sha }}-install
path: ratpac2

acrylic_attenuation:
needs: build
uses: ./.github/workflows/rattests-template.yml
with:
rattest-name: acrylic_attenuation

fitcentroid:
needs: build
uses: ./.github/workflows/rattests-template.yml
with:
rattest-name: fitcentroid
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ src/core/Config.hh

*.log
*.root
!test/full/*/standard.root
*.heprep
.DS_Store
*.gif
Expand All @@ -28,7 +29,14 @@ src/core/Config.hh

.idea/
.vscode/
.cache/
compile_commands.json
doc/_build/
doc/doxygen
.pytest_cache*
ratpac.*sh
RatpacConfig.cmake

# rattest outputs
test/full/*/*.png
test/full/*/*.html
2 changes: 1 addition & 1 deletion .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
version: 2

build:
os: "ubuntu-20.04"
os: "ubuntu-22.04"
tools:
python: "3.11"

Expand Down
10 changes: 8 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.11...3.14)
project(ratpac VERSION 2.1.3
project(ratpac VERSION 2.3.0
DESCRIPTION "RAT-PAC"
LANGUAGES C CXX)

Expand Down Expand Up @@ -78,9 +78,12 @@ else()
endif()
include(${ROOT_USE_FILE})

find_package(Geant4 REQUIRED COMPONENTS qt)
find_package(Geant4 REQUIRED)
find_package(Geant4 QUIET OPTIONAL_COMPONENTS qt)
include(${Geant4_USE_FILE})
include_directories(${Geant4_INCLUDE_DIRS})
include_directories(${CLHEP_INCLUDE_DIRS})
include_directories(${XercesC_INCLUDE_DIRS})

find_package(Threads REQUIRED)

Expand Down Expand Up @@ -136,6 +139,9 @@ install(DIRECTORY models/ DESTINATION ${RATSHARE}/models
install(DIRECTORY python/ DESTINATION ${RATSHARE}/python
PATTERN "python/*")

# Install rattest executable
install(PROGRAMS python/rattest.py DESTINATION bin RENAME rattest)

# Install the macro files
install(DIRECTORY macros/ DESTINATION ${RATSHARE}/macros
PATTERN "macros/*")
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build_directory := build
install_directory := $(PWD)/install

all:
ln -sf ../../cformat.sh ./.git/hooks/pre-commit
ln -sf $(PWD)/cformat.sh $(shell git rev-parse --git-common-dir)/hooks/pre-commit
cmake . -B$(build_directory) -DCMAKE_INSTALL_PREFIX=$(install_directory)
cmake --build $(build_directory) -- $(MAKEFLAGS)
cmake --install $(build_directory) &> /dev/null
Expand Down
57 changes: 49 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,67 @@
# Ratpac-two

[![Documentation Status](https://readthedocs.org/projects/ratpac/badge/?version=latest)](https://ratpac.readthedocs.io/en/latest/?badge=latest)

[![Build RatpacExperiment](https://github.com/rat-pac/ratpac-two/actions/workflows/build-experiment.yml/badge.svg)](https://github.com/rat-pac/ratpac-two/actions/workflows/build-experiment.yml)

[![clang-format Check](https://github.com/rat-pac/ratpac-two/actions/workflows/check-format.yml/badge.svg)](https://github.com/rat-pac/ratpac-two/actions/workflows/check-format.yml)

[ratpac.readthedocs.io](ratpac.readthedocs.io)
[![Build Docker Image](https://github.com/rat-pac/ratpac-two/actions/workflows/latest-container.yml/badge.svg?branch=main&event=deployment)](https://github.com/rat-pac/ratpac-two/actions/workflows/latest-container.yml)

[ratpac.readthedocs.io](https://ratpac.readthedocs.io)

## Quick Start with containers

The easiest way to get started with ratpac-two is via containers. The latest
builds can be found on
[dockerhub](https://hub.docker.com/r/ratpac/ratpac-two/tags) or on
[ghcr.io](https://github.com/rat-pac/ratpac-two/pkgs/container/ratpac-two).

On HPC platforms, apptainer/singularity containers are a better option than
docker containers. To create these, run

```sh
apptainer pull ratpac2.sif docker://ratpac/ratpac-two:main
```

To enter the container:

```sh
apptainer run [-B /disks/to/mount] ratpac2.sif
```

## Installation
Installation requires [ROOT 6.25+](https://root.cern.ch),

Installation requires [ROOT 6.25+](https://root.cern.ch),
[Geant4 11.0+](https://geant4.web.cern.ch/), and [cmake 3.22+](https://cmake.org/)

Install using cmake
For development, the following are also required:

$ cmake . -Bbuild
$ cmake --build build -- -j$(nproc)
- clang-format: major version 14. _other major versions are known to produce
different outputs that will result in failed checks_

If you want to install the code, just add
The most well-supported way of installing ratpac-two is via the [ratpac-setup
script](https://github.com/rat-pac/ratpac-setup). Follow the instruction will
produce a standalone directory that includes all dependencies. You can also
check this repo for the best-tested minor versions of each dependency.

A convenience Makefile exists to automate the above process, simply type `make`.

Install using cmake:

$ cmake --build build . --target install -j$(nproc)
``` sh
cmake . -Bbuild
cmake --build build -- -j$(nproc)
```

A convenience Makefile exists to automate the above process.
If you want to install the code, just add

``` sh
cmake --build build . --target install -j$(nproc)
```

## Usage

Ratpac-two compiles as a library which can be extended for specific experiment
use cases. The library can be accessed through CMake using
`find_package(Ratpac)`.
Expand All @@ -32,6 +72,7 @@ against the ratpac library, and any specific additions to the C++ framework
should exist outside of the main repository.

## About

Ratpac-two is a refactor of ratpac which makes the necessary changes to compile
with modern versions of GCC and is compatible with the latest Geant4 and ROOT
versions. This version of Ratpac is not backwards compatible with the previous
Expand Down
2 changes: 1 addition & 1 deletion cformat.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ fi

echo "Checking formatting..."
changes=0
for file in $(find ./src \( -name "*.cc" -o -name "*.hh" -o -name "*.icc" -o -name "*.cpp" -o -name "*.hpp" \)); do
for file in $(find ./src ./test \( -name "*.cc" -o -name "*.hh" -o -name "*.icc" -o -name "*.cpp" -o -name "*.hpp" -o -name "*.C" \)); do
retval=$(clang-format -style=file -n -Werror $file)
if [ $? -eq 1 ]; then
echo "Formatting $file"
Expand Down
6 changes: 3 additions & 3 deletions containers/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
FROM ratpac/ratpac-two:base
LABEL maintainer="Morgan Askins <maskins@berkeley.edu>"
FROM ratpac/ratpac-two:latest-base
LABEL maintainer="James Shen <[email protected].edu>"

SHELL ["/bin/bash", "-c"]

USER ratuser

WORKDIR /ratpac-setup

RUN ./setup.sh --only ratpac -j6
RUN ./setup.sh --only ratpac -j$(nproc)
RUN cd ratpac && cmake --install build && cd ..

RUN sed -i '1s/^/#!\/bin\/bash\n/' /ratpac-setup/env.sh
Expand Down
Loading

0 comments on commit 5214a26

Please sign in to comment.