name: CI / Tests

on:
  pull_request:
    branches: ["*"]
  push:
    branches: ["main"]
  merge_group:
  workflow_dispatch:
  workflow_call:

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

env:
  FORCE_COLOR: "1"
  NODE_VERSION: 22.x
  # You can leverage Remote Caching with Turbo to speed up your builds
  # @link https://turbo.build/repo/docs/guides/ci-vendors/github-actions
  TURBO_TEAM: ${{ secrets.TURBO_TEAM }}
  TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}

jobs:
  test:
    name: 🧪 Test
    runs-on: ubuntu-latest
    steps:
      - name: ✅ Checkout code
        uses: actions/checkout@v5

      - name: 🔨 Setup
        uses: ./tooling/github/setup
        with:
          node-version: ${{ env.NODE_VERSION }}

      - name: 🖌️ Format
        run: pnpm run format

      - name: 🛻 Lint
        run: pnpm run lint && pnpm run lint:ws

      - name: 📝 Typecheck
        run: pnpm run typecheck

      - name: 🧪 Test
        run: pnpm run test
