name: Compile

on:
  pull_request: 
  push:
    branches-ignore:
      - 'hotfix-*'   
      - 'release'


jobs:

  compile-accounts:
    runs-on: ubuntu-latest
    env:
      CI_PIPELINE_ID: ${{github.run_number}}
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: latest
      - run: cd Common && npm install
      - name: Compile Accounts
        uses: nick-fields/retry@v3
        with:
          timeout_minutes: 30
          max_attempts: 3
          command: cd App/FeatureSet/Accounts && npm install && npm run compile && npm run dep-check

  compile-common:
    runs-on: ubuntu-latest
    env:
      CI_PIPELINE_ID: ${{github.run_number}}
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: latest
      - name: Compile Common
        uses: nick-fields/retry@v3
        with:
          timeout_minutes: 30
          max_attempts: 3
          command: cd Common && npm install && npm run compile && npm run dep-check

  compile-app:
    runs-on: ubuntu-latest
    env:
      CI_PIPELINE_ID: ${{github.run_number}}
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: latest
      - run: cd Common && npm install
      - name: Compile App
        uses: nick-fields/retry@v3
        with:
          timeout_minutes: 30
          max_attempts: 3
          command: cd App && npm install && npm run compile && npm run dep-check

  compile-home:
    runs-on: ubuntu-latest
    env:
      CI_PIPELINE_ID: ${{github.run_number}}
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: latest
      - run: cd Common && npm install
      - name: Compile Home
        uses: nick-fields/retry@v3
        with:
          timeout_minutes: 30
          max_attempts: 3
          command: cd Home && npm install && npm run compile && npm run dep-check


  compile-nginx:
    runs-on: ubuntu-latest
    env:
      CI_PIPELINE_ID: ${{github.run_number}}
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: latest
      - run: cd Common && npm install
      
      - name: Compile Nginx
        uses: nick-fields/retry@v3
        with:
          timeout_minutes: 30
          max_attempts: 3
          command: cd Nginx && npm install && npm run compile && npm run dep-check

  compile-infrastructure-agent:
    runs-on: ubuntu-latest
    env:
      CI_PIPELINE_ID: ${{github.run_number}}
    steps:
      - uses: actions/checkout@v4
      # Setup Go
      - uses: actions/setup-go@v5
      - name: Compile Infrastructure Agent
        uses: nick-fields/retry@v3
        with:
          timeout_minutes: 30
          max_attempts: 3
          command: cd InfrastructureAgent && go build .
  

  compile-admin-dashboard:
    runs-on: ubuntu-latest
    env:
      CI_PIPELINE_ID: ${{github.run_number}}
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: latest
      - run: cd Common && npm install
      
      - name: Compile Admin Dashboard
        uses: nick-fields/retry@v3
        with:
          timeout_minutes: 30
          max_attempts: 3
          command: cd App/FeatureSet/AdminDashboard && npm install && npm run compile && npm run dep-check

  compile-dashboard:
    runs-on: ubuntu-latest
    env:
      CI_PIPELINE_ID: ${{github.run_number}}
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: latest
      - run: cd Common && npm install
      
      - name: Compile Dashboard
        uses: nick-fields/retry@v3
        with:
          timeout_minutes: 30
          max_attempts: 3
          command: cd App/FeatureSet/Dashboard && npm install && npm run compile && npm run dep-check


  compile-e2e:
    runs-on: ubuntu-latest
    env:
      CI_PIPELINE_ID: ${{github.run_number}}
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: latest
      - run: sudo apt-get update
      - run: cd Common && npm install
      - name: Compile E2E
        uses: nick-fields/retry@v3
        with:
          timeout_minutes: 30
          max_attempts: 3
          command: cd E2E && npm install && npm run compile && npm run dep-check

  compile-probe:
    runs-on: ubuntu-latest
    env:
      CI_PIPELINE_ID: ${{github.run_number}}
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: latest
      - run: cd Common && npm install
      - name: Compile Probe
        uses: nick-fields/retry@v3
        with:
          timeout_minutes: 30
          max_attempts: 3
          command: cd Probe && npm install && npm run compile && npm run dep-check

  compile-status-page:
    runs-on: ubuntu-latest
    env:
      CI_PIPELINE_ID: ${{github.run_number}}
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: latest
      - run: cd Common && npm install
      
      - name: Compile Status Page
        uses: nick-fields/retry@v3
        with:
          timeout_minutes: 30
          max_attempts: 3
          command: cd App/FeatureSet/StatusPage && npm install && npm run compile && npm run dep-check

  compile-test-server:
    runs-on: ubuntu-latest
    env:
      CI_PIPELINE_ID: ${{github.run_number}}
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: latest
      - run: cd Common && npm install
      - name: Compile Test Server
        uses: nick-fields/retry@v3
        with:
          timeout_minutes: 30
          max_attempts: 3
          command: cd TestServer && npm install && npm run compile && npm run dep-check

  compile-mobile-app:
    runs-on: ubuntu-latest
    env:
      CI_PIPELINE_ID: ${{github.run_number}}
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: latest
      - run: cd Common && npm install && npm run compile
      - name: Compile MobileApp
        uses: nick-fields/retry@v3
        with:
          timeout_minutes: 30
          max_attempts: 3
          command: cd MobileApp && npm install && npm run compile

  compile-ai-agent:
    runs-on: ubuntu-latest
    env:
      CI_PIPELINE_ID: ${{github.run_number}}
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: latest
      - run: cd Common && npm install
      - name: Compile AIAgent
        uses: nick-fields/retry@v3
        with:
          timeout_minutes: 30
          max_attempts: 3
          command: cd AIAgent && npm install && npm run compile && npm run dep-check

  compile-cli:
    runs-on: ubuntu-latest
    env:
      CI_PIPELINE_ID: ${{github.run_number}}
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: latest
      - run: cd Common && npm install
      - name: Compile CLI
        uses: nick-fields/retry@v3
        with:
          timeout_minutes: 30
          max_attempts: 3
          command: cd CLI && npm install && npm run compile && npm run dep-check