name: CodSpeed

on:
  workflow_dispatch:

jobs:
  benchmarks:
    name: Run benchmarks
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6.0.1

      - uses: nixbuild/nix-quick-install-action@2c9db80fb984ceb1bcaa77cdda3fdf8cfba92035
        with:
          github_access_token: ${{ secrets.GITHUB_TOKEN }}
      - name: Populate the nix store
        run: nix develop --command echo

      - name: Build the benchmark target(s)
        run: nix develop --command cargo codspeed build -p bench --jobs 1

      - name: Run benchmarks
        uses: CodSpeedHQ/action@v4
        with:
          token: ${{ secrets.CODSPEED_TOKEN }}
          run: nix develop --command cargo codspeed run -p bench
        env:
          RUST_BACKTRACE: 1
