-
Notifications
You must be signed in to change notification settings - Fork 1
199 lines (155 loc) · 6.1 KB
/
Copy pathci-deploy.yml
File metadata and controls
199 lines (155 loc) · 6.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
name: CI & Deploy
on:
push:
branches: [main]
pull_request:
branches: [main]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
unit-component-tests:
name: Unit & Component Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: oven-sh/setup-bun@v2
with:
bun-version: "1.3.6"
- name: Install dependencies
run: bun install
- name: Build shared package
run: cd packages/shared && bun run build
- name: Run shared package tests
run: cd packages/shared && bun test
- name: Build CLI
run: cd packages/cli && bun run build
- name: Run CLI tests
run: cd packages/cli && bun test
- name: Build MCP
run: cd packages/mcp && bun run build
- name: Run MCP tests
run: cd packages/mcp && bun test
- name: Generate Prisma client
run: cd backend && bun x prisma generate
- name: Type check backend
run: cd backend && bun x tsc -p tsconfig.build.json --noEmit
- name: Type check frontend
run: cd apps/web && bun x tsc --noEmit
- name: Type check site
run: cd apps/site && bun x tsc --noEmit
- name: Run backend tests
run: cd backend && bun run test
- name: Run frontend tests
run: cd apps/web && bun run test
- name: Run site tests
run: cd apps/site && bun run test
- name: Build frontend
run: cd apps/web && bun run build
- name: Build site
run: cd apps/site && bun run build
e2e-tests:
name: E2E Tests
needs: unit-component-tests
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v5
- uses: oven-sh/setup-bun@v2
with:
bun-version: "1.3.6"
- uses: supabase/setup-cli@v1
with:
version: latest
- name: Start local Supabase
run: |
# Move RLS migration aside — it references Prisma tables that don't exist yet
mv supabase/migrations/00002_rls_policies.sql /tmp/00002_rls_policies.sql
supabase start
# Will apply RLS after Prisma migrations
- name: Extract Supabase keys
id: supabase
run: |
echo "SUPABASE_URL=$(supabase status --output json | jq -r '.API_URL')" >> "$GITHUB_OUTPUT"
echo "ANON_KEY=$(supabase status --output json | jq -r '.ANON_KEY')" >> "$GITHUB_OUTPUT"
echo "SERVICE_ROLE_KEY=$(supabase status --output json | jq -r '.SERVICE_ROLE_KEY')" >> "$GITHUB_OUTPUT"
echo "DB_URL=$(supabase status --output json | jq -r '.DB_URL')" >> "$GITHUB_OUTPUT"
- name: Install dependencies
run: bun install
- name: Build shared package
run: cd packages/shared && bun run build
- name: Generate Prisma client
run: cd backend && bun x prisma generate
- name: Run Prisma migrations
run: cd backend && bun x prisma migrate deploy
env:
DATABASE_URL: ${{ steps.supabase.outputs.DB_URL }}
DIRECT_URL: ${{ steps.supabase.outputs.DB_URL }}
- name: Apply RLS policies
run: psql "${{ steps.supabase.outputs.DB_URL }}" -f /tmp/00002_rls_policies.sql
- name: Seed database
run: cd backend && bun x prisma db seed
env:
DATABASE_URL: ${{ steps.supabase.outputs.DB_URL }}
DIRECT_URL: ${{ steps.supabase.outputs.DB_URL }}
- name: Seed brands
run: cd backend && bun x ts-node prisma/seeds/brands.ts
env:
DATABASE_URL: ${{ steps.supabase.outputs.DB_URL }}
DIRECT_URL: ${{ steps.supabase.outputs.DB_URL }}
- name: Build backend
run: cd backend && bun run build
- name: Build frontend
run: cd apps/web && bun run build
env:
NEXT_PUBLIC_SUPABASE_URL: ${{ steps.supabase.outputs.SUPABASE_URL }}
NEXT_PUBLIC_SUPABASE_ANON_KEY: ${{ steps.supabase.outputs.ANON_KEY }}
NEXT_PUBLIC_BACKEND_URL: http://localhost:3000/api/v1
- name: Install Playwright browsers
run: cd apps/web && bun x playwright install --with-deps chromium
- name: Start services and run E2E tests
run: |
# Start backend (subshell so cd doesn't affect parent)
(cd backend && bun run start:prod) &
# Start frontend on port 3001
(cd apps/web && PORT=3001 bun run start) &
# Wait for both
timeout 60 bash -c 'until curl -sf http://localhost:3000/api/v1/health 2>/dev/null; do sleep 2; done'
echo "Backend ready"
timeout 120 bash -c 'until curl -sf http://localhost:3001 2>/dev/null; do sleep 2; done'
echo "Frontend ready"
# Run Playwright
cd apps/web && bun run test:e2e
env:
CI: "true"
DATABASE_URL: ${{ steps.supabase.outputs.DB_URL }}
DIRECT_URL: ${{ steps.supabase.outputs.DB_URL }}
SUPABASE_URL: ${{ steps.supabase.outputs.SUPABASE_URL }}
SUPABASE_SERVICE_ROLE_KEY: ${{ steps.supabase.outputs.SERVICE_ROLE_KEY }}
ALLOWED_ORIGINS: http://localhost:3001
NEXT_PUBLIC_SUPABASE_URL: ${{ steps.supabase.outputs.SUPABASE_URL }}
NEXT_PUBLIC_SUPABASE_ANON_KEY: ${{ steps.supabase.outputs.ANON_KEY }}
NEXT_PUBLIC_BACKEND_URL: http://localhost:3000/api/v1
- name: Upload Playwright report
uses: actions/upload-artifact@v4
if: ${{ !cancelled() }}
with:
name: playwright-report
path: apps/web/playwright-report/
retention-days: 14
deploy-backend:
name: Deploy Backend
needs:
- unit-component-tests
- e2e-tests
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Install Railway CLI
run: npm install -g @railway/cli
- name: Deploy backend to Railway
run: railway up --service ${{ vars.RAILWAY_SERVICE_NAME }}
env:
RAILWAY_TOKEN: ${{ secrets.RAILWAY_TOKEN }}
# Frontend deploys automatically via Vercel git integration