name: PR Checks

on:
  pull_request:
    branches:
      - main
      - beta
      - dev

permissions:
  contents: read
  pull-requests: read

jobs:
  lint-and-test:
    name: Lint & Test
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - uses: actions/setup-python@v5
        with:
          python-version: '3.11'
          cache: 'pip'

      - name: Install dependencies
        run: |
          python -m pip install --upgrade pip
          pip install -r requirements.txt
          pip install black flake8 pylint pytest

      - name: Black format check
        run: |
          if ! black --check src/; then
            echo "Run 'black src/' to format code"
            black --diff src/
            exit 1
          fi

  build-docker:
    name: Build Docker
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Build Docker image
        run: docker build -t krawl:test .
