vision-rs 0.1.1

A high-performance computer vision SDK for Rust.
name: Rust CI

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

env:
  CARGO_TERM_COLOR: always

jobs:
  build-test-clippy:
    name: Build, test, clippy
    runs-on: ubuntu-latest
    # Cargo.toml's [patch.crates-io] section unconditionally resolves
    # teeny-* deps to ../teenygrad/... (every cargo invocation reads it,
    # regardless of which features are enabled) -- must exist as an actual
    # sibling directory, matching the local dev layout. actions/checkout
    # refuses a path outside github.workspace (confirmed via a live failed
    # run: "Repository path '.../teenygrad' is not under '.../vision-rs'"),
    # so both repos are checked out as sibling *subdirectories* of the
    # workspace instead, with this job's working directory pointed at the
    # vision-rs one -- ../teenygrad from there resolves to the teenygrad
    # subdirectory, a true sibling on disk either way.
    defaults:
      run:
        working-directory: vision-rs
    steps:
      - name: Checkout repository
        uses: actions/checkout@v4
        with:
          path: vision-rs

      - name: Checkout teenygrad (sibling dependency)
        uses: actions/checkout@v4
        with:
          repository: teenygrad/teenygrad
          path: teenygrad
          submodules: true

      - name: Install Rust toolchain
        uses: dtolnay/rust-toolchain@stable
        with:
          components: clippy, rustfmt

      - name: Cache cargo registry and build artifacts
        uses: Swatinem/rust-cache@v2
        with:
          workspaces: vision-rs

      # The cuda feature (on by default) pulls in teeny-cuda, whose build.rs
      # unconditionally runs bindgen against real CUDA headers. Installed
      # directly via apt (not the Jimver/cuda-toolkit action -- see
      # teenygrad's deploy-docs.yml for why: its version table doesn't cover
      # every release, and its default package selection pulls in the real
      # nvidia-driver/nvidia-dkms packages, which fail to configure on
      # hosted runners with no matching kernel). Only the -dev packages
      # build.rs actually links against are installed -- no driver/dkms.
      # cuda-profiler-api-13-2 is a separate package from cuda-cudart-dev
      # (confirmed via `dpkg -S cuda_profiler_api.h` -- teeny-cuda's
      # wrapper.h includes it directly). The nvcc-config-common package
      # symlinks /usr/local/cuda -> /usr/local/cuda-13.2 via
      # update-alternatives but does NOT put /usr/local/cuda/bin on PATH --
      # add it explicitly so both bindgen and docs-site/build.sh's `command
      # -v nvcc` detection find it (a real gap discovered here: teenygrad's
      # own deploy-docs.yml has been silently skipping teeny-cuda/
      # teeny-kernels docs this whole time for exactly this reason).
      - name: Install CUDA toolkit
        run: |
          wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2404/x86_64/cuda-keyring_1.1-1_all.deb -O /tmp/cuda-keyring.deb
          sudo dpkg -i /tmp/cuda-keyring.deb
          sudo apt-get update
          sudo apt-get install -y --no-install-recommends \
            cuda-nvcc-13-2 cuda-cudart-dev-13-2 cuda-nvrtc-dev-13-2 cuda-driver-dev-13-2 cuda-profiler-api-13-2
          echo "/usr/local/cuda/bin" >> "$GITHUB_PATH"

      - name: Build
        run: cargo build --all-features

      - name: Clippy
        # --all-targets is deliberately omitted: examples/yolo26.rs (a large,
        # separate CLI tool) has pre-existing clippy/fmt debt out of scope
        # for this pass. Default clippy (lib + bins only) doesn't touch it.
        run: cargo clippy --all-features -- -D warnings

      # Even the hardware-independent snapshot tests (comparing generated
      # PTX/MLIR text, not running it) call compile_kernel, which shells
      # out to teenyc -- a separate compiler fork, not part of the stable
      # rustc used to build everything else (confirmed via a live failed
      # run: "rustc not found at teenyc"). Installed via cargo-teeny, which
      # fetches a prebuilt release rather than building teenyc from source.
      - name: Install teenyc toolchain
        run: |
          cargo install --git https://github.com/teenygrad/cargo-teeny
          cargo teeny install-toolchain
          echo "TEENYC_PATH=$HOME/.rustup/toolchains/stable-teenyc-x86_64-unknown-linux-gnu/bin/teenyc" >> "$GITHUB_ENV"

      - name: Test
        # No CUDA-capable GPU on hosted runners -- installing the toolkit
        # above gets headers for bindgen (so Build/Clippy above exercise the
        # full feature set), but actually *running* a kernel still needs a
        # real device. --no-default-features runs the hardware-independent
        # subset (mostly graph/snapshot tests, which still need teenyc --
        # see above -- to compile kernel source to PTX/MLIR for comparison,
        # even though nothing gets executed on a device). Full CUDA-hardware
        # integration testing is a local/GPU-runner-only activity for now.
        run: cargo test --no-default-features

      - name: Doc build
        run: cargo doc --no-deps --all-features