name: Dev smoke (CE)

on:
  pull_request:
    branches: [main]
    paths:
      - 'supabase/migrations/**'
      - 'supabase/seeds/**'
      - 'scripts/dev-start.sh'
      - 'scripts/smoke-dev.sh'
      - 'apps/cli/**'

jobs:
  dev-smoke:
    name: Dev stack smoke test
    runs-on: ubuntu-latest
    timeout-minutes: 10

    steps:
      - name: Checkout
        uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0

      - name: Setup workspace
        uses: ./.github/actions/setup-workspace
        with:
          node-version: '20'

      - uses: supabase/setup-cli@v2
        with:
          version: latest
          github-token: ${{ secrets.GITHUB_TOKEN }}

      - name: Start Supabase
        run: pnpm supabase start

      - name: Build CLI
        run: pnpm nx build cli --skip-nx-cache

      - name: Run smoke-dev.sh
        run: bash scripts/smoke-dev.sh

      - name: Upload timing report
        if: always()
        uses: actions/upload-artifact@v4
        with:
          name: smoke-dev-timing
          path: tmp/smoke-timings.txt
          if-no-files-found: ignore
          retention-days: 7
