name: Python Tests

on:
  push:
    branches:
      - "main"
    paths:
      - "**/*.py"
      - "**/pyproject.toml"
      - '.github/workflows/pytest.yml'
  pull_request:
    branches:
      - "main"
      - "dev"
    paths:
      - "**/*.py"
      - "**/pyproject.toml"
      - '.github/workflows/pytest.yml'

jobs:
  test:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        python-version:
          - "3.11"

    concurrency:
      group: ci-task-lock
      cancel-in-progress: false

    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Install uv
        uses: astral-sh/setup-uv@v7
        with:
          python-version: ${{ matrix.python-version }}
          github-token: ${{ github.token }}

      - name: Install dependencies
        working-directory: ./src_py
        run: |
          uv venv
          uv pip install -e .[dev]

      - name: Run linter
        working-directory: ./src_py
        run: |
          make lint

      - name: Run tests
        working-directory: ./src_py
        run: |
          uv run pytest -vvv tests
        env:
          ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
          GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}
          OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
          ZAI_API_KEY: ${{ secrets.ZAI_API_KEY }}
          MOONSHOT_API_KEY: ${{ secrets.MOONSHOT_API_KEY }}
          DEEPSEEK_API_KEY: ${{ secrets.DEEPSEEK_API_KEY }}
          MODELVERSE_API_KEY: ${{ secrets.MODELVERSE_API_KEY }}
          OPENROUTER_API_KEY: ${{ secrets.OPENROUTER_API_KEY }}
          SILICONFLOW_API_KEY: ${{ secrets.SILICONFLOW_API_KEY }}
          BEDROCK_API_KEY: ${{ secrets.BEDROCK_API_KEY }}
          VERTEX_API_KEY: ${{ secrets.VERTEX_API_KEY }}
