Repository navigation
354 lines (303 loc) · 11.3 KB
/
Copy pathci.yml
File metadata and controls
354 lines (303 loc) · 11.3 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
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
name: CI
on:
pull_request:
types: [opened, synchronize, reopened]
merge_group:
types: [checks_requested]
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
detect-changes:
name: Detect Changes
runs-on: ubuntu-latest
timeout-minutes: 5
permissions:
contents: read
pull-requests: read
outputs:
packages: ${{ steps.packages.outputs.list }}
chart: ${{ steps.filter.outputs.chart }}
store: ${{ steps.filter.outputs.store }}
steps:
- name: Check out repository code
uses: actions/checkout@v7
- name: Detect path changes
uses: dorny/paths-filter@v4.0.3
id: filter
with:
# Shared roots on every package filter so path-gated tests still run when:
# - package.json: root test:* entrypoints change
# - pnpm-workspace.yaml: workspace membership/graph changes
# - tsconfig.base.json: shared TS settings affect package tests
# - .github/workflows/ci.yml: this workflow's package matrix/steps change
filters: |
trueforge-core:
- 'packages/trueforge-core/**'
- 'package.json'
- 'pnpm-workspace.yaml'
- 'tsconfig.base.json'
- '.github/workflows/ci.yml'
trueforge:
- 'packages/trueforge/**'
- 'package.json'
- 'pnpm-workspace.yaml'
- 'tsconfig.base.json'
- '.github/workflows/ci.yml'
frontend:
- 'packages/frontend/**'
# trueforge-sdk is workspace:* (no version bump); SDK-only PRs must still run FE checks.
- 'packages/trueforge-sdk/**'
# trueforge-ui depends on the runtime workspace package.
- 'packages/assistant-ui-runtime/**'
- 'package.json'
- 'pnpm-workspace.yaml'
- 'tsconfig.base.json'
- '.github/workflows/ci.yml'
trueforge-ui:
- 'packages/trueforge-ui/**'
- 'packages/assistant-ui-runtime/**'
- 'package.json'
- 'pnpm-workspace.yaml'
- 'tsconfig.base.json'
- '.github/workflows/ci.yml'
assistant-ui-runtime:
- 'packages/assistant-ui-runtime/**'
- 'package.json'
- 'pnpm-workspace.yaml'
- 'tsconfig.base.json'
- '.github/workflows/ci.yml'
store:
- 'packages/trueforge/src/db/**'
- 'packages/trueforge/tests/db/**'
- 'packages/trueforge/jest.store.postgres.config.cjs'
- 'packages/trueforge/jest.store.sqlite.config.cjs'
- 'packages/trueforge/package.json'
- 'packages/trueforge-core/package.json'
- 'packages/trueforge-core/src/agent-session/models/**'
- 'packages/trueforge-core/src/agent-session/schemas/**'
- 'packages/trueforge-core/src/agent-session/store/**'
- 'packages/trueforge-core/tests/agent-session/store/**'
- 'packages/trueforge-core/tests/agent-session/testHelpers.ts'
- 'package.json'
- 'pnpm-workspace.yaml'
- 'tsconfig.base.json'
- '.github/workflows/ci.yml'
chart:
- 'charts/trueforge/**'
- 'Dockerfile'
- 'package.json'
- '.github/workflows/ci.yml'
- name: Build package matrix
id: packages
env:
TRUEFORGE_CORE: ${{ steps.filter.outputs['trueforge-core'] }}
TRUEFORGE: ${{ steps.filter.outputs.trueforge }}
FRONTEND: ${{ steps.filter.outputs.frontend }}
TRUEFORGE_UI: ${{ steps.filter.outputs['trueforge-ui'] }}
ASSISTANT_UI_RUNTIME: ${{ steps.filter.outputs['assistant-ui-runtime'] }}
run: |
node <<'EOF' >> "$GITHUB_OUTPUT"
const changedPackages = [];
if (process.env.TRUEFORGE_CORE === 'true') changedPackages.push('trueforge-core');
if (process.env.TRUEFORGE === 'true') changedPackages.push('trueforge');
if (process.env.FRONTEND === 'true') changedPackages.push('frontend');
if (process.env.TRUEFORGE_UI === 'true') changedPackages.push('trueforge-ui');
if (process.env.ASSISTANT_UI_RUNTIME === 'true') changedPackages.push('assistant-ui-runtime');
console.log(`list=${JSON.stringify(changedPackages)}`);
EOF
# Always-on: format + lint cover the whole tree (incl. roots outside packages/*);
# typecheck/build stay always-on. Per-package jobs only run tests.
# Order matters for fail-fast and lint correctness:
# - format first (cheapest signal)
# - typecheck next (package pretypecheck emits SDK .d.ts; core resolves from src/)
# - lint after typecheck (type-aware eslint reuses those declarations)
# - build last (full emit; SDK JS built once via the root graph, still always-on as a ship gate)
migration-order:
name: Migration Order
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Check out repository code
uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Refresh base branch reference
env:
BASE_REF: ${{ github.base_ref || github.event.merge_group.base_ref }}
run: |
base_branch="${BASE_REF#refs/heads/}"
git fetch --no-tags origin "+refs/heads/${base_branch}:refs/remotes/origin/${base_branch}"
echo "MIGRATION_BASE_REF=origin/${base_branch}" >> "$GITHUB_ENV"
- name: Check migration ordering
run: bash scripts/check-migration-order.sh
typecheck-and-build:
name: Format, Typecheck, Lint and Build
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Check out repository code
uses: actions/checkout@v7
- name: Setup pnpm
uses: pnpm/action-setup@v6
- name: Setup Node.js
uses: actions/setup-node@v7
with:
node-version: '24'
cache: 'pnpm'
- name: Cache prettier
uses: actions/cache@v6.1.0
with:
path: .prettiercache
# Project tsconfigs only (plugin reads them); !node_modules so post-install **/ globs stay bounded.
key: prettier-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml', '.prettierrc', '.prettierignore', 'package.json', '**/tsconfig*.json', '!**/node_modules/**') }}
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Format
run: pnpm format:check
- name: Typecheck
run: pnpm typecheck
# After typecheck so trueforge-ui and SDK .d.ts exist for type-aware eslint.
- name: Lint
run: pnpm lint:ci
- name: Build
run: pnpm build
windows-test:
name: Test (Windows)
runs-on: windows-latest
timeout-minutes: 30
steps:
- name: Check out repository code
uses: actions/checkout@v7
- name: Setup pnpm
uses: pnpm/action-setup@v6
- name: Setup Node.js
uses: actions/setup-node@v7
with:
node-version: '24'
cache: 'pnpm'
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Test
run: pnpm test
- name: SQLite store tests
run: pnpm test:store:sqlite
# Path-gated tests only — format/lint are covered by the global job above.
package-checks:
name: Package (${{ matrix.package }})
needs: detect-changes
if: needs.detect-changes.outputs.packages != '[]'
runs-on: ubuntu-latest
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
package: ${{ fromJSON(needs.detect-changes.outputs.packages) }}
steps:
- name: Check out repository code
uses: actions/checkout@v7
- name: Setup pnpm
uses: pnpm/action-setup@v6
- name: Setup Node.js
uses: actions/setup-node@v7
with:
node-version: '24'
cache: 'pnpm'
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Test
run: pnpm "test:${{ matrix.package }}"
chart-checks:
name: Helm Chart
needs: detect-changes
if: needs.detect-changes.outputs.chart == 'true'
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Check out repository code
uses: actions/checkout@v7
- name: Setup pnpm
uses: pnpm/action-setup@v6
- name: Setup Node.js
uses: actions/setup-node@v7
with:
node-version: '24'
- name: Install Helm
uses: azure/setup-helm@v5
with:
version: v3.16.4
- name: Build chart dependencies
run: pnpm chart:deps
- name: Lint chart
run: pnpm chart:lint
# Store contract suites when store paths change. Parallel with typecheck-and-build.
store-tests:
name: Store Tests
needs: detect-changes
if: needs.detect-changes.outputs.store == 'true'
runs-on: ubuntu-latest
timeout-minutes: 30
services:
postgres:
image: postgres:13-alpine
env:
POSTGRES_USER: proto
POSTGRES_PASSWORD: proto
POSTGRES_DB: proto
ports:
- 55432:5432
options: >-
--health-cmd "pg_isready -U proto -d proto"
--health-interval 5s
--health-timeout 5s
--health-retries 10
steps:
- name: Check out repository code
uses: actions/checkout@v7
- name: Setup pnpm
uses: pnpm/action-setup@v6
- name: Setup Node.js
uses: actions/setup-node@v7
with:
node-version: '24'
cache: 'pnpm'
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: SQLite store tests
run: pnpm test:store:sqlite
- name: Postgres store tests
env:
SESSION_STORE_TEST_PG_URL: postgres://proto:proto@localhost:55432/proto
run: pnpm test:store:postgres
# https://github.com/marketplace/actions/alls-green#why
check:
if: always()
needs:
- detect-changes
- migration-order
- typecheck-and-build
- package-checks
- chart-checks
- store-tests
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Decide whether the needed jobs succeeded or failed
env:
DETECT_CHANGES: ${{ needs.detect-changes.result }}
MIGRATION_ORDER: ${{ needs.migration-order.result }}
TYPECHECK_AND_BUILD: ${{ needs.typecheck-and-build.result }}
PACKAGE_CHECKS: ${{ needs.package-checks.result }}
CHART_CHECKS: ${{ needs.chart-checks.result }}
STORE_TESTS: ${{ needs.store-tests.result }}
run: |
ok() { [ "$1" = success ] || [ "$1" = skipped ]; }
echo "detect-changes=$DETECT_CHANGES migration-order=$MIGRATION_ORDER typecheck-and-build=$TYPECHECK_AND_BUILD package-checks=$PACKAGE_CHECKS chart-checks=$CHART_CHECKS store-tests=$STORE_TESTS"
[ "$DETECT_CHANGES" = success ] || exit 1
[ "$MIGRATION_ORDER" = success ] || exit 1
[ "$TYPECHECK_AND_BUILD" = success ] || exit 1
ok "$PACKAGE_CHECKS" || exit 1
ok "$CHART_CHECKS" || exit 1
ok "$STORE_TESTS" || exit 1