name: mindmodel validation

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

jobs:
  validate:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Set up Python
        uses: actions/setup-python@v4
        with:
          python-version: '3.x'

      - name: Install development dependencies (if present)
        run: |
          python -m pip install --upgrade pip
          if [ -f requirements-dev.txt ]; then
            pip install -r requirements-dev.txt
          else
            echo "requirements-dev.txt not found, skipping"
          fi

      - name: Run mindmodel validator (report-only)
        if: ${{ always() }}
        run: |
          # Make this step report-only: run the validator but always exit 0 so PRs are not blocked
          set +e
          if [ -f .mindmodel/manifest.yaml ]; then
            python scripts/validate_mindmodel.py --manifest .mindmodel/manifest.yaml --report reports/out.json || true
          else
            echo "No .mindmodel/manifest.yaml present — skipping validator"
          fi
          exit 0

      - name: Upload mindmodel reports
        if: ${{ always() }}
        uses: actions/upload-artifact@v4
        with:
          name: mindmodel-reports
          path: reports/mindmodel-report-*.json
