# Check code style and formatting
name: Lint

on:
  push:
    branches: [main, master, develop]
  pull_request:
    branches: [main, master, develop]

jobs:
  lint:
    runs-on: ubuntu-latest
    
    steps:
      # 1. Get the code
      - name: Checkout code
        uses: actions/checkout@v4
      
      # 2. Set up Python
      - name: Set up Python
        uses: actions/setup-python@v5
        with:
          python-version: "3.11"
      
      # 3. Install linting tools
      - name: Install linters
        run: |
          python -m pip install --upgrade pip
          pip install ruff black
      
      # 4. Run ruff (fast linter - catches bugs and style issues)
      - name: Run ruff
        run: |
          ruff check src/ tests/ frontends/
      
      # 5. Check black formatting (doesn't modify, just checks)
      - name: Check black formatting
        run: |
          black --check src/ tests/ frontends/

  # Type checking (optional but helpful)
  typecheck:
    runs-on: ubuntu-latest
    
    steps:
      - name: Checkout code
        uses: actions/checkout@v4
      
      - name: Set up Python
        uses: actions/setup-python@v5
        with:
          python-version: "3.11"
      
      - name: Install dependencies
        run: |
          python -m pip install --upgrade pip
          pip install -e ".[dev]"
          pip install mypy
      
      - name: Run mypy
        run: |
          mypy src/stegasoo --ignore-missing-imports
        continue-on-error: true  # Don't fail build on type errors (yet)
