name: Mypy Type Checking for Aiservice

on:
  push:
    branches:
      - main
  pull_request:

jobs:
  type-check-aiservice:
    runs-on: ubuntu-latest

    env:
      SECRET_KEY: ${{ secrets.SECRET_KEY }}
      DATABASE_URL: ${{ secrets.DATABASE_URL }}
      OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
    steps:
      - name: Checkout code
        uses: actions/checkout@v4
        with:
          fetch-depth: 0
          token: ${{ secrets.GITHUB_TOKEN }}

      - name: Set up Python
        uses: actions/setup-python@v5
        with:
          python-version: '3.12.7'

      - name: Install dependencies
        working-directory: ./django/aiservice
        run: |
          python -m pip install --upgrade pip
          pip install poetry
          poetry install --with dev

      - name: Run mypy on allowlist
        working-directory: ./django/aiservice
        run: poetry run mypy --config-file pyproject.toml @mypy_allowlist.txt
