-
Notifications
You must be signed in to change notification settings - Fork 0
323 lines (270 loc) · 9.68 KB
/
ci.yml
File metadata and controls
323 lines (270 loc) · 9.68 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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
# CI pipeline — runs on every PR to main and dev
# Validates code quality, types, build, tests, and database integrity
#
# Minute-saving strategy:
# - Path-based filtering skips expensive jobs when irrelevant files change
# - E2E only runs on PRs to main (most expensive job at ~6 min)
# - DB jobs only run when migration files change
# - Schema drift detection moved to deploy-dev (informational only)
# - Skipped jobs satisfy required status checks in GitHub rulesets
# - npm ci with cache — reproducible installs, no lockfile deletion
name: CI
on:
pull_request:
branches: [main, dev]
concurrency:
group: ci-${{ github.head_ref || github.ref_name }}
cancel-in-progress: true
env:
# Turborepo remote cache (optional — works without these)
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: ${{ vars.TURBO_TEAM }}
# Filter to only packages affected since the PR base branch
TURBO_FILTER: --filter=...[origin/${{ github.base_ref }}]
jobs:
# ─── Detect what changed ─────────────────────────────────────
changes:
name: Detect Changes
runs-on: ubuntu-latest
outputs:
src: ${{ steps.filter.outputs.src }}
migrations: ${{ steps.filter.outputs.migrations }}
web: ${{ steps.filter.outputs.web }}
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
src:
- 'apps/**/*.{ts,tsx,js,jsx,css}'
- 'packages/**/*.{ts,tsx,js,jsx}'
- '!packages/db/types/database.ts'
- '**/package.json'
- '**/tsconfig*.json'
- 'turbo.json'
migrations:
- 'packages/db/supabase/migrations/**'
- 'packages/db/supabase/seed.sql'
web:
- 'apps/web/**'
- 'packages/**'
# ─── Lint & Type-check (parallel) ─────────────────────────────
lint:
name: Lint
needs: [changes]
if: needs.changes.outputs.src == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: 24
cache: npm
- name: Install dependencies
run: npm ci
- name: Turbo lint
run: npx turbo run lint ${{ env.TURBO_FILTER }}
- name: Summary
if: always()
run: echo "### Lint ${{ job.status == 'success' && '✅' || '❌' }}" >> "$GITHUB_STEP_SUMMARY"
typecheck:
name: Type-check
needs: [changes]
if: needs.changes.outputs.src == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: 24
cache: npm
- name: Install dependencies
run: npm ci
- name: Turbo check-types
run: npx turbo run check-types ${{ env.TURBO_FILTER }}
- name: Summary
if: always()
run: echo "### Type-check ${{ job.status == 'success' && '✅' || '❌' }}" >> "$GITHUB_STEP_SUMMARY"
# ─── Build & Test (parallel, after lint+typecheck) ────────────
build:
name: Build
needs: [changes, lint, typecheck]
if: needs.changes.outputs.src == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: 24
cache: npm
- name: Install dependencies
run: npm ci
- name: Turbo build
run: npx turbo run build ${{ env.TURBO_FILTER }}
- name: Summary
if: always()
run: echo "### Build ${{ job.status == 'success' && '✅' || '❌' }}" >> "$GITHUB_STEP_SUMMARY"
test:
name: Test
needs: [changes, lint, typecheck]
if: needs.changes.outputs.src == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: 24
cache: npm
- name: Install dependencies
run: npm ci
- uses: supabase/setup-cli@v1
with:
version: latest
- name: Start local Supabase (db + API only)
run: supabase start -x realtime,storage,imgproxy,inbucket,studio,edge-runtime,logflare,vector,supavisor
working-directory: packages/db
- name: Reset DB (migrations + seed)
run: supabase db reset
working-directory: packages/db
- name: Turbo test
run: npx turbo run test ${{ env.TURBO_FILTER }}
- name: Stop local Supabase
if: always()
run: supabase stop
working-directory: packages/db
- name: Summary
if: always()
run: echo "### Test ${{ job.status == 'success' && '✅' || '❌' }}" >> "$GITHUB_STEP_SUMMARY"
# ─── E2E (main PRs only — most expensive job) ────────────────
e2e:
name: E2E
needs: [changes, lint, typecheck]
if: github.base_ref == 'main' && needs.changes.outputs.web == 'true'
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: 24
cache: npm
- name: Install dependencies
run: npm ci
- uses: supabase/setup-cli@v1
with:
version: latest
- name: Start local Supabase
run: supabase start -x imgproxy,inbucket,studio,edge-runtime,logflare,vector,supavisor
working-directory: packages/db
- name: Export Supabase keys
id: supabase-keys
run: |
eval "$(supabase status -o env)"
echo "anon_key=${ANON_KEY}" >> "$GITHUB_OUTPUT"
echo "service_role_key=${SERVICE_ROLE_KEY}" >> "$GITHUB_OUTPUT"
working-directory: packages/db
- name: Reset DB (migrations + seed)
run: supabase db reset
working-directory: packages/db
- name: Wait for Supabase services to be ready
run: |
for i in $(seq 1 30); do
if curl -sf http://127.0.0.1:54321/rest/v1/ -H "apikey: $SUPABASE_ANON_KEY" > /dev/null 2>&1; then
echo "Supabase is ready"
exit 0
fi
echo "Waiting for Supabase... ($i/30)"
sleep 2
done
echo "Supabase failed to start"
exit 1
env:
SUPABASE_ANON_KEY: ${{ steps.supabase-keys.outputs.anon_key }}
- name: Install Playwright browsers (chromium)
run: npx playwright install --with-deps chromium
working-directory: apps/web
- name: Build web app for E2E
run: npx turbo run build --filter=web
env:
NEXT_PUBLIC_SUPABASE_URL: http://127.0.0.1:54321
NEXT_PUBLIC_SUPABASE_PUB_KEY: ${{ steps.supabase-keys.outputs.anon_key }}
SUPABASE_SECRET_KEY: ${{ steps.supabase-keys.outputs.service_role_key }}
- name: Run Playwright tests
run: npx playwright test
working-directory: apps/web
env:
NEXT_PUBLIC_SUPABASE_URL: http://127.0.0.1:54321
NEXT_PUBLIC_SUPABASE_PUB_KEY: ${{ steps.supabase-keys.outputs.anon_key }}
SUPABASE_SECRET_KEY: ${{ steps.supabase-keys.outputs.service_role_key }}
- name: Upload Playwright report
if: failure()
uses: actions/upload-artifact@v4
with:
name: playwright-report
path: apps/web/playwright-report/
retention-days: 7
- name: Stop local Supabase
if: always()
run: supabase stop
working-directory: packages/db
- name: Summary
if: always()
run: echo "### E2E ${{ job.status == 'success' && '✅' || '❌' }}" >> "$GITHUB_STEP_SUMMARY"
# ─── Supabase database checks (only when migrations change) ──
db-lint:
name: DB Lint
needs: [changes]
if: needs.changes.outputs.migrations == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: supabase/setup-cli@v1
with:
version: latest
- name: Link to dev project
run: supabase link --project-ref "${{ secrets.SUPABASE_DEV_PROJECT_REF }}"
working-directory: packages/db
env:
SUPABASE_ACCESS_TOKEN: ${{ secrets.SUPABASE_ACCESS_TOKEN }}
- name: Lint migrations
run: supabase db lint --linked
working-directory: packages/db
env:
SUPABASE_ACCESS_TOKEN: ${{ secrets.SUPABASE_ACCESS_TOKEN }}
- name: Summary
if: always()
run: echo "### DB Lint ${{ job.status == 'success' && '✅' || '❌' }}" >> "$GITHUB_STEP_SUMMARY"
migration-dry-run:
name: Migration Dry Run
needs: [changes]
if: needs.changes.outputs.migrations == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: supabase/setup-cli@v1
with:
version: latest
- name: Start local Supabase (db only)
run: supabase start -x realtime,storage,imgproxy,inbucket,postgrest,gotrue,studio,edge-runtime,logflare,vector,supavisor
working-directory: packages/db
- name: Reset DB (replay all migrations + seed)
run: supabase db reset
working-directory: packages/db
- name: Stop local Supabase
if: always()
run: supabase stop
working-directory: packages/db
- name: Summary
if: always()
run: echo "### Migration Dry Run ${{ job.status == 'success' && '✅' || '❌' }}" >> "$GITHUB_STEP_SUMMARY"