name: Test CUDA

on:
    push:
        branches: ["main"]
    pull_request:
        branches: ["main"]
    workflow_dispatch:

env:
    CARGO_TERM_COLOR: always

jobs:
    cuda_unit_test:
        name: Cuda Unit Tests
        runs-on: cuda_t4_runner
        container:
            image: ghcr.io/luminal-ai/luminal-docker:cuda
            options: --gpus all
        timeout-minutes: 30

        steps:
            - uses: actions/checkout@v6
            - name: Detect GPU compute capability
              run: |
                  CAP=$(nvidia-smi --query-gpu=compute_cap --format=csv,noheader | head -1 | tr -d '.')
                  echo "CUDA_COMPUTE_CAP=${CAP}" >> "$GITHUB_ENV"
            - name: Run CUDA crate tests
              run: cargo test -p luminal_cuda_lite --verbose -- --test-threads=1
