|
| 1 | +name: Test rust package |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - rust-api |
| 7 | + workflow_dispatch: |
| 8 | + |
| 9 | +concurrency: |
| 10 | + group: test-rust-package-${{ github.ref }} |
| 11 | + cancel-in-progress: true |
| 12 | + |
| 13 | +jobs: |
| 14 | + test-rust-package: |
| 15 | + runs-on: ${{ matrix.os }} |
| 16 | + strategy: |
| 17 | + fail-fast: false |
| 18 | + matrix: |
| 19 | + os: [ubuntu-latest, macos-latest, macos-15-intel, ubuntu-22.04-arm] |
| 20 | + |
| 21 | + env: |
| 22 | + # Placeholder, will be overwritten per OS |
| 23 | + SHERPA_ONNX_LIB_DIR: "" |
| 24 | + RUSTFLAGS: "" |
| 25 | + |
| 26 | + steps: |
| 27 | + # Checkout the repository |
| 28 | + - uses: actions/checkout@v4 |
| 29 | + |
| 30 | + # Install Rust stable |
| 31 | + - uses: actions-rust-lang/setup-rust-toolchain@v1 |
| 32 | + with: |
| 33 | + toolchain: stable |
| 34 | + |
| 35 | + # Download prebuilt libraries depending on OS |
| 36 | + - name: Download prebuilt Sherpa-ONNX libraries |
| 37 | + shell: bash |
| 38 | + run: | |
| 39 | + SHERPA_ONNX_VERSION=$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2) |
| 40 | +
|
| 41 | + if [[ "${{ matrix.os }}" == "macos-latest" ]]; then |
| 42 | + d=sherpa-onnx-v$SHERPA_ONNX_VERSION-osx-universal2-shared |
| 43 | + elif [[ "${{ matrix.os }}" == "macos-15-intel" ]]; then |
| 44 | + d=sherpa-onnx-v$SHERPA_ONNX_VERSION-osx-universal2-shared |
| 45 | + elif [[ "${{ matrix.os }}" == "ubuntu-latest" ]]; then |
| 46 | + d=sherpa-onnx-v$SHERPA_ONNX_VERSION-linux-x64-shared |
| 47 | + elif [[ "${{ matrix.os }}" == "ubuntu-22.04-arm" ]]; then |
| 48 | + d=sherpa-onnx-v$SHERPA_ONNX_VERSION-linux-aarch64-shared-cpu |
| 49 | + else |
| 50 | + echo "Unknown ${{ matrix.os }}" |
| 51 | + exit 1 |
| 52 | + fi |
| 53 | +
|
| 54 | + LIB_URL="https://github.com/k2-fsa/sherpa-onnx/releases/download/v$SHERPA_ONNX_VERSION/$d.tar.bz2" |
| 55 | +
|
| 56 | + curl -SsL -O "$LIB_URL" |
| 57 | + tar -xvf $d.tar.bz2 |
| 58 | +
|
| 59 | + ls -lh $d/lib |
| 60 | +
|
| 61 | + # Export environment variables for this step |
| 62 | + echo "SHERPA_ONNX_LIB_DIR=$PWD/$d/lib" >> $GITHUB_ENV |
| 63 | + echo "RUSTFLAGS=-C link-arg=-Wl,-rpath,$PWD/$d/lib" >> $GITHUB_ENV |
| 64 | +
|
| 65 | + - name: Show libs |
| 66 | + shell: bash |
| 67 | + run: | |
| 68 | + echo "SHERPA_ONNX_LIB_DIR: $SHERPA_ONNX_LIB_DIR" |
| 69 | + ls -lh $SHERPA_ONNX_LIB_DIR |
| 70 | +
|
| 71 | + echo "RUSTFLAGS: $RUSTFLAGS" |
| 72 | +
|
| 73 | + # Test using published crates.io dependencies |
| 74 | + - name: Test Published Crates |
| 75 | + shell: bash |
| 76 | + run: | |
| 77 | + cd rust-api-examples |
| 78 | + git checkout Cargo.toml |
| 79 | + cargo clean |
| 80 | + # cargo test --locked --all-features |
| 81 | + cargo run --example version |
0 commit comments