feat: implement ABI-compatible library download system #5
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Rust CI | |
| on: | |
| push: | |
| branches: [ main ] | |
| paths: | |
| - 'src/**' | |
| - 'Cargo.toml' | |
| - 'Cargo.lock' | |
| - '.github/workflows/rust-ci.yml' | |
| pull_request: | |
| branches: [ main ] | |
| paths: | |
| - 'src/**' | |
| - 'Cargo.toml' | |
| - 'Cargo.lock' | |
| - '.github/workflows/rust-ci.yml' | |
| env: | |
| CARGO_TERM_COLOR: always | |
| permissions: | |
| contents: read | |
| jobs: | |
| rust-test: | |
| name: Rust Tests | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Install Rust toolchain | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| components: rustfmt, clippy | |
| - name: Cache cargo registry | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.cargo/registry | |
| ~/.cargo/git | |
| target | |
| key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
| - name: Check formatting | |
| run: cargo fmt -- --check | |
| - name: Run clippy | |
| run: cargo clippy -- -D warnings | |
| - name: Run Rust tests | |
| run: cargo test --verbose | |
| - name: Build library | |
| run: cargo build --release | |
| cross-compile: | |
| name: Cross compile ${{ matrix.target }} | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| # Linux GNU targets | |
| - target: x86_64-unknown-linux-gnu | |
| os: ubuntu-latest | |
| - target: aarch64-unknown-linux-gnu | |
| os: ubuntu-latest | |
| # Linux MUSL targets | |
| - target: x86_64-unknown-linux-musl | |
| os: ubuntu-latest | |
| - target: aarch64-unknown-linux-musl | |
| os: ubuntu-latest | |
| # macOS targets | |
| - target: x86_64-apple-darwin | |
| os: macos-latest | |
| - target: aarch64-apple-darwin | |
| os: macos-latest | |
| # Windows targets | |
| - target: x86_64-pc-windows-msvc | |
| os: windows-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Install Rust toolchain | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| targets: ${{ matrix.target }} | |
| - name: Install cross-compilation dependencies (Linux) | |
| if: matrix.os == 'ubuntu-latest' | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y \ | |
| gcc-aarch64-linux-gnu \ | |
| musl-tools \ | |
| g++-aarch64-linux-gnu \ | |
| libc6-dev-arm64-cross \ | |
| pkg-config | |
| - name: Cache cargo registry | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.cargo/registry | |
| ~/.cargo/git | |
| key: cross-${{ runner.os }}-${{ matrix.target }}-${{ hashFiles('**/Cargo.lock') }} | |
| - name: Install cross | |
| run: cargo install cross --git https://github.com/cross-rs/cross | |
| - name: Clean target dir (Unix) | |
| if: matrix.os != 'windows-latest' | |
| shell: bash | |
| run: rm -rf target | |
| - name: Clean target dir (Windows) | |
| if: matrix.os == 'windows-latest' | |
| shell: pwsh | |
| run: Remove-Item -Recurse -Force target -ErrorAction SilentlyContinue | |
| - name: Cross compile (Linux) | |
| if: matrix.os == 'ubuntu-latest' | |
| run: | | |
| cross build --release --target ${{ matrix.target }} | |
| - name: Cross compile (macOS) | |
| if: matrix.os == 'macos-latest' | |
| run: | | |
| cargo build --release --target ${{ matrix.target }} | |
| - name: Cross compile (Windows) | |
| if: matrix.os == 'windows-latest' | |
| run: | | |
| cargo build --release --target ${{ matrix.target }} | |
| - name: Verify library exists (Unix) | |
| if: matrix.os != 'windows-latest' | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| case "${{ matrix.target }}" in | |
| *-apple-darwin) ART="libtokenizers.dylib" ;; | |
| *-unknown-linux-gnu) ART="libtokenizers.so" ;; | |
| *-unknown-linux-musl) ART="libtokenizers.a" ;; | |
| *) echo "Unknown target: ${{ matrix.target }}"; exit 1 ;; | |
| esac | |
| P="target/${{ matrix.target }}/release/${ART}" | |
| echo "Expecting $P" | |
| ls -la "$P" | |
| file "$P" || true | |
| - name: Verify library exists (Windows) | |
| if: matrix.os == 'windows-latest' | |
| shell: pwsh | |
| run: | | |
| $art = "tokenizers.dll" | |
| $p = "target/${{ matrix.target }}/release/$art" | |
| Get-Item $p |