Feat: Initial benchmark suite #43
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/CD | |
| on: | |
| push: | |
| branches: ["main"] | |
| tags: | |
| - "v*" | |
| pull_request: | |
| branches: ["main"] | |
| env: | |
| CARGO_TERM_COLOR: always | |
| RUST_BACKTRACE: 1 | |
| jobs: | |
| benchmark: | |
| name: Run Benchmarks | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install system dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y software-properties-common | |
| sudo add-apt-repository universe | |
| sudo apt-get update | |
| sudo apt-get install -y build-essential simstring-bin | |
| - name: Install Rust toolchain | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| toolchain: stable | |
| components: rustfmt, clippy | |
| - name: Rust Benchmarks | |
| run: | | |
| echo "Running Rust benchmarks..." | |
| cargo bench | |
| - name: Run SimString C++ benchmarks | |
| run: | | |
| echo "Running C++ benchmarks..." | |
| bash benches/bench_cpp.sh | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.13" | |
| - name: Run Python Benchmarks | |
| run: | | |
| pip install uv | |
| uv venv | |
| source .venv/bin/activate | |
| uv pip install simstring-fast | |
| echo "Running Python Benchmarks..." | |
| uv run benches/bench.py | |
| - name: Set up Ruby | |
| uses: ruby/setup-ruby@v1 | |
| with: | |
| ruby-version: "3.3" | |
| bundler-cache: true | |
| - name: Run Ruby Benchmarks | |
| run: | | |
| gem install simstring_pure | |
| gem install descriptive_statistics | |
| echo "Running Ruby benchmarks..." | |
| ruby benches/bench.rb | |
| - name: Set up Julia | |
| uses: julia-actions/setup-julia@v2 | |
| with: | |
| version: "1.11" | |
| - name: Run Julia Benchmarks | |
| run: | | |
| julia -e 'using Pkg; Pkg.add(["SimString", "BenchmarkTools", "Statistics"])' | |
| echo "Running Julia benchmarks..." | |
| julia benches/bench.jl | |
| test: | |
| name: Test on ${{ matrix.os }} / ${{ matrix.rust }} | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest, windows-latest, macos-latest] | |
| rust: [stable] | |
| include: | |
| - os: ubuntu-latest | |
| rust: stable | |
| target: x86_64-unknown-linux-gnu | |
| - os: ubuntu-latest | |
| rust: stable | |
| target: aarch64-unknown-linux-gnu | |
| - os: windows-latest | |
| rust: stable | |
| target: x86_64-pc-windows-msvc | |
| - os: macos-latest | |
| rust: stable | |
| target: x86_64-apple-darwin | |
| - os: macos-latest | |
| rust: stable | |
| target: aarch64-apple-darwin | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install Rust toolchain | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| toolchain: ${{ matrix.rust }} | |
| target: ${{ matrix.target }} | |
| components: rustfmt, clippy | |
| - name: Install cross | |
| if: matrix.target == 'aarch64-unknown-linux-gnu' | |
| run: cargo install cross | |
| - name: Set up cargo cache | |
| uses: actions/cache@v3 | |
| with: | |
| path: | | |
| ~/.cargo/bin/ | |
| ~/.cargo/registry/index/ | |
| ~/.cargo/registry/cache/ | |
| ~/.cargo/git/db/ | |
| target/ | |
| key: ${{ runner.os }}-${{ matrix.target }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
| restore-keys: ${{ runner.os }}-${{ matrix.target }}-cargo- | |
| - name: Check formatting | |
| run: cargo fmt --all -- --check | |
| - name: Run clippy | |
| if: matrix.target != 'aarch64-unknown-linux-gnu' | |
| run: cargo clippy --target ${{ matrix.target }} -- -D warnings | |
| - name: Run clippy (cross) | |
| if: matrix.target == 'aarch64-unknown-linux-gnu' | |
| run: cross clippy --target ${{ matrix.target }} -- -D warnings | |
| - name: Run tests | |
| if: matrix.target != 'aarch64-unknown-linux-gnu' | |
| run: cargo test --target ${{ matrix.target }} --verbose | |
| - name: Run tests (cross) | |
| if: matrix.target == 'aarch64-unknown-linux-gnu' | |
| run: cross test --target ${{ matrix.target }} --verbose | |
| - name: Build | |
| if: matrix.target != 'aarch64-unknown-linux-gnu' | |
| run: cargo build --target ${{ matrix.target }} --verbose | |
| - name: Build (cross) | |
| if: matrix.target == 'aarch64-unknown-linux-gnu' | |
| run: cross build --target ${{ matrix.target }} --verbose | |
| # Documentation check | |
| - name: Check documentation | |
| run: cargo doc --no-deps --document-private-items | |
| - name: Run benchmarks | |
| run: cargo bench --verbose | |
| # Publish to crates.io on new tags | |
| publish: | |
| name: Publish to crates.io | |
| needs: test | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install Rust toolchain | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Verify tag version matches Cargo.toml version | |
| run: | | |
| CARGO_VERSION=$(grep '^version =' Cargo.toml | cut -d '"' -f2) | |
| TAG_VERSION=${GITHUB_REF#refs/tags/v} | |
| echo "CARGO_VERSION: $CARGO_VERSION" | |
| echo "TAG_VERSION: $TAG_VERSION" | |
| if [ "$CARGO_VERSION" != "$TAG_VERSION" ]; then | |
| echo "Error: Git tag $TAG_VERSION doesn't match Cargo.toml version $CARGO_VERSION" | |
| exit 1 | |
| fi | |
| - name: Check package | |
| run: cargo package | |
| - name: Publish to crates.io | |
| run: cargo publish | |
| env: | |
| CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} |