Skip to content

Commit

Permalink
build-test dynamic and static libs
Browse files Browse the repository at this point in the history
  • Loading branch information
lobis committed Dec 5, 2023
1 parent ec83d32 commit 53f4523
Show file tree
Hide file tree
Showing 2 changed files with 227 additions and 27 deletions.
216 changes: 216 additions & 0 deletions .github/workflows/build-test-static.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,216 @@
name: Build and Test

on:
schedule:
- cron: 0 */24 * * *
workflow_dispatch:
inputs:
debug_enabled:
type: boolean
description:
Run the build with tmate debugging enabled
(https://github.com/marketplace/actions/debugging-with-tmate)
required: false
default: false
pull_request:
push:
branches: [main]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
build-geant4:
name: "Geant4 Install - No Datasets"
runs-on: ${{ matrix.platform }}
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
platform: [ubuntu-latest, macos-latest]
geant4-version:
- 11.1.3

steps:
- name: Install additional dependencies (ubuntu)
if: matrix.platform == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install -y build-essential git
python -m pip install cmake
- name: Cache Xerces-C Installation
id: cache-xerces
uses: actions/cache@v3
with:
path: ${{ github.workspace }}/xerces
key: xerces-${{ matrix.platform }}

- name: Build and Install Xerces-C
if: steps.cache-xerces.outputs.cache-hit != 'true'
run: |
git clone https://github.com/apache/xerces-c.git xerces-source
git -C xerces-source checkout tags/v3.2.4
mkdir -p ${{ github.workspace }}/xerces-source/build
cd ${{ github.workspace }}/xerces-source/build
cmake .. -DCMAKE_INSTALL_PREFIX=${{ github.workspace }}/xerces -DCMAKE_CXX_STANDARD=20 -DBUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS=-fPIC
make install -j$(nproc)
- name: Cache Geant4 Installation
id: cache-geant4
uses: actions/cache@v3
with:
path: ${{ github.workspace }}/geant4
key: geant4-${{ matrix.geant4-version }}-${{ matrix.platform }}

- name: Build and Install Geant4 (without datasets)
if: steps.cache-geant4.outputs.cache-hit != 'true'
run: |
git clone https://github.com/Geant4/geant4.git ${{ github.workspace }}/geant4-source --depth 1 --branch v${{ matrix.geant4-version }}
mkdir -p ${{ github.workspace }}/geant4-source/build
cd ${{ github.workspace }}/geant4-source/build
cmake .. -DCMAKE_INSTALL_PREFIX=${{ github.workspace }}/geant4 -DCMAKE_CXX_STANDARD=20 -DCMAKE_BUILD_TYPE=Release -DGEANT4_USE_GDML=ON -DGEANT4_INSTALL_EXAMPLES=OFF -DGEANT4_INSTALL_DATA=OFF -DGEANT4_BUILD_TLS_MODEL=global-dynamic -DCMAKE_CXX_FLAGS=-fPIC -DGEANT4_USE_SYSTEM_EXPAT=OFF -DBUILD_STATIC_LIBS=ON -DBUILD_SHARED_LIBS=OFF -DXERCESC_ROOT_DIR=${{ github.workspace }}/xerces
make install -j$(nproc)
install-geant4-datasets:
name: "Geant4 Datasets"
needs: [build-geant4]
runs-on: ${{ matrix.platform }}
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
platform: [ubuntu-latest, macos-latest]
geant4-version:
- 11.1.3

steps:
- name: Cache Geant4 Installation
id: cache-geant4
uses: actions/cache@v3
with:
path: ${{ github.workspace }}/geant4
key: geant4-${{ matrix.geant4-version }}-${{ matrix.platform }}
fail-on-cache-miss: true

- name: Cache Geant4 Datasets
id: cache-geant4-data
uses: actions/cache@v3
with:
path: ${{ github.workspace }}/geant4-data
key: geant4-${{ matrix.geant4-version }}-data
enableCrossOsArchive: true

- name: Install Geant4 Datasets
if: steps.cache-geant4-data.outputs.cache-hit != 'true'
run: |
source ${{ github.workspace }}/geant4/bin/geant4.sh
geant4-config --install-datasets
geant4-config --check-datasets
mv ${{ github.workspace }}/geant4/share/Geant4/data ${{ github.workspace }}/geant4-data
build-test:
name: "Build and Test"
needs: [install-geant4-datasets]
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
platform: [ubuntu-latest, macos-latest]
geant4-version:
- 11.1.3
python-version:
- "3.8"
- "3.9"
- "3.10"
- "3.11"
- "3.12"

runs-on: ${{ matrix.platform }}

steps:
- uses: actions/checkout@v4

- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install additional dependencies (ubuntu)
if: matrix.platform == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install -y build-essential
- name: Install cmake
run: |
python -m pip install cmake
- name: Cache Xerces-C Installation
id: cache-xerces
uses: actions/cache@v3
with:
path: ${{ github.workspace }}/xerces
key: xerces-${{ matrix.platform }}
fail-on-cache-miss: true

- name: Cache Geant4 Installation
id: cache-geant4
uses: actions/cache@v3
with:
path: ${{ github.workspace }}/geant4
key: geant4-${{ matrix.geant4-version }}-${{ matrix.platform }}
fail-on-cache-miss: true

- name: Cache Geant4 Datasets
id: cache-geant4-data
uses: actions/cache@v3
with:
path: ${{ github.workspace }}/geant4-data
key: geant4-${{ matrix.geant4-version }}-data
fail-on-cache-miss: true
enableCrossOsArchive: true

- name: Check Geant4
run: |
mv ${{ github.workspace }}/geant4-data ${{ github.workspace }}/geant4/share/Geant4/data
source ${{ github.workspace }}/geant4/bin/geant4.sh
geant4-config --version
geant4-config --check-datasets
- name: pip install the package
run: |
source ${{ github.workspace }}/geant4/bin/geant4.sh
python -m pip install .[test]
- name: Check import
run: |
source ${{ github.workspace }}/geant4/bin/geant4.sh
python -c "import geant4_python_application; geant4_python_application.Application()"
- name: Setup tmate session
uses: mxschmitt/action-tmate@v3
if:
${{ github.event_name == 'workflow_dispatch' && inputs.debug_enabled
}}
with:
limit-access-to-actor: false

# Need to run each "run" test separately to avoid error (TODO: investigate)
- name: Run tests
run: |
source ${{ github.workspace }}/geant4/bin/geant4.sh
find ./tests -name "test_*.py" -exec python -m pytest -vv --reruns 3 --reruns-delay 30 --only-rerun "(?i)http|timeout|connection|socket|resolve" {} \;
- name: Build Wheel
run: |
source ${{ github.workspace }}/geant4/bin/geant4.sh
python -m pip install build
python -m build --wheel .
- name: Upload Wheel
uses: actions/upload-artifact@v3
with:
name: wheels
path: dist/*.whl
38 changes: 11 additions & 27 deletions .github/workflows/build-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,25 +37,14 @@ jobs:
if: matrix.platform == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install -y build-essential git
sudo apt-get install -y build-essential git libxerces-c-dev
python -m pip install cmake
- name: Cache Xerces-C Installation
id: cache-xerces
uses: actions/cache@v3
with:
path: ${{ github.workspace }}/xerces
key: xerces-${{ matrix.platform }}

- name: Build and Install Xerces-C
if: steps.cache-xerces.outputs.cache-hit != 'true'
- name: Install additional dependencies (macos)
if: matrix.platform == 'macos-latest'
run: |
git clone https://github.com/apache/xerces-c.git xerces-source
git -C xerces-source checkout tags/v3.2.4
mkdir -p ${{ github.workspace }}/xerces-source/build
cd ${{ github.workspace }}/xerces-source/build
cmake .. -DCMAKE_INSTALL_PREFIX=${{ github.workspace }}/xerces -DCMAKE_CXX_STANDARD=20 -DBUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS=-fPIC
make install -j$(nproc)
brew install xerces-c
python -m pip install cmake
- name: Cache Geant4 Installation
id: cache-geant4
Expand All @@ -70,7 +59,7 @@ jobs:
git clone https://github.com/Geant4/geant4.git ${{ github.workspace }}/geant4-source --depth 1 --branch v${{ matrix.geant4-version }}
mkdir -p ${{ github.workspace }}/geant4-source/build
cd ${{ github.workspace }}/geant4-source/build
cmake .. -DCMAKE_INSTALL_PREFIX=${{ github.workspace }}/geant4 -DCMAKE_CXX_STANDARD=20 -DCMAKE_BUILD_TYPE=Release -DGEANT4_USE_GDML=ON -DGEANT4_INSTALL_EXAMPLES=OFF -DGEANT4_INSTALL_DATA=OFF -DGEANT4_BUILD_TLS_MODEL=global-dynamic -DCMAKE_CXX_FLAGS=-fPIC -DGEANT4_USE_SYSTEM_EXPAT=OFF -DBUILD_STATIC_LIBS=ON -DBUILD_SHARED_LIBS=OFF -DXERCESC_ROOT_DIR=${{ github.workspace }}/xerces
cmake .. -DCMAKE_INSTALL_PREFIX=${{ github.workspace }}/geant4 -DCMAKE_CXX_STANDARD=20 -DCMAKE_BUILD_TYPE=Release -DGEANT4_USE_GDML=ON -DGEANT4_INSTALL_EXAMPLES=OFF -DGEANT4_INSTALL_DATA=OFF -DGEANT4_BUILD_TLS_MODEL=global-dynamic -DCMAKE_CXX_FLAGS=-fPIC -DGEANT4_USE_SYSTEM_EXPAT=OFF
make install -j$(nproc)
install-geant4-datasets:
Expand Down Expand Up @@ -141,20 +130,15 @@ jobs:
if: matrix.platform == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install -y build-essential
sudo apt-get install -y build-essential libxerces-c-dev
python -m pip install cmake
- name: Install cmake
- name: Install additional dependencies (macos)
if: matrix.platform == 'macos-latest'
run: |
brew install xerces-c
python -m pip install cmake
- name: Cache Xerces-C Installation
id: cache-xerces
uses: actions/cache@v3
with:
path: ${{ github.workspace }}/xerces
key: xerces-${{ matrix.platform }}
fail-on-cache-miss: true

- name: Cache Geant4 Installation
id: cache-geant4
uses: actions/cache@v3
Expand Down

0 comments on commit 53f4523

Please sign in to comment.