name: xmake

on:
  workflow_call:

jobs:
  build:
    strategy:
      fail-fast: false
      matrix:
        os: [windows-2025, ubuntu-24.04, macos-15]
        build_type: [debug, releasedbg]
        exclude:
          - os: windows-2025
            build_type: debug
    runs-on: ${{ matrix.os }}
    steps:
      - name: Checkout repository
        uses: actions/checkout@v4

      - name: Setup xmake
        uses: xmake-io/github-action-setup-xmake@v1
        with:
          xmake-version: 3.0.5
          actions-cache-folder: ".xmake-cache"
          actions-cache-key: ${{ matrix.os }}
          package-cache: true
          package-cache-key: ${{ matrix.os }}-pixi
          build-cache: true
          build-cache-key: ${{ matrix.os }}-${{ matrix.build_type }}

      - uses: ./.github/actions/setup-pixi

      - name: Build
        run: pixi run xmake ${{ matrix.build_type }}

      - name: Test
        run: pixi run xmake-test

      - name: Remove llvm package (Linux)
        if: runner.os == 'Linux'
        run: xmake require --uninstall clice-llvm
