name: CodSpeed Benchmarks

on:
  push:
    branches:
      - master
      - '[0-9].[0-9]+'
  pull_request:
    branches:
      - master
      - '[0-9].[0-9]+'

jobs:
  benchmark:
    name: Run CodSpeed Benchmarks (Python ${{ matrix.python-version }})
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v6

      - name: Set up Python
        uses: actions/setup-python@v6
        with:
          python-version: '3.13'
          cache: 'pip'
          cache-dependency-path: '**/requirements*.txt'

      - name: Install dependencies
        run: pip install -r requirements-benchmarks.txt

      - name: Create empty pytest config
        run: echo "[pytest]" > .empty-pytest.ini

      - name: Run the benchmarks
        uses: CodSpeedHQ/action@v4
        with:
          mode: instrumentation
          run: pytest -c .empty-pytest.ini --codspeed benchmark.py --timeout=0
          token: ${{ secrets.CODSPEED_TOKEN }}
