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 Accounts && npm install && npm run compile && npm run dep-check

  compile-isolated-vm:
    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 IsolatedVM
        uses: nick-fields/retry@v3
        with:
          timeout_minutes: 30
          max_attempts: 3
          command: cd IsolatedVM && 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-worker:
    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 Worker
        uses: nick-fields/retry@v3
        with:
          timeout_minutes: 30
          max_attempts: 3
          command: cd Worker && npm install && npm run compile && npm run dep-check

  compile-workflow:
    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 Workflow
        uses: nick-fields/retry@v3
        with:
          timeout_minutes: 30
          max_attempts: 3
          command: cd Workflow && npm install && npm run compile && npm run dep-check

  compile-api-reference:
    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 API Reference
        uses: nick-fields/retry@v3
        with:
          timeout_minutes: 30
          max_attempts: 3
          command: cd APIReference && npm install && npm run compile && npm run dep-check

  compile-docs-reference:
    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 Docs Reference
        uses: nick-fields/retry@v3
        with:
          timeout_minutes: 30
          max_attempts: 3
          command: cd Docs && npm install && npm run compile && npm run dep-check

  compile-copilot:
    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 Copilot
        uses: nick-fields/retry@v3
        with:
          timeout_minutes: 30
          max_attempts: 3
          command: cd Copilot && 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 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 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-probe-ingest:
    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 Ingest
        uses: nick-fields/retry@v3
        with:
          timeout_minutes: 30
          max_attempts: 3
          command: cd ProbeIngest && npm install && npm run compile && npm run dep-check

  compile-server-monitor-ingest:
    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 Server Monitor Ingest
        uses: nick-fields/retry@v3
        with:
          timeout_minutes: 30
          max_attempts: 3
          command: cd ServerMonitorIngest && npm install && npm run compile && npm run dep-check

  compile-telemetry:
    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 Telemetry
        uses: nick-fields/retry@v3
        with:
          timeout_minutes: 30
          max_attempts: 3
          command: cd Telemetry && npm install && npm run compile && npm run dep-check


  compile-incoming-request-ingest: 
    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 Incoming Request Ingest
        uses: nick-fields/retry@v3
        with:
          timeout_minutes: 30
          max_attempts: 3
          command: cd IncomingRequestIngest && 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 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-mcp:
    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 MCP
        uses: nick-fields/retry@v3
        with:
          timeout_minutes: 30
          max_attempts: 3
          command: cd MCP && npm update @oneuptime/common && npm install && npm run compile && npm run dep-check