name: CI — Common Platform

on:
  push:
    branches: [main]
    paths:
      - 'packages/**'
      - 'services/**'
      - 'dashboards/**'
      - 'pnpm-lock.yaml'
      - 'pnpm-workspace.yaml'
      - 'package.json'
      - 'tsconfig.base.json'
      - 'eslint.config.js'
      - '.gitea/workflows/**'

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

jobs:
  build-and-test:
    name: Build, Test & Typecheck
    runs-on: [ubuntu-latest, bytelyst, hostinger]
    container:
      image: node:20-bookworm
    timeout-minutes: 20
    steps:
      - name: Checkout
        uses: actions/checkout@v4
        with:
          fetch-depth: 0
          github-server-url: https://gitea.bytelyst.com

      - name: Install pinned pnpm
        run: |
          npm install -g pnpm@10.6.5
          pnpm --version

      - name: Install dependencies
        run: HUSKY=0 pnpm install --frozen-lockfile

      - name: Build release package
        run: pnpm --filter @bytelyst/errors run build

      - name: Typecheck release package
        run: pnpm --filter @bytelyst/errors exec tsc --noEmit

      - name: Test release package
        run: pnpm --filter @bytelyst/errors test
