name: Type check
# see: https://help.github.com/en/actions/reference/events-that-trigger-workflows
on: # Trigger the workflow on pull request or merge
  schedule:
    - cron: "0 0 * * *" # daily at midnight UTC
  workflow_dispatch: # allows manual triggering of the workflow
  # pull_request:
  # push:
  #   branches:
  #     - main

defaults:
  run:
    shell: bash

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

jobs:
  type-check:
    strategy:
      fail-fast: false
      matrix:
        python-version: ["3.10", "3.11", "3.12", "3.13"]
        optional-dependencies:
          - "none"
          # LLMs
          - "openai"
          - "gemini"
          - "anthropic"
          - "deepseek"
          # optional dependencies
          - "browser-use"
          - "commsagent-discord"
          - "commsagent-slack"
          - "commsagent-telegram"
          - "jupyter-executor"
          - "retrievechat"
          - "retrievechat-pgvector"
          - "retrievechat-mongodb"
          - "retrievechat-qdrant"
          - "graph-rag-falkor-db"
          - "neo4j"
          - "twilio"
          - "interop"
          - "crawl4ai"
          - "docs"
          - "interop-crewai"
          - "interop-langchain"
          - "interop-pydantic-ai"
          - "mcp"
          - "websockets"
        exclude:
          # Issues with installing retrievechat-qdrant in python 3.13
          - python-version: "3.13"
            optional-dependencies: "retrievechat-qdrant"
          # Browser use doesn't support below python 3.11
          - python-version: "3.10"
            optional-dependencies: "browser-use"
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v5
      - uses: astral-sh/setup-uv@v6
        with:
          version: "latest"
      - uses: actions/setup-python@v5
        with:
          python-version: ${{ matrix.python-version }}
      # All additional modules should be defined in pyproject.toml
      - run: uv pip install --system ".[types]"
        if: matrix.optional-dependencies == 'none'
      - run: uv pip install --system ".[types, ${{ matrix.optional-dependencies }}]"
        if: matrix.optional-dependencies != 'none'
      # Any additional configuration should be defined in pyproject.toml
      - run: |
          mypy
