name: MacOS
on: [push, pull_request]
env:
  BUILD_TYPE: Release
jobs:
  Build:
    runs-on: macos-12
    strategy:
      matrix:
        fips: [ON, OFF]
        arch: [x86_64, arm64]
    steps:
      - name: Setup Ninja
        run: brew install ninja
      - name: Setup cmake
        run: brew install cmake
      - name: Checkout
        uses: actions/checkout@v3
        with:
          submodules: true
      - run: cmake --version
      - name: Configure CMake
        shell: zsh {0}
        run: |
          cmake -B ${{github.workspace}}/build \
          -DBUILD_TESTS=true \
          -DFIPS=${{matrix.fips}} \
          -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} \
          -DCMAKE_OSX_ARCHITECTURES=${{matrix.arch}}
      - name: Build
        shell: zsh {0}
        working-directory: ${{github.workspace}}/build
        run: make
      - if: matrix.arch == 'x86_64'
        name: Test
        shell: zsh {0}
        working-directory: ${{github.workspace}}/build
        run: ctest --output-on-failure
      - name: Install
        shell: zsh {0}
        working-directory: ${{github.workspace}}/build
        run: make install
