name: macOS Monterey 12

on:
  push:
    branches:
      - master
  pull_request:
    branches:
      - master

jobs:
  build_on_mac:
    strategy:
      matrix:
        mode: [Debug, Release]
        ssl: [OFF]

    runs-on: macos-latest

    steps:
      - name: Checkout
        uses: actions/checkout@master

      - name: SetUp HomeBrew
        id: set-up-homebrew
        uses: Homebrew/actions/setup-homebrew@master
      
      - name: Install Dependencies
        run: HOMEBREW_NO_INSTALL_CLEANUP=1 HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=1 brew install openssl protobuf

      - name: Configure CMake
        run: OPENSSL_ROOT_DIR=/usr/local/opt/openssl@3 CXX=clang++ CC=clang cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{matrix.mode}} -DCINATRA_ENABLE_SSL=${{matrix.ssl}}

      - name: Build
        run: cmake --build ${{github.workspace}}/build --config ${{matrix.mode}}

      - name: Test
        working-directory: ${{github.workspace}}/build
        run: ctest -C ${{matrix.mode}} -j -V

      - name: Upload Artifact
        uses: actions/upload-artifact@v4
        if: failure()
        with: 
          name: LastTest.log
          if-no-files-found: ignore
          path: ${{ github.workspace }}/build/Testing/Temporary/LastTest.log
