name: Build on RHEL9

on:
  push:
  workflow_dispatch:

permissions:
  contents: read

jobs:
  build:
    runs-on: "ubuntu-latest"
    container:
      image: gitea.psi.ch/detectors/rhel9-detectors-dev
    steps:
      - uses: actions/checkout@v4


      - name: Install Python dependencies
        run: |
          python3.12 -m pip install --upgrade pip
          python3.12 -m pip install pytest
          python3.12 -m pip install numpy
          python3.12 -m pip install pytest-check 
          python3.12 -m pip install matplotlib 
          python3.12 -m pip install boost-histogram

      - name: Build library 
        run: |
            mkdir build && cd build
            cmake .. -DAARE_PYTHON_BINDINGS=ON -DAARE_TESTS=ON
            make -j 2 

      - name: C++ unit tests
        working-directory: ${{gitea.workspace}}/build
        run: ctest

      - name: Python unit tests
        working-directory: ${{gitea.workspace}}/build
        run: | 
          python3.12 -m pytest ${{gitea.workspace}}/python/tests/