name: test-macos

on:
  push:
    branches: [master, stable-*]
  pull_request:
    branches: [master, stable-*]

jobs:
  tests:
    name: ${{ matrix.build_type }} on ${{ matrix.os }}
    runs-on: ${{ matrix.os }}

    strategy:
      matrix:
        os: [macos-14, macos-15, macos-latest]
        build_type: ["Debug", "Release"]

    steps:
      - uses: actions/checkout@v4

      - name: Configure build
        run: cmake -Bbuild -DCMAKE_BUILD_TYPE=${{ matrix.build_type}} -DWARNINGS_AS_ERRORS=ON .

      - name: Build
        working-directory: build
        run: make

      - name: binding-functions
        working-directory: build
        run: |
          make binding-functions
          test -s binding-functions

      - name: Tests
        working-directory: build
        run: |
          make test
          sudo make install

      - name: Examples
        run: |
          mkdir build/examples
          cd build/examples
          cmake -DCMAKE_BUILD_TYPE=${{ matrix.build_type}} ../../examples
          make
          make test
