name: CI

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

jobs:
  tests:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout repository
        uses: actions/checkout@v4

      - name: Set up Python
        uses: actions/setup-python@v5
        with:
          python-version: "3.9"

      - name: Install dependencies
        run: |
          python -m pip install --upgrade pip
          pip install -r requirements-dev.txt

      - name: Smoke test - import core modules
        run: |
          python - << 'EOF'
          import importlib
          modules = [
              "core.infra.project_context.path_manager",
              "core.modules.strategy",
              "core.modules.data_manager",
              "core.modules.data_source",
              "core.modules.tag",
              "core.modules.indicator",
          ]
          for m in modules:
              importlib.import_module(m)
          print("All core modules imported successfully.")
          EOF

      - name: Run core tests
        run: python -m pytest -v

  # 确保 Dockerfile 可构建（不跑完整 install，避免 CI 时间过长）
  docker-build:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout repository
        uses: actions/checkout@v4

      - name: Validate compose file
        run: docker compose -f docker-compose.yml config --quiet

      - name: Build image
        run: docker build -t new-tea-quant:ci .

