name: Benchmark

on:
  push:
    branches: [ "main" ]
  workflow_dispatch:

env:
  CARGO_TERM_COLOR: always

permissions:
  contents: write
  deployments: write

jobs:
  bench:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v6
      with:
        submodules: recursive
    - name: Install Rust stable
      run: rustup toolchain install stable --profile minimal && rustup default stable
    - name: Run benchmark
      run: cargo bench --bench solver -- --output-format bencher | tee bench-output.txt
    - name: Publish benchmark numbers
      uses: benchmark-action/github-action-benchmark@v1
      with:
        tool: cargo
        output-file-path: bench-output.txt
        github-token: ${{ secrets.GITHUB_TOKEN }}
        auto-push: true
        gh-pages-branch: gh-pages
        benchmark-data-dir-path: dev/bench
        alert-threshold: 200%
        comment-on-alert: false
        fail-on-alert: false
