name: 🧪 Cargo Tests
on:
  push:
    paths:
      - '.github/workflows/test.yml'
      - 'src/**/*.rs'
      - 'ort-sys/**/*.rs'
      - 'ort-sys/**/dist.txt'
      - 'Cargo.toml'
      - 'tests/**/*'
  pull_request:
    types: [ opened, synchronize, reopened ]
    paths:
      - '.github/workflows/test.yml'
      - 'src/**/*.rs'
      - 'ort-sys/**/*.rs'
      - 'ort-sys/**/dist.txt'
      - 'Cargo.toml'
      - 'tests/**/*'
permissions:
  contents: read
concurrency:
  group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}'
  cancel-in-progress: true
env:
  RUST_BACKTRACE: 1
jobs:
  test:
    name: Run tests
    runs-on: ${{ matrix.platform.os }}
    strategy:
      fail-fast: false
      matrix:
        platform:
          - os: ubuntu-latest
          - os: ubuntu-24.04-arm
          - os: windows-latest
          - os: macos-15
    steps:
      - uses: actions/checkout@v5
      - name: Install stable Rust toolchain
        uses: dtolnay/rust-toolchain@stable
        with:
          toolchain: stable
      - uses: Swatinem/rust-cache@v2.7.8
      - name: Run tests
        run: |
          cargo test -p ort --verbose --features fetch-models,tls-rustls -- --test-threads 1
