name: Pyright Lint

on:
  push:
    branches:
      - master
  pull_request:
    paths:
      - "envs/**"
      - "nonebot/**"
      - "packages/**"
      - "tests/**"
      - ".github/actions/setup-python/**"
      - ".github/workflows/pyright.yml"
      - "pyproject.toml"
      - "uv.lock"

jobs:
  pyright:
    name: Pyright Lint
    runs-on: ubuntu-latest
    concurrency:
      group: pyright-${{ github.ref }}-${{ matrix.env }}
      cancel-in-progress: true
    strategy:
      matrix:
        env: [pydantic-v1, pydantic-v2]
      fail-fast: false

    steps:
      - uses: actions/checkout@v6

      - name: Setup Python environment
        uses: ./.github/actions/setup-python
        with:
          env-group: ${{ matrix.env }}

      - run: |
          echo "$(dirname $(uv python find))" >> $GITHUB_PATH
          if [ "${{ matrix.env }}" = "pydantic-v1" ]; then
            sed -i 's/PYDANTIC_V2 = true/PYDANTIC_V2 = false/g' ./pyproject.toml
          fi
        shell: bash

      - name: Run Pyright
        uses: jakebailey/pyright-action@v2
        with:
          pylance-version: latest-release
