name: macOS

on:
  push:
    branches: [ master ]
  pull_request:
    branches: [ master ]

jobs:
  build:
    if: "! contains(toJSON(github.event.commits.*.message), '[ci skip]')"

    name: Build and Test (macOS) - ${{ matrix.os }}-${{ matrix.arch }}
    runs-on: ${{ matrix.os }}

    strategy:
      matrix:
        include:
          - os: macos-15-intel
            arch: x64
          - os: macos-latest
            arch: arm64

    steps:
    - uses: actions/checkout@v1
      with:
        submodules: true

    - name: configure
      run: cd test && mkdir build && cd build && cmake -DCMAKE_BUILD_TYPE=Debug -DPOLYSCOPE_BACKEND_OPENGL3_GLFW=ON -DPOLYSCOPE_BACKEND_OPENGL_MOCK=ON ..

    - name: build
      run: cd test/build && cmake --build "." --parallel

    - name: run test
      run: cd test/build && ./bin/polyscope-test --gtest_catch_exceptions=0 backend=openGL_mock
  
  build_shared:
    if: "! contains(toJSON(github.event.commits.*.message), '[ci skip]')"
    
    name: Build Shared and Test (macOS) - ${{ matrix.os }}-${{ matrix.arch }}
    runs-on: ${{ matrix.os }}

    strategy:
      matrix:
        include:
          - os: macos-15-intel
            arch: x64
          - os: macos-latest
            arch: arm64

    steps:
    - uses: actions/checkout@v1
      with:
        submodules: true

    - name: configure
      run: cd test && mkdir build && cd build && cmake -DBUILD_SHARED_LIBS=TRUE -DCMAKE_BUILD_TYPE=Debug -DPOLYSCOPE_BACKEND_OPENGL3_GLFW=ON -DPOLYSCOPE_BACKEND_OPENGL_MOCK=ON ..

    - name: build
      run: cd test/build && cmake --build "." --parallel

    - name: run test
      run: cd test/build && ./bin/polyscope-test --gtest_catch_exceptions=0 backend=openGL_mock
