name: Web Sentinel CI

on:
  push:
    branches: [ main ]
  pull_request:

jobs:
  build-and-test:
    runs-on: ubuntu-latest

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

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

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

      - name: Set up Node.js
        uses: actions/setup-node@v4
        with:
          node-version: "18"
          cache: npm

      - name: Install VS Code extension deps (web-sentinel)
        run: npm install
        working-directory: integrations/vscode-web-sentinel

      - name: Install VS Code extension deps (legacy)
        run: npm install
        working-directory: integrations/vscode

      - name: Lint TypeScript packages
        run: |
          npm run lint
        working-directory: integrations/vscode-web-sentinel

      - name: Run pytest (subset)
        run: python -m pytest tests/test_payment_integration.py tests/test_license_backend.py

      - name: Build executables
        run: python tools/build/build_standalone.py

      - name: Upload dist artifacts
        if: always()
        uses: actions/upload-artifact@v4
        with:
          name: dist-executables
          path: dist/
