name: CLI experience

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

concurrency:
  group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
  cancel-in-progress: true

env:
  STABLE_PYTHON_VERSION: '3.12'
  HYPERFINE_VERSION: '1.18.0'

jobs:
  response-time:
    name: CLI responsiveness with latest Python
    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v4

    - name: Set up Python ${{ env.STABLE_PYTHON_VERSION }}
      uses: actions/setup-python@v5
      with:
        python-version: ${{ env.STABLE_PYTHON_VERSION }}

    - name: Install UV
      uses: astral-sh/setup-uv@v3

    - name: Install hyperfine
      uses: taiki-e/install-action@v2
      with:
        tool: hyperfine@${{ env.HYPERFINE_VERSION }}

    - name: Install other tools
      run: uv pip install --system --upgrade flit poetry pipenv

    - name: Install ourself
      run: |
        uv pip install --system .

    - name: Benchmark
      run: |
        hyperfine -m 100 --warmup 10 -i pipenv
        hyperfine -m 100 --warmup 10 poetry
        hyperfine -m 100 --warmup 10 -i flit
        hyperfine -m 100 --warmup 10 hatch
