name: Test

on:
  push:
    branches: [main]
  pull_request:
    branches: [main]

jobs:
  test:
    runs-on: ubuntu-latest

    services:
      postgres:
        image: postgres:16-alpine
        env:
          POSTGRES_PASSWORD: test
          POSTGRES_DB: postgres
        ports:
          - 5432:5432

    steps:
      - uses: actions/checkout@v4

      - name: Install Bun
        run: curl -fsSL https://bun.sh/install | bash

      - name: Install dependencies
        run: ~/.bun/bin/bun install --frozen-lockfile

      - name: Run tests
        env:
          SHADE_TEST_PG_URL: postgres://postgres:test@localhost:5432/postgres
        run: ~/.bun/bin/bun test --recursive

      - name: Run examples
        run: |
          ~/.bun/bin/bun run examples/01-basic-conversation/main.ts
          ~/.bun/bin/bun run examples/04-identity-verification/main.ts
