name: 🔗 Static Linking
on:
  workflow_dispatch:
    inputs:
      onnxruntime-branch:
        type: string
        description: "ONNX Runtime branch"
        default: "v1.24.3"
  push:
    paths:
      - 'ort-sys/build/**/*.rs'
  pull_request:
    types: [ opened, synchronize, reopened ]
    paths:
      - 'ort-sys/build/**/*.rs'
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:
  static-link-linux:
    name: Linux (x64)
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v5
      - name: Compile ONNX Runtime
        run: |
          git clone https://github.com/microsoft/onnxruntime --recursive --branch ${{ inputs.onnxruntime-branch || 'v1.24.3' }} --single-branch --depth 1
          cd onnxruntime
          ./build.sh --update --build --config Release --parallel --compile_no_warning_as_error --skip_submodule_sync
          cd ..
      - name: Install stable Rust toolchain
        uses: dtolnay/rust-toolchain@stable
        with:
          toolchain: stable
      - uses: Swatinem/rust-cache@v2.7.8
      - name: Run test
        run: |
          ORT_LIB_PATH="$(pwd)/onnxruntime/build/Linux/Release" cargo example-custom-ops
  # minimal-build:
  #   name: Minimal build
  #   runs-on: ubuntu-latest
  #   steps:
  #     - uses: actions/checkout@v5
  #     - name: Compile ONNX Runtime
  #       run: |
  #         git clone https://github.com/microsoft/onnxruntime --recursive --branch ${{ inputs.onnxruntime-branch || 'v1.24.3' }} --single-branch --depth 1
  #         cd onnxruntime
  #         ./build.sh --update --build --config Release --parallel --compile_no_warning_as_error --skip_submodule_sync --minimal_build
  #         cd ..
  #     - name: Install stable Rust toolchain
  #       uses: dtolnay/rust-toolchain@stable
  #       with:
  #         toolchain: stable
  #     - uses: Swatinem/rust-cache@v2.7.8
  #     - name: Test linking
  #       run: |
  #         ORT_LIB_PATH="$(pwd)/onnxruntime/build/Linux/Release" cargo build --manifest-path examples/custom-ops/Cargo.toml --example custom-ops --target-dir target
