name: Mobile Apps CI

on:
  push:
    paths:
      - 'apps/app-client-base-net/**'
      - 'apps/app-client-base-swift/**'
      - 'apps/web-client-base-net/**'
      - 'apps/web-client-tpos-net/**'
      - 'apps/web-client-eggymon-landipage-net/**'
  pull_request:
    paths:
      - 'apps/app-client-base-net/**'
      - 'apps/app-client-base-swift/**'
      - 'apps/web-client-base-net/**'
      - 'apps/web-client-tpos-net/**'
      - 'apps/web-client-eggymon-landipage-net/**'

jobs:
  dotnet-client-apps:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        project:
          - apps/web-client-base-net/src/WebClientBase.Server/WebClientBase.Server.csproj
          - apps/web-client-tpos-net/src/WebClientTpos.Server/WebClientTpos.Server.csproj
          - apps/web-client-eggymon-landipage-net/src/EggymonLandingPage.Server/EggymonLandingPage.Server.csproj
    steps:
      - uses: actions/checkout@v4

      - name: Setup .NET
        uses: actions/setup-dotnet@v4
        with:
          dotnet-version: '10.0.x'

      - name: Restore
        run: dotnet restore ${{ matrix.project }}

      - name: Build
        run: dotnet build ${{ matrix.project }} --configuration Release --no-restore

  dotnet-client-app-tests:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        project:
          - apps/app-client-base-net/tests/AppClientBase.UnitTests/AppClientBase.UnitTests.csproj
          - apps/web-client-base-net/tests/WebClientBase.SmokeTests/WebClientBase.SmokeTests.csproj
          - apps/web-client-tpos-net/tests/WebClientTpos.SmokeTests/WebClientTpos.SmokeTests.csproj
          - apps/web-client-eggymon-landipage-net/tests/EggymonLandingPage.SmokeTests/EggymonLandingPage.SmokeTests.csproj
    steps:
      - uses: actions/checkout@v4

      - name: Setup .NET
        uses: actions/setup-dotnet@v4
        with:
          dotnet-version: '10.0.x'

      - name: Restore tests
        run: dotnet restore ${{ matrix.project }}

      - name: Run tests
        run: dotnet test ${{ matrix.project }} --configuration Release --no-restore

  swift-client-app:
    runs-on: macos-latest
    steps:
      - uses: actions/checkout@v4

      - name: Run Swift smoke tests
        run: swift test --package-path apps/app-client-base-swift/smoke-tests

      - name: Build Swift iOS app
        run: |
          xcodebuild \
            -project apps/app-client-base-swift/AppClientBaseSwift/AppClientBaseSwift.xcodeproj \
            -scheme AppClientBaseSwift \
            -sdk iphonesimulator \
            -destination 'platform=iOS Simulator,name=iPhone 16' \
            build

  maui-project-validation:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Validate MAUI project file exists
        run: test -f apps/app-client-base-net/AppClientBase.csproj
