# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: Validation
on:
  push:
    branches: [master]
  pull_request:
    branches: [master]
jobs:
  test:
    name: Python ${{ matrix.python-version }}
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        python-version: ["3.10", "3.11", "3.12", "3.13"]
    steps:
      - name: Checkout
        uses: actions/checkout@v4
      - name: Set up Python ${{ matrix.python-version }}
        id: setup-python
        uses: actions/setup-python@v5
        with:
          python-version: ${{ matrix.python-version }}
      - name: Setup uv
        uses: astral-sh/setup-uv@v1
      - name: Install dependencies
        run: |
          uv sync --dev
      - name: Format check
        run: |
          uv run ruff format --check .
      - name: Lint
        run: |
          uv run ruff check
      - name: Type check
        run: |
          uv run mypy krcg
      - name: Test
        env:
          LOCAL_CARDS: 1
        run: |
          uv run coverage run -m pytest
          uv run coverage xml
      - name: Upload coverage to Codacy
        if: github.event_name == 'push' && matrix.python-version == '3.12'
        uses: codacy/codacy-coverage-reporter-action@v1
        with:
          project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
          coverage-reports: coverage.xml
