CI: Bump Geant4 to v11.2.2 #156
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Tests | |
on: | |
workflow_dispatch: | |
pull_request: | |
push: | |
branches: | |
- main | |
env: | |
GEANT4_GIT_TAG: v11.2.2 | |
GEANT4_SOURCE_DIR: geant4_source | |
GEANT4_BUILD_DIR: geant4_build | |
GEANT4_INSTALL_DIR: geant4_install | |
XERCES_C_GIT_REF: cd34018a9585fb74044f3773d3e3233454808b75 | |
XERCES_C_SOURCE_DIR: xerces-c_source | |
XERCES_C_BUILD_DIR: xerces-c_build | |
XERCES_C_INSTALL_DIR: xerces-c_install | |
jobs: | |
run_tests: | |
name: Tests on ${{ matrix.os }}/${{ matrix.python-version }} | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [windows-latest, macos-latest, ubuntu-latest] | |
python-version: ["3.7", "3.11"] | |
exclude: | |
- os: macos-latest | |
python-version: "3.7" | |
- os: windows-latest | |
python-version: "3.7" | |
steps: | |
- name: Cache Geant4 install | |
uses: actions/cache@v4 | |
id: g4cache | |
with: | |
path: ${{ github.workspace }}/${{ env.GEANT4_INSTALL_DIR }} | |
key: ${{ env.GEANT4_GIT_TAG }}-${{ env.XERCES_C_GIT_REF }} | |
- name: Cache xerces-c install | |
uses: actions/cache@v4 | |
id: xerces-cache | |
with: | |
path: ${{ github.workspace }}/${{ env.XERCES_C_INSTALL_DIR }} | |
key: ${{ env.XERCES_C_GIT_REF }} | |
- uses: actions/checkout@v4 | |
if: steps.g4cache.outputs.cache-hit != 'true' | |
with: | |
repository: Geant4/geant4 | |
ref: ${{ env.GEANT4_GIT_TAG }} | |
path: ${{ env.GEANT4_SOURCE_DIR }} | |
- uses: actions/checkout@v4 | |
if: steps.xerces-cache.outputs.cache-hit != 'true' | |
with: | |
repository: apache/xerces-c | |
ref: ${{ env.XERCES_C_GIT_REF }} | |
path: ${{ env.XERCES_C_SOURCE_DIR }} | |
- uses: lukka/get-cmake@latest | |
if: steps.g4cache.outputs.cache-hit != 'true' || steps.xerces-cache.outputs.cache-hit != 'true' | |
- name: CMake configure xerces-c Unix | |
if: steps.xerces-cache.outputs.cache-hit != 'true' && runner.os != 'Windows' | |
run: > | |
cmake -E env CXXFLAGS="-fPIC" | |
cmake -E env CFLAGS="-fPIC" | |
cmake | |
-Dnetwork-accessor=socket | |
-Dtranscoder=iconv | |
-DBUILD_SHARED_LIBS=OFF | |
-DCMAKE_INSTALL_PREFIX="${{ github.workspace }}/${{ env.XERCES_C_INSTALL_DIR }}" | |
-S "${{ github.workspace }}/${{ env.XERCES_C_SOURCE_DIR }}" | |
-B "${{ github.workspace }}/${{ env.XERCES_C_BUILD_DIR }}" | |
- name: CMake configure xerces-c Windows | |
if: steps.xerces-cache.outputs.cache-hit != 'true' && runner.os == 'Windows' | |
run: > | |
cmake | |
-DBUILD_SHARED_LIBS=OFF | |
-DCMAKE_CXX_FLAGS_RELEASE="/MT" | |
-DCMAKE_INSTALL_PREFIX="${{ github.workspace }}/${{ env.XERCES_C_INSTALL_DIR }}" | |
-S "${{ github.workspace }}/${{ env.XERCES_C_SOURCE_DIR }}" | |
-B "${{ github.workspace }}/${{ env.XERCES_C_BUILD_DIR }}" | |
- name: CMake build xerces-c | |
if: steps.xerces-cache.outputs.cache-hit != 'true' | |
run: | | |
cmake --build "${{ github.workspace }}/${{ env.XERCES_C_BUILD_DIR }}" --config Release | |
cmake --build "${{ github.workspace }}/${{ env.XERCES_C_BUILD_DIR }}" --config Release --target install | |
- name: CMake configure Geant4 Unix | |
if: steps.g4cache.outputs.cache-hit != 'true' && runner.os != 'Windows' | |
run: > | |
cmake -E env CXXFLAGS="-fPIC" | |
cmake -E env CFLAGS="-fPIC" | |
cmake | |
-GNinja | |
-DBUILD_STATIC_LIBS=ON | |
-DBUILD_SHARED_LIBS=OFF | |
-DGEANT4_INSTALL_EXAMPLES=OFF | |
-DGEANT4_USE_SYSTEM_EXPAT=OFF | |
-DGEANT4_USE_GDML=ON | |
-DGEANT4_BUILD_TLS_MODEL=global-dynamic | |
-DCMAKE_PREFIX_PATH="${{ github.workspace }}/${{ env.XERCES_C_INSTALL_DIR }}" | |
-DCMAKE_INSTALL_PREFIX="${{ github.workspace }}/${{ env.GEANT4_INSTALL_DIR }}" | |
-S "${{ github.workspace }}/${{ env.GEANT4_SOURCE_DIR }}" | |
-B "${{ github.workspace }}/${{ env.GEANT4_BUILD_DIR }}" | |
- name: CMake configure Geant4 Windows | |
if: steps.g4cache.outputs.cache-hit != 'true' && runner.os == 'Windows' | |
run: > | |
cmake | |
-DBUILD_STATIC_LIBS=ON | |
-DBUILD_SHARED_LIBS=OFF | |
-DGEANT4_INSTALL_EXAMPLES=OFF | |
-DGEANT4_USE_GDML=ON | |
-DGEANT4_BUILD_TLS_MODEL=global-dynamic | |
-DGEANT4_USE_OPENGL_WIN32=ON | |
-DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded | |
-DCMAKE_PREFIX_PATH="${{ github.workspace }}/${{ env.XERCES_C_INSTALL_DIR }}" | |
-DCMAKE_INSTALL_PREFIX="${{ github.workspace }}/${{ env.GEANT4_INSTALL_DIR }}" | |
-S "${{ github.workspace }}/${{ env.GEANT4_SOURCE_DIR }}" | |
-B "${{ github.workspace }}/${{ env.GEANT4_BUILD_DIR }}" | |
- name: CMake build Geant4 | |
if: steps.g4cache.outputs.cache-hit != 'true' | |
run: | | |
cmake --build "${{ github.workspace }}/${{ env.GEANT4_BUILD_DIR }}" --config Release | |
cmake --build "${{ github.workspace }}/${{ env.GEANT4_BUILD_DIR }}" --config Release --target install | |
- name: Setup environment variables | |
shell: bash | |
run: | | |
echo "${{ github.workspace }}/${{ env.GEANT4_INSTALL_DIR }}/bin" >> $GITHUB_PATH | |
echo "${{ github.workspace }}/${{ env.XERCES_C_INSTALL_DIR }}/bin" >> $GITHUB_PATH | |
echo "HOME=${{ github.workspace }}" >> $GITHUB_ENV | |
echo "CMAKE_ARGS=-DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded" >> $GITHUB_ENV | |
- uses: actions/checkout@v4 | |
with: | |
submodules: true | |
path: ${{ github.event.repository.name }} | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Add Python requirements | |
run: python -m pip install --upgrade setuptools psutil | |
- name: Install ${{ github.event.repository.name }} | |
run: python -m pip install "${{ github.workspace }}/${{ github.event.repository.name }}" | |
- name: Cache Geant4 datasets | |
uses: actions/cache@v4 | |
with: | |
key: ${{ env.GEANT4_GIT_TAG }}-datasets | |
path: ${{ github.workspace }}/.geant4_pybind | |
enableCrossOsArchive: true | |
- name: Run B1 (sanity) test | |
run: python ${{ github.event.repository.name }}/tests/test_B1.py | |
- name: Run example tests | |
run: python ${{ github.event.repository.name }}/tests/test_examples.py |