name: TypeScript

on:
  push:
    branches: [main]
    paths:
      - "apps/**"
      - "lib/packages/**"
      - "package.json"
      - "bun.lock"
      - ".github/workflows/typescript.yml"
  pull_request:
    branches: [main]
    paths:
      - "apps/**"
      - "lib/packages/**"
      - "package.json"
      - "bun.lock"
      - ".github/workflows/typescript.yml"
  workflow_dispatch:

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

permissions:
  contents: read

jobs:
  typecheck:
    name: Typecheck
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
        with:
          persist-credentials: false
      - uses: oven-sh/setup-bun@3d267786b128fe76c2f16a390aa2448b815359f3 # v2
      - run: bun install
      - run: cd apps/fabro-web && bun run typecheck

  test:
    name: Test
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
        with:
          persist-credentials: false
      - uses: oven-sh/setup-bun@3d267786b128fe76c2f16a390aa2448b815359f3 # v2
      - run: bun install
      - run: cd apps/fabro-web && bun test

  build:
    name: Build
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
        with:
          persist-credentials: false
      - uses: oven-sh/setup-bun@3d267786b128fe76c2f16a390aa2448b815359f3 # v2
      - run: bun install
      - run: cd apps/fabro-web && bun run build
