name: Verify Pi Apple Platforms

on:
  pull_request:
  push:
    branches: [main]

permissions:
  contents: read

jobs:
  unit-and-package:
    name: Typecheck, tests, extension, package
    runs-on: macos-26
    timeout-minutes: 20
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: 22
          cache: npm
      - run: npm ci
      - run: npm run check
      - run: npx pi -e . --list-models
      - run: npm pack --dry-run --json
      - run: git diff --check

  xcode-e2e:
    name: Real Xcode ${{ matrix.suite }} E2E
    strategy:
      fail-fast: false
      matrix:
        suite: [platforms, handoff]
    runs-on: macos-26
    timeout-minutes: 45
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: 22
          cache: npm
      - run: npm ci
      - run: xcodebuild -version
      - if: matrix.suite == 'platforms'
        run: IDEVFLOW_IOS_XCODE_E2E=1 IDEVFLOW_MACOS_XCODE_E2E=1 IDEVFLOW_UNIVERSAL_XCODE_E2E=1 npx tsx --test tests/xcode-e2e.test.ts
      - if: matrix.suite == 'handoff'
        run: IDEVFLOW_IOS_XCODE_E2E=1 npx tsx --test tests/real-app-handoff-e2e.test.ts
