name: Tests

on:
  push:
    branches:
      - main
    paths:
      - "src/**"
      - "tests/**"
      - "pyproject.toml"
      - ".github/workflows/tests.yaml"
  pull_request:
    branches:
      - main
    paths:
      - "src/**"
      - "tests/**"
      - "pyproject.toml"
      - "package.json"
      - "package-lock.json"
      - ".github/workflows/tests.yaml"

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

jobs:
  python-tests:
    name: Python tests (Python ${{ matrix.python-version }})
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        python-version: ["3.11", "3.12", "3.13"]

    steps:
      - name: Checkout repository
        uses: actions/checkout@v6

      - name: Setup Python
        uses: actions/setup-python@v6
        with:
          python-version: ${{ matrix.python-version }}

      - name: Install uv
        uses: astral-sh/setup-uv@v7

      - name: Install dependencies
        run: uv pip install --system -e ".[dev]"

      - name: Run Python tests
        run: pytest tests/ -v --color=yes

  javascript-tests:
    name: JavaScript tests
    runs-on: ubuntu-latest

    steps:
      - name: Checkout repository
        uses: actions/checkout@v6

      - name: Install pixi
        uses: prefix-dev/setup-pixi@v0.9.4

      - name: Install npm dependencies
        run: pixi run npm install

      - name: Run JavaScript tests
        run: pixi run test-js
