whatsapp-rust 0.6.0

Rust client for WhatsApp Web
Documentation
name: Benchmark

on:
  pull_request:
    branches: [main]
  push:
    branches: [main]

permissions:
  contents: write
  pull-requests: write
  deployments: write

concurrency:
  group: benchmark-${{ github.head_ref || github.run_id }}
  cancel-in-progress: true

env:
  CARGO_TERM_COLOR: never
  IAI_CALLGRIND_COLOR: never
  PROTOC_VERSION: "3.25.3"
  SCCACHE_GHA_ENABLED: "true"
  RUSTC_WRAPPER: "sccache"

jobs:
  benchmark:
    name: iai-callgrind
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6

      - uses: dtolnay/rust-toolchain@master
        with:
          toolchain: nightly-2026-04-05

      - name: Install tools (protoc, valgrind, iai-callgrind-runner)
        uses: taiki-e/install-action@v2
        with:
          tool: protoc@${{ env.PROTOC_VERSION }},valgrind,iai-callgrind-runner@0.16.1

      - name: Setup sccache
        uses: mozilla-actions/sccache-action@v0.0.9

      - name: Cache Rust registry
        uses: Swatinem/rust-cache@v2
        with:
          prefix-key: ${{ runner.os }}-cargo-bench
          cache-targets: "false"

      - name: Run benchmarks
        run: cargo bench -p wacore -p wacore-binary -p wacore-libsignal | tee bench_output.txt

      - name: Parse results
        run: |
          python3 .github/scripts/iai-to-benchmark-json.py \
            < bench_output.txt \
            > bench_results.json

      - name: Upload benchmark artifacts
        uses: actions/upload-artifact@v4
        with:
          name: benchmark-results
          path: |
            bench_output.txt
            bench_results.json
          retention-days: 30

      # Save PR number so the comment workflow can find the PR
      - name: Save PR number
        if: github.event_name == 'pull_request'
        run: echo "${{ github.event.number }}" > pr_number.txt

      - name: Upload PR metadata
        if: github.event_name == 'pull_request'
        uses: actions/upload-artifact@v4
        with:
          name: pr-metadata
          path: pr_number.txt

      # Push to main: store baseline and update gh-pages charts
      - name: Store baseline (push to main)
        if: github.event_name == 'push'
        uses: benchmark-action/github-action-benchmark@v1
        with:
          name: "whatsapp-rust benchmarks"
          tool: "customSmallerIsBetter"
          output-file-path: bench_results.json
          github-token: ${{ secrets.GITHUB_TOKEN }}
          auto-push: true
          benchmark-data-dir-path: dev/bench
          max-items-in-chart: 100
          summary-always: true

      # PR: compare against baseline (job summary only, comment posted
      # by the separate benchmark-comment workflow which has write access)
      - name: Compare against baseline (pull request)
        if: github.event_name == 'pull_request'
        uses: benchmark-action/github-action-benchmark@v1
        with:
          name: "whatsapp-rust benchmarks"
          tool: "customSmallerIsBetter"
          output-file-path: bench_results.json
          github-token: ${{ secrets.GITHUB_TOKEN }}
          auto-push: false
          save-data-file: false
          benchmark-data-dir-path: dev/bench
          summary-always: true