name: CI

on:
  push:
    branches: [main]
  pull_request:
    branches: [main]

jobs:
  build:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        python-version: ["3.10", "3.11", "3.12"]

    steps:
      - uses: actions/checkout@v4

      - name: Set up Python ${{ matrix.python-version }}
        uses: actions/setup-python@v5
        with:
          python-version: ${{ matrix.python-version }}

      - name: Install dependencies
        run: |
          python -m pip install --upgrade pip
          pip install -e ".[dev]" 2>/dev/null || pip install -e . 2>/dev/null || pip install .

      - name: Syntax check
        run: python -m py_compile vaultfire_crewai/__init__.py

      - name: Validate all modules
        run: |
          python -c "
          import ast, sys, pathlib
          errors = []
          for f in pathlib.Path('vaultfire_crewai').glob('*.py'):
              try:
                  ast.parse(f.read_text())
              except SyntaxError as e:
                  errors.append(f'{f}: {e}')
          if errors:
              for e in errors:
                  print(f'ERROR: {e}', file=sys.stderr)
              sys.exit(1)
          print(f'All modules valid')
          "
