feat: use official spacetimedb-sdk 2.0 with real SpacetimeDB server #9
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 Benchmark | |
| on: | |
| push: | |
| branches: [main, master] | |
| paths: ['rust/**', '.github/workflows/rust-benchmark.yml'] | |
| pull_request: | |
| branches: [main, master] | |
| paths: ['rust/**', '.github/workflows/rust-benchmark.yml'] | |
| env: | |
| CARGO_TERM_COLOR: always | |
| RUST_BACKTRACE: 1 | |
| defaults: | |
| run: | |
| working-directory: rust | |
| jobs: | |
| test: | |
| name: Test (${{ matrix.os }}) | |
| runs-on: ${{ matrix.os }} | |
| timeout-minutes: 360 | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest, macos-latest, windows-latest] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup Rust (nightly) | |
| uses: dtolnay/rust-toolchain@master | |
| with: | |
| toolchain: nightly | |
| components: rustfmt, clippy | |
| - name: Cache cargo registry | |
| uses: Swatinem/rust-cache@v2 | |
| with: | |
| workspaces: rust -> target | |
| cache-on-failure: "true" | |
| - name: Check formatting | |
| run: cargo fmt --all -- --check | |
| - name: Run Clippy | |
| run: cargo clippy --all-targets | |
| - name: Run tests | |
| run: cargo test | |
| benchmark: | |
| name: Benchmark | |
| runs-on: ubuntu-latest | |
| needs: [test] | |
| if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master') | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Setup Rust (nightly) | |
| uses: dtolnay/rust-toolchain@master | |
| with: | |
| toolchain: nightly | |
| - name: Setup Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.11' | |
| - name: Install Python dependencies | |
| run: pip install matplotlib numpy | |
| - name: Cache cargo registry | |
| uses: Swatinem/rust-cache@v2 | |
| with: | |
| workspaces: rust -> target | |
| cache-on-failure: "true" | |
| - name: Build benchmark | |
| run: cargo build --release | |
| - name: Run benchmark | |
| env: | |
| BENCHMARK_LINK_COUNT: 1000 | |
| BACKGROUND_LINK_COUNT: 3000 | |
| run: cargo bench --bench bench -- --output-format bencher | tee out.txt | |
| - name: Generate charts | |
| run: python3 out.py | |
| - name: Configure git | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| - name: Commit benchmark results | |
| run: | | |
| git add -f out.txt bench_rust.png bench_rust_log_scale.png 2>/dev/null || true | |
| git diff --staged --quiet || git commit -m "chore: update benchmark results [skip ci]" | |
| git push | |
| - name: Upload benchmark artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: benchmark-results | |
| path: | | |
| rust/out.txt | |
| rust/bench_rust.png | |
| rust/bench_rust_log_scale.png |