name: Run tests

on: [push, pull_request]

jobs:

  build-and-test:

    strategy:
      fail-fast: false
      matrix:
        include:
          - os: ubuntu-20.04
            python-version: 3.8
            boost_platform: 20.04
            boost_version: 1.73.0
          - os: ubuntu-22.04
            python-version: 3.9
            boost_platform: 22.04
            boost_version: 1.81.0
          - os: ubuntu-22.04
            python-version: '3.10'
            boost_platform: 22.04
            boost_version: 1.81.0
          - os: ubuntu-22.04
            python-version: 3.11
            boost_platform: 22.04
            boost_version: 1.81.0
          - os: macos-11
            python-version: 3.11
            boost_platform: 11
            boost_version: 1.73.0
          - os: macos-12
            python-version: 3.11
            boost_platform: 11
            boost_version: 1.81.0

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

    steps:
      - uses: actions/checkout@v3
      - name: Set up Python ${{ matrix.python-version }}
        uses: actions/setup-python@v4
        with:
          python-version: ${{ matrix.python-version }}
      - name: Install boost
        uses: MarkusJx/install-boost@v2.4.1
        id: install-boost
        with:
            # REQUIRED: Specify the required boost version
            # A list of supported versions can be found here:
            # https://github.com/MarkusJx/prebuilt-boost/blob/main/versions-manifest.json
            boost_version: ${{ matrix.boost_version }}
            # OPTIONAL: Specify a platform version
            platform_version: ${{ matrix.boost_platform }}
      - name: Build
        run: |
          mkdir build
          cd build
          cmake .. -DCMAKE_BUILD_TYPE=Release -DENABLE_TESTING=1
          cmake --build .
        env:
          BOOST_ROOT: ${{ steps.install-boost.outputs.BOOST_ROOT }}
      - name: Binary test
        run: make test
        working-directory: ./build/tests
      - name: Python test
        run: make test
        working-directory: ./build/python-wrapper/tests
