Repository navigation
86 lines (80 loc) · 2.8 KB
/
Copy pathci.yml
File metadata and controls
86 lines (80 loc) · 2.8 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
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
build:
name: Typecheck & build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '22'
cache: npm
- run: npm ci || npm install
- run: node node_modules/prisma/build/index.js generate
- name: Generate TypeScript client from openapi.yaml
run: npm run client:gen
- name: Fail if the committed client is out of date
run: git diff --exit-code -- clients/typescript
- name: Typecheck the generated TypeScript client
run: npm run client:typecheck
- name: Fail if the committed README tables are out of date with openapi.yaml
run: npm run readme:check
- run: npx tsc --noEmit
- run: npm run build
- run: npm test --if-present
db-migrations:
# #233 — schema changes must be reviewable migrations, not `db push`.
# This job is the authority on drift: it replays every committed migration
# against a real Postgres and fails if the result disagrees with
# prisma/schema.prisma. It also proves a new migration can be generated,
# applied and rolled back on a clean database.
name: Migration drift & deploy
runs-on: ubuntu-latest
needs: build
services:
postgres:
image: postgres:15-alpine
env:
POSTGRES_USER: lens
POSTGRES_PASSWORD: lens
POSTGRES_DB: lens
ports:
- 5432:5432
options: >-
--health-cmd "pg_isready -U lens -d lens"
--health-interval 5s
--health-timeout 5s
--health-retries 10
env:
DATABASE_URL: postgresql://lens:lens@localhost:5432/lens
DIRECT_DATABASE_URL: postgresql://lens:lens@localhost:5432/lens
SHADOW_DATABASE_URL: postgresql://lens:lens@localhost:5432/lens_shadow
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '22'
cache: npm
- run: npm ci || npm install
- run: node node_modules/prisma/build/index.js generate
- name: Create empty shadow database
run: |
node -e '
const { Client } = require("pg");
(async () => {
const c = new Client({ connectionString: process.env.DATABASE_URL });
await c.connect();
await c.query("DROP DATABASE IF EXISTS lens_shadow");
await c.query("CREATE DATABASE lens_shadow");
await c.end();
})();
'
- name: Fail on drift between schema.prisma and prisma/migrations
run: bash scripts/db-drift-check.sh
- name: Prove generate / apply / rollback on a clean database
run: bash scripts/db-migration-cycle.sh