name: xtablo-ci

on:
  pull_request:
  push:
    branches:
      - main
      - develop

concurrency:
  group: ci-${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

jobs:
  checks:
    name: Checks
    runs-on:
      - self-hosted
      - linux
      - x64

    timeout-minutes: 45

    steps:
      - name: Checkout repository
        uses: actions/checkout@v6

      - name: Setup pnpm
        uses: pnpm/action-setup@v5
        with:
          version: 10.19.0

      - name: Setup Node.js
        uses: actions/setup-node@v6
        with:
          node-version: 20
          cache: pnpm

      - name: Install dependencies
        run: pnpm install --frozen-lockfile --child-concurrency=2

      - name: Lint
        run: pnpm turbo run lint --concurrency=2

      - name: Typecheck
        run: pnpm turbo run typecheck --concurrency=1

      - name: Test main app
        run: pnpm --filter @xtablo/main test -- --maxWorkers=1 --no-file-parallelism

      - name: Test clients app
        run: pnpm --filter @xtablo/clients test -- --maxWorkers=1 --no-file-parallelism

      - name: Typecheck API
        run: pnpm --filter @xtablo/api typecheck
