portail 2.1.0

Unified proxy/gateway: AI Gateway + MCP Gateway + CDN cache
Documentation
name: Benchmark Gate

# Architecture: Runs on PRs that touch Rust code or Cargo files.
# Uses cargo-criterion to run benchmarks and compares against main branch.
# If any benchmark regresses by more than 200%, it comments on the PR.
# Runs on self-hosted runner (dev-cx53) for consistent performance measurements.

on:
  pull_request:
    branches: [main]
    paths:
      - src/**/*.rs
      - Cargo.toml
      - Cargo.lock
      - benches/**/*.rs

env:
  CARGO_TERM_COLOR: always
  RUSTFLAGS: -D warnings

jobs:
  bench:
    runs-on: self-hosted
    steps:
      - uses: actions/checkout@v7
        with:
          fetch-depth: 0

      - uses: actions-rust-lang/setup-rust-toolchain@v1

      - name: Cache cargo registry
        uses: actions/cache@v6
        with:
          path: |
            ~/.cargo/registry
            ~/.cargo/git
          key: bench-cargo-registry-${{ hashFiles('Cargo.lock') }}
          restore-keys: bench-cargo-registry-

      - name: Install cargo-criterion
        uses: baptiste0928/cargo-install@v3
        with:
          crate: cargo-criterion

      - name: Build bench deps
        run: cargo build --benches --locked

      - name: Run benchmarks
        run: cargo criterion --message-format=json 2>&1 | tee bench-output.json

      - uses: benchmark-action/github-action-benchmark@v1
        with:
          tool: cargo
          output-file-path: bench-output.json
          github-token: ${{ secrets.GITHUB_TOKEN }}
          auto-push: false
          alert-threshold: "200%"
          comment-on-alert: true
          summary-always: true