-
Notifications
You must be signed in to change notification settings - Fork 0
249 lines (199 loc) · 7.38 KB
/
Copy pathci.yml
File metadata and controls
249 lines (199 loc) · 7.38 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
name: CI
on:
pull_request:
push:
branches:
- main
permissions:
contents: read
concurrency:
group: ci-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
# The pnpm version is read from `packageManager` in package.json and the Node
# version from .node-version, so neither is repeated in this workflow.
env:
TURBO_TELEMETRY_DISABLED: 1
jobs:
quality:
name: Quality gate
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Check out repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Set up Node.js
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version-file: .node-version
- name: Install pnpm and dependencies
uses: pnpm/setup@703c52620218391530e48b9e8870d5c0082e1b9b # v2.1.0
with:
cache: true
require-lockfile: true
- name: Restore Turborepo cache
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4
with:
path: .turbo/cache
key: turbo-quality-${{ runner.os }}-${{ github.sha }}
restore-keys: |
turbo-quality-${{ runner.os }}-
- name: Check formatting, lint and types
run: pnpm check
- name: Run unit and component tests
run: pnpm test:unit
- name: Audit production dependencies
run: pnpm audit --prod --audit-level=high
routes:
name: Route gate
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Check out repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Set up Node.js
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version-file: .node-version
- name: Install pnpm and dependencies
uses: pnpm/setup@703c52620218391530e48b9e8870d5c0082e1b9b # v2.1.0
with:
cache: true
require-lockfile: true
- name: Restore Turborepo cache
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4
with:
path: .turbo/cache
key: turbo-routes-${{ runner.os }}-${{ github.sha }}
restore-keys: |
turbo-routes-${{ runner.os }}-
- name: Install Chromium
run: pnpm --filter @coursemap/web exec playwright install --with-deps chromium
- name: Check authenticated access control
run: pnpm --filter @coursemap/web test:build:auth && pnpm --filter @coursemap/web test:auth-access
- name: Check for whitespace errors
run: git diff --check
- name: Upload route-test report and traces
if: always()
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: playwright-route-report
path: |
apps/web/playwright-report
apps/web/test-results
retention-days: 7
database:
name: Database gate
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Check out repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Set up Node.js
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version-file: .node-version
- name: Install pnpm and dependencies
uses: pnpm/setup@703c52620218391530e48b9e8870d5c0082e1b9b # v2.1.0
with:
cache: true
require-lockfile: true
- name: Set up Supabase CLI
uses: supabase/setup-cli@46f7f98c7f948ad727d22c1e67fab04c223a0520 # v3.0.0
with:
version: 2.114.0
- name: Start local database
run: pnpm db:start
- name: Reset and seed local preview database
run: pnpm db:reset
- name: Run database tests
run: pnpm db:test
- name: Lint database schemas
run: pnpm db:lint
- name: Verify generated database types
run: |
cp apps/web/types/database.ts /tmp/database.committed.ts
pnpm db:types
diff --ignore-blank-lines --unified /tmp/database.committed.ts apps/web/types/database.ts
- name: Test catalogue database import
run: pnpm test:catalogue-db
browser:
name: Browser gate
runs-on: ubuntu-latest
timeout-minutes: 25
steps:
- name: Check out repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Set up Node.js
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version-file: .node-version
- name: Install pnpm and dependencies
uses: pnpm/setup@703c52620218391530e48b9e8870d5c0082e1b9b # v2.1.0
with:
cache: true
require-lockfile: true
- name: Restore Turborepo cache
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4
with:
path: .turbo/cache
key: turbo-browser-${{ runner.os }}-${{ github.sha }}
restore-keys: |
turbo-browser-${{ runner.os }}-
- name: Install Chromium
run: pnpm --filter @coursemap/web exec playwright install --with-deps chromium
- name: Set up Supabase CLI
uses: supabase/setup-cli@46f7f98c7f948ad727d22c1e67fab04c223a0520 # v3.0.0
with:
version: 2.114.0
- name: Start local services
run: pnpm db:start
- name: Seed local catalogue
run: pnpm db:reset
- name: Run authenticated browser journeys
run: pnpm test:e2e
- name: Upload Playwright report and failure traces
if: always()
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: playwright-browser-report
path: |
apps/web/playwright-report
apps/web/test-results
retention-days: 7
production-database:
name: Apply production migrations
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
needs:
- quality
- routes
- database
- browser
runs-on: ubuntu-latest
timeout-minutes: 10
environment: Production
env:
SUPABASE_POOLER_URL: postgresql://postgres.mogdmhkqkpvksvtvwdgl@aws-0-ap-southeast-2.pooler.supabase.com:5432/postgres
steps:
- name: Check out repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Set up Node.js
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version-file: .node-version
- name: Set up Supabase CLI
uses: supabase/setup-cli@46f7f98c7f948ad727d22c1e67fab04c223a0520 # v3.0.0
with:
version: 2.114.0
- name: Prepare production database connection
env:
SUPABASE_DB_PASSWORD: ${{ secrets.SUPABASE_DB_PASSWORD }}
run: >-
node -e 'const fs = require("node:fs"); const url = new
URL(process.env.SUPABASE_POOLER_URL); url.password =
process.env.SUPABASE_DB_PASSWORD;
fs.appendFileSync(process.env.GITHUB_ENV,
`SUPABASE_DB_URL=${url.href}\n`);'
- name: Preview production migrations
run: supabase db push --db-url "$SUPABASE_DB_URL" --dry-run
- name: Apply production migrations
run: supabase db push --db-url "$SUPABASE_DB_URL" --yes