CognxSafeTrack Claude Sonnet 4.6 commited on
Commit
56d35ea
·
1 Parent(s): 9d56788

ci: add GitHub Actions workflow — typecheck, tests, build

Browse files

Three jobs on push/PR to main:
- typecheck: tsc --noEmit on api, whatsapp-worker, admin (after Prisma generate + ai-sdk build)
- test: vitest run (excluding AI regression) against real Postgres/pgvector + Redis service containers,
runs migrate:deploy before tests
- build: pnpm turbo run build gated on typecheck passing

Concurrency group cancels in-progress runs on new push to same branch.
AI regression tests (test/regression/) excluded — require real API keys, run manually.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

Files changed (1) hide show
  1. .github/workflows/ci.yml +138 -0
.github/workflows/ci.yml ADDED
@@ -0,0 +1,138 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+ branches: [main]
8
+
9
+ concurrency:
10
+ group: ci-${{ github.ref }}
11
+ cancel-in-progress: true
12
+
13
+ jobs:
14
+ # ─── TypeScript ───────────────────────────────────────────────────────────────
15
+ typecheck:
16
+ name: TypeScript
17
+ runs-on: ubuntu-latest
18
+ steps:
19
+ - uses: actions/checkout@v4
20
+
21
+ - uses: pnpm/action-setup@v4
22
+ with:
23
+ version: 9.15.0
24
+
25
+ - uses: actions/setup-node@v4
26
+ with:
27
+ node-version: '20'
28
+ cache: pnpm
29
+
30
+ - name: Install dependencies
31
+ run: pnpm install --frozen-lockfile
32
+
33
+ - name: Generate Prisma client
34
+ run: pnpm --filter @repo/database generate
35
+
36
+ - name: Build ai-sdk (needed for downstream tsc)
37
+ run: pnpm --filter @repo/ai-sdk build
38
+
39
+ - name: tsc — api
40
+ run: pnpm --filter api exec tsc --noEmit
41
+
42
+ - name: tsc — whatsapp-worker
43
+ run: pnpm --filter whatsapp-worker exec tsc --noEmit
44
+
45
+ - name: tsc — admin
46
+ run: pnpm --filter admin exec tsc --noEmit
47
+
48
+ # ─── Unit & Integration Tests ────────────────────────────────────────────────
49
+ test:
50
+ name: Tests
51
+ runs-on: ubuntu-latest
52
+
53
+ services:
54
+ postgres:
55
+ image: ankane/pgvector:latest
56
+ env:
57
+ POSTGRES_USER: postgres
58
+ POSTGRES_PASSWORD: postgres
59
+ POSTGRES_DB: edtech_test
60
+ ports:
61
+ - 5432:5432
62
+ options: >-
63
+ --health-cmd pg_isready
64
+ --health-interval 10s
65
+ --health-timeout 5s
66
+ --health-retries 5
67
+
68
+ redis:
69
+ image: redis:7-alpine
70
+ ports:
71
+ - 6379:6379
72
+ options: >-
73
+ --health-cmd "redis-cli ping"
74
+ --health-interval 10s
75
+ --health-timeout 5s
76
+ --health-retries 5
77
+
78
+ env:
79
+ DATABASE_URL: postgresql://postgres:postgres@localhost:5432/edtech_test
80
+ REDIS_URL: redis://localhost:6379/1
81
+ ADMIN_API_KEY: test-api-key-32-chars-long-at-least-123456
82
+ ENCRYPTION_SECRET: test-encryption-secret-32-chars-long-123456
83
+ JWT_SECRET: test-jwt-secret
84
+ NODE_ENV: test
85
+
86
+ steps:
87
+ - uses: actions/checkout@v4
88
+
89
+ - uses: pnpm/action-setup@v4
90
+ with:
91
+ version: 9.15.0
92
+
93
+ - uses: actions/setup-node@v4
94
+ with:
95
+ node-version: '20'
96
+ cache: pnpm
97
+
98
+ - name: Install dependencies
99
+ run: pnpm install --frozen-lockfile
100
+
101
+ - name: Generate Prisma client
102
+ run: pnpm --filter @repo/database generate
103
+
104
+ - name: Build ai-sdk
105
+ run: pnpm --filter @repo/ai-sdk build
106
+
107
+ - name: Run database migrations
108
+ run: pnpm --filter @repo/database migrate:deploy
109
+
110
+ - name: Run unit & integration tests
111
+ # Exclude AI regression tests — they require real API keys and are slow
112
+ run: pnpm --filter api exec vitest run --exclude 'test/regression/**'
113
+
114
+ # ─── Build ───────────────────────────────────────────────────────────────────
115
+ build:
116
+ name: Build
117
+ runs-on: ubuntu-latest
118
+ needs: [typecheck]
119
+ steps:
120
+ - uses: actions/checkout@v4
121
+
122
+ - uses: pnpm/action-setup@v4
123
+ with:
124
+ version: 9.15.0
125
+
126
+ - uses: actions/setup-node@v4
127
+ with:
128
+ node-version: '20'
129
+ cache: pnpm
130
+
131
+ - name: Install dependencies
132
+ run: pnpm install --frozen-lockfile
133
+
134
+ - name: Generate Prisma client
135
+ run: pnpm --filter @repo/database generate
136
+
137
+ - name: Build all packages and apps
138
+ run: pnpm turbo run build