name: macOS CI

on:
  push:
    paths-ignore:
      - ".devcontainer/**"
      - ".vscode/**"
      - "doc/**"
      - "*.md"
  pull_request:
    paths-ignore:
      - ".devcontainer/**"
      - ".vscode/**"
      - "doc/**"
      - "*.md"

jobs:
  macos-build:
    name: Build on macOS
    strategy:
      matrix:
        python-version: ["3.10"]
        compiler: ["clang"]
        include:
          - compiler: "clang"
            c_compiler: "/usr/local/opt/ccache/libexec/clang"
            cxx_compiler: "/usr/local/opt/ccache/libexec/clang++"
    runs-on: "macos-13"
    env:
      C_COMPILER: ${{ matrix.c_compiler }}
      CXX_COMPILER: ${{ matrix.cxx_compiler }}
      PYTHON: ${{ matrix.python-version }}
      CACHE_NAME: "ccache-qulacs-build-v2"
    steps:
      - uses: actions/checkout@v4

      - name: Setup cmake
        uses: lukka/get-cmake@latest

      - name: Setup ccache
        uses: hendrikmuhs/ccache-action@v1.2
        with:
          # Include compiler to distinguish cache for each compiler.
          key: ${{ github.job }}-macos-12-${{ matrix.compiler }}
          verbose: 2

      - name: Install Boost for macOS
        run: |
          brew update
          brew install boost
          brew link boost

      - name: Setup Python
        uses: actions/setup-python@v5
        with:
          python-version: ${{ matrix.python-version }}

      - name: Install qulacs for macOS
        run: USE_TEST=Yes ./script/build_gcc.sh

      - name: Install qulacs Python module
        run: pip install .[ci]

      - name: Test in macOS
        run: |
          cd ./build
          make test -j
          make pythontest -j
