name: Swift Build and Test in DevContainer
on:
  push:
  pull_request:

jobs:
  build:
    name: Swift on ubuntu-latest
    runs-on: ubuntu-latest

    steps:
    - name: Checkout
      uses: actions/checkout@v4
      with:
        submodules: true

    - name: Download pre-built llama.cpp binaries
      run: |
        wget -O llama-cpp-bin.zip "https://github.com/fkunn1326/llama.cpp/releases/download/b4846/llama-b4846-bin-ubuntu-x64.zip"
        unzip llama-cpp-bin.zip -d llama-cpp-bin

    - name: Copy llama.cpp binaries
      run: cp llama-cpp-bin/build/bin/lib*.so ./

    - name: Build and Test in DevContainer
      uses: devcontainers/ci@v0.3
      with:
        push: never
        runCmd: |
          swift build -c release -Xswiftc -strict-concurrency=complete -Xlinker -L./ -v
          cp llama-cpp-bin/build/bin/lib*.so .build/*/release/
          swift test -c release -Xswiftc -strict-concurrency=complete -Xlinker -L./ -v
