name: Flutter Analyze

on:
  pull_request:
    branches:
      - main
  push:
    branches:
      - "**"
      - "!main"

jobs:
  analyze:
    name: Dart Analyze
    runs-on: ubuntu-latest
    container:
      image: ghcr.io/cirruslabs/flutter:stable

    defaults:
      run:
        working-directory: kell_creations_apps

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

      - name: Install dependencies — core
        run: cd packages/core && flutter pub get

      - name: Install dependencies — design_system
        run: cd packages/design_system && flutter pub get

      - name: Install dependencies — feature_wordpress
        run: cd packages/feature_wordpress && flutter pub get

      - name: Install dependencies — feature_inventory
        run: cd packages/feature_inventory && flutter pub get

      - name: Install dependencies — feature_orders
        run: cd packages/feature_orders && flutter pub get

      - name: Install dependencies — feature_policy
        run: cd packages/feature_policy && flutter pub get

      - name: Install dependencies — kell_web
        run: cd apps/kell_web && flutter pub get

      - name: Install dependencies — kell_mobile
        run: cd apps/kell_mobile && flutter pub get

      - name: Analyze — core
        run: cd packages/core && dart analyze --fatal-infos

      - name: Analyze — design_system
        run: cd packages/design_system && dart analyze --fatal-infos

      - name: Analyze — feature_wordpress
        run: cd packages/feature_wordpress && dart analyze --fatal-infos

      - name: Analyze — feature_inventory
        run: cd packages/feature_inventory && dart analyze --fatal-infos

      - name: Analyze — feature_orders
        run: cd packages/feature_orders && dart analyze --fatal-infos

      - name: Analyze — feature_policy
        run: cd packages/feature_policy && dart analyze --fatal-infos

      - name: Analyze — kell_web
        run: cd apps/kell_web && dart analyze --fatal-infos

      - name: Analyze — kell_mobile
        run: cd apps/kell_mobile && dart analyze --fatal-infos

      - name: Summary
        if: always()
        run: echo "✅ Dart analyze completed for all packages and apps"
