name: CodSpeed Benchmarks

on:
  push:
    branches:
      - master
  pull_request:
    branches:
      - master

jobs:
  benchmarks:
    name: Run benchmarks
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Setup Python
        uses: actions/setup-python@v5
        with:
          python-version: "3.13"
      - name: Install Pythran dependencies
        run: |
          python -m pip install --upgrade pip
          python -m pip install .
          python -m pip install . 'pythran[build]'
      - name: Install Codspeed dependencies
        run: pip install pytest pytest-codspeed
      - name: Run the benchmarks
        uses: CodSpeedHQ/action@v4
        with:
          mode: instrumentation
          run: pytest pythran/benchmarks/ --codspeed
