fix(autopilot): refactor findOrCreateAutopilotSession to use upsert f… #26
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: ci | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| jobs: | |
| ci: | |
| runs-on: ubuntu-latest | |
| services: | |
| postgres: | |
| image: postgres:16 | |
| env: | |
| POSTGRES_USER: postgres | |
| POSTGRES_PASSWORD: postgres | |
| POSTGRES_DB: cherry_test | |
| ports: | |
| - 5432:5432 | |
| options: >- | |
| --health-cmd="pg_isready -U postgres -d cherry_test" | |
| --health-interval=5s | |
| --health-timeout=5s | |
| --health-retries=20 | |
| env: | |
| DATABASE_URL: postgresql://postgres:postgres@localhost:5432/cherry_test?schema=public | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Node | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| cache: 'npm' | |
| - name: Install Postgres client | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y postgresql-client | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Check migration hygiene | |
| run: npm run check:migrations | |
| - name: Check clean working tree | |
| run: npm run check:clean | |
| - name: Check guardrails | |
| run: npm run check:guardrails | |
| - name: Wait for Postgres | |
| run: | | |
| ready=0 | |
| for i in {1..30}; do | |
| if pg_isready -h localhost -p 5432 -U postgres -d cherry_test; then | |
| echo "Postgres is ready" | |
| ready=1 | |
| break | |
| fi | |
| echo "Waiting for Postgres... ($i)" | |
| sleep 2 | |
| done | |
| if [ "$ready" -ne 1 ]; then | |
| echo "Postgres never became ready" | |
| exit 1 | |
| fi | |
| - name: Apply Prisma migrations to test DB | |
| run: | | |
| npx prisma generate --schema=prisma/schema.prisma | |
| npx prisma migrate deploy --schema=prisma/schema.prisma | |
| - name: Database smoke test | |
| run: npm run check:db | |
| - name: Verify Prisma migration status | |
| run: npx prisma migrate status --schema=prisma/schema.prisma | |
| - name: Database smoke test | |
| run: npm run check:db | |
| - name: Dump migration status on failure | |
| if: failure() | |
| run: | | |
| echo "DB: $DATABASE_URL" | sed -E 's#(//[^:/@]+):[^@]+@#\\1:***@#' | |
| npx prisma migrate status --schema=prisma/schema.prisma || true | |
| psql "$DATABASE_URL" -c "\\dt" || true | |
| - name: Check routes structure | |
| run: npm run check:routes | |
| - name: Check engine freeze | |
| run: npm run check:engine-freeze | |
| - name: Lint | |
| run: npm run lint | |
| - name: Typecheck scripts | |
| run: npm run typecheck:scripts | |
| - name: Typecheck | |
| run: npm run typecheck | |
| - name: Test | |
| run: npm test | |
| - name: Build | |
| run: npm run build |