| 1 | name: Rust |
| 2 | |
| 3 | on: |
| 4 | push: |
| 5 | branches: |
| 6 | - main |
| 7 | pull_request: |
| 8 | paths: |
| 9 | - Cargo.toml |
| 10 | - rust/** |
| 11 | - .github/workflows/rust.yml |
| 12 | |
| 13 | concurrency: |
| 14 | group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} |
| 15 | cancel-in-progress: true |
| 16 | |
| 17 | env: |
| 18 | # This env var is used by Swatinem/rust-cache@v2 for the cache |
| 19 | # key, so we set it to make sure it is always consistent. |
| 20 | CARGO_TERM_COLOR: always |
| 21 | # Disable full debug symbol generation to speed up CI build and keep memory down |
| 22 | # "1" means line tables only, which is useful for panic tracebacks. |
| 23 | RUSTFLAGS: "-C debuginfo=1" |
| 24 | RUST_BACKTRACE: "1" |
| 25 | |
| 26 | jobs: |
| 27 | lint: |
| 28 | timeout-minutes: 30 |
| 29 | runs-on: ubuntu-24.04 |
| 30 | defaults: |
| 31 | run: |
| 32 | shell: bash |
| 33 | env: |
| 34 | # Need up-to-date compilers for kernels |
| 35 | CC: clang-18 |
| 36 | CXX: clang++-18 |
| 37 | steps: |
| 38 | - uses: actions/checkout@v4 |
| 39 | with: |
| 40 | fetch-depth: 0 |
| 41 | lfs: true |
| 42 | - uses: Swatinem/rust-cache@v2 |
| 43 | with: |
| 44 | workspaces: rust |
| 45 | - name: Install dependencies |
| 46 | run: | |
| 47 | sudo apt update |
| 48 | sudo apt install -y protobuf-compiler libssl-dev |
| 49 | - name: Run format |
| 50 | run: cargo fmt --all -- --check |
| 51 | - name: Run clippy |
| 52 | run: cargo clippy --workspace --tests --all-features -- -D warnings |
| 53 | linux: |
| 54 | timeout-minutes: 30 |
| 55 | # To build all features, we need more disk space than is available |
| 56 | # on the free OSS github runner. This is mostly due to the the |
| 57 | # sentence-transformers feature. |
| 58 | runs-on: ubuntu-2404-4x-x64 |
| 59 | defaults: |
| 60 | run: |
| 61 | shell: bash |
| 62 | working-directory: rust |
| 63 | env: |
| 64 | # Need up-to-date compilers for kernels |
| 65 | CC: clang-18 |
| 66 | CXX: clang++-18 |
| 67 | steps: |
| 68 | - uses: actions/checkout@v4 |
| 69 | with: |
| 70 | fetch-depth: 0 |
| 71 | lfs: true |
| 72 | - uses: Swatinem/rust-cache@v2 |
| 73 | with: |
| 74 | workspaces: rust |
| 75 | - name: Install dependencies |
| 76 | run: | |
| 77 | sudo apt update |
| 78 | sudo apt install -y protobuf-compiler libssl-dev |
| 79 | - name: Make Swap |
| 80 | run: | |
| 81 | sudo fallocate -l 16G /swapfile |
| 82 | sudo chmod 600 /swapfile |
| 83 | sudo mkswap /swapfile |
| 84 | sudo swapon /swapfile |
| 85 | - name: Start S3 integration test environment |
| 86 | working-directory: . |
| 87 | run: docker compose up --detach --wait |
| 88 | - name: Build |
| 89 | run: cargo build --all-features |
| 90 | - name: Run tests |
| 91 | run: cargo test --all-features |
| 92 | - name: Run examples |
| 93 | run: cargo run --example simple |
| 94 | macos: |
| 95 | timeout-minutes: 30 |
| 96 | strategy: |
| 97 | matrix: |
| 98 | mac-runner: [ "macos-13", "macos-14" ] |
| 99 | runs-on: "${{ matrix.mac-runner }}" |
| 100 | defaults: |
| 101 | run: |
| 102 | shell: bash |
| 103 | working-directory: rust |
| 104 | steps: |
| 105 | - uses: actions/checkout@v4 |
| 106 | with: |
| 107 | fetch-depth: 0 |
| 108 | lfs: true |
| 109 | - name: CPU features |
| 110 | run: sysctl -a | grep cpu |
| 111 | - uses: Swatinem/rust-cache@v2 |
| 112 | with: |
| 113 | workspaces: rust |
| 114 | - name: Install dependencies |
| 115 | run: brew install protobuf |
| 116 | - name: Build |
| 117 | run: cargo build --all-features |
| 118 | - name: Run tests |
| 119 | # Run with everything except the integration tests. |
| 120 | run: cargo test --features remote,fp16kernels |
| 121 | windows: |
| 122 | runs-on: windows-2022 |
| 123 | steps: |
| 124 | - uses: actions/checkout@v4 |
| 125 | - uses: Swatinem/rust-cache@v2 |
| 126 | with: |
| 127 | workspaces: rust |
| 128 | - name: Install Protoc v21.12 |
| 129 | working-directory: C:\ |
| 130 | run: | |
| 131 | New-Item -Path 'C:\protoc' -ItemType Directory |
| 132 | Set-Location C:\protoc |
| 133 | Invoke-WebRequest https://github.com/protocolbuffers/protobuf/releases/download/v21.12/protoc-21.12-win64.zip -OutFile C:\protoc\protoc.zip |
| 134 | 7z x protoc.zip |
| 135 | Add-Content $env:GITHUB_PATH "C:\protoc\bin" |
| 136 | shell: powershell |
| 137 | - name: Run tests |
| 138 | run: | |
| 139 | $env:VCPKG_ROOT = $env:VCPKG_INSTALLATION_ROOT |
| 140 | cargo build |
| 141 | cargo test |