name: CI

on:
  push:
    branches: [main, v0.0.1]
  pull_request:
    branches: [main, v0.0.1]

jobs:
  lint-and-test:
    name: Lint & Test
    runs-on: ubuntu-latest
    timeout-minutes: 10

    steps:
      - uses: actions/checkout@v4

      - uses: oven-sh/setup-bun@v2
        with:
          bun-version: latest

      - name: Install dependencies
        run: bun install --frozen-lockfile

      - name: Type check
        run: npx tsc --noEmit

      - name: Run tests
        run: bun --bun run test

  build-web:
    name: Build Web
    runs-on: ubuntu-latest
    timeout-minutes: 10
    needs: lint-and-test

    steps:
      - uses: actions/checkout@v4

      - uses: oven-sh/setup-bun@v2
        with:
          bun-version: latest

      - name: Install dependencies
        run: bun install --frozen-lockfile

      - name: Build
        run: bun --bun run build

      - name: Upload web build artifact
        uses: actions/upload-artifact@v4
        with:
          name: web-build
          path: .output/
          retention-days: 7
