name: Benchmark Reports

on:
  schedule:
    - cron: "0 0 * * MON"

env:
  CARGO_TERM_COLOR: always
  NODE_VERSION: "22.14.0"
  PYTHON_VERSION: "3.11"
  RUST_TOOLCHAIN_VERSION: "1.95"

jobs:
  runBenchmark:
    runs-on: ubuntu-latest
    name: run benchmark
    permissions:
      contents: read
      pull-requests: write
    steps:
      - uses: actions/checkout@v6
        with:
          fetch-depth: 0
          ref: main
      - uses: actions/setup-python@v6
        with:
          python-version: ${{ env.PYTHON_VERSION }}
      - name: setup rust
        uses: actions-rs/toolchain@v1
        with:
          toolchain: ${{ env.RUST_TOOLCHAIN_VERSION }}
      - name: setup cargo criterion
        run: cargo install cargo-criterion
      - name: run benching script
        run: ./build.py --ci-bench --no-check-prereqs
      - name: preserve bench artifacts
        uses: actions/upload-artifact@v6
        with:
          name: benchmarks
          path: |
            *.json
