diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..8dc9a96 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,43 @@ +name: CI Test + +on: + pull_request: + branches: [ "main" ] + push: + branches: [ "main" ] + +jobs: + test-apple-silicon: + name: Test on M1 Mac + runs-on: macos-14 + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.10' + + - name: Install Build Dependencies + run: | + pip install --upgrade pip setuptools wheel cmake pybind11 + + - name: Build Backend (CMake) + run: | + mkdir build + cd build + cmake -Dpybind11_DIR=$(python -m pybind11 --cmakedir) .. + cmake --build . + + - name: Install Library + # Installs your library in editable mode + run: pip install -e . + + - name: Install Test Dependencies + run: pip install pytest + + - name: Run Tests + run: | + pytest tests/ diff --git a/CMakeLists.txt b/CMakeLists.txt index aea68e1..d0fdbb1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,6 +18,18 @@ pybind11_add_module( cpp/src/metal_utils.mm ) +if(APPLE) + find_library(METAL_LIB Metal) + find_library(MPS_LIB MetalPerformanceShaders) + find_library(FOUNDATION_LIB Foundation) + + target_link_libraries(_backend PRIVATE + ${METAL_LIB} + ${MPS_LIB} + ${FOUNDATION_LIB} + ) +endif() + # Put output in python package set_target_properties(_backend PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/py/Forge