Build and Test #12
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: Build and Test | |
on: | |
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-test: | |
timeout-minutes: 20 | |
strategy: | |
fail-fast: false | |
matrix: | |
platform: [macos-latest, ubuntu-latest] | |
geant4-version: [11.1.3, 11.0.3] | |
python-version: [3.9, 3.11] | |
runs-on: ${{ matrix.platform }} | |
defaults: | |
run: | |
shell: bash -l {0} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Get conda | |
uses: conda-incubator/setup-miniconda@v3 | |
with: | |
auto-update-conda: true | |
python-version: ${{ matrix.python-version }} | |
miniforge-variant: Mambaforge | |
use-mamba: true | |
- name: Setup tmate session | |
uses: mxschmitt/action-tmate@v3 | |
if: ${{ github.event_name == 'workflow_dispatch' && inputs.debug_enabled }} | |
with: | |
limit-access-to-actor: true | |
- name: Install cmake via conda | |
run: | | |
conda env list | |
mamba install -c conda-forge cmake | |
conda list | |
- name: Install Geant4 via conda | |
run: | | |
conda env list | |
mamba install -c conda-forge geant4=${{ matrix.geant4-version }} | |
conda list | |
- name: Info | |
run: | | |
cmake --version | |
python --version | |
geant4-config --version | |
geant4-config --prefix | |
geant4-config --cflags | |
- name: Build the c++ library to run tests | |
run: | | |
cd application | |
mkdir -p build | |
cd build | |
cmake .. -DCMAKE_BUILD_TYPE=Debug -DCMAKE_PREFIX_PATH=${CONDA_PREFIX} | |
cd tests | |
ctest | |
- name: Build the c++ library | |
run: | | |
cd application | |
rm -rf build | |
mkdir -p build | |
cd build | |
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=${CONDA_PREFIX} | |
make | |
ls ../lib | |
- name: Install the python bindings | |
run: pip install .[test] | |
- name: Run tests | |
run: | | |
export PYTHONPATH=$PYTHONPATH:$(pwd)/application/lib | |
python -m pytest -vv tests |