-
Notifications
You must be signed in to change notification settings - Fork 26
502 lines (419 loc) · 14.2 KB
/
Copy pathci.yml
File metadata and controls
502 lines (419 loc) · 14.2 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
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
name: CI
on:
push:
branches: [main, feat/**]
pull_request:
branches: [main]
workflow_dispatch: # Allow manual trigger
# Cancel in-progress runs for the same workflow + branch/PR
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
lint:
name: Lint & Format Check
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- name: Install dependencies
run: bun install --frozen-lockfile
- name: Run Prettier check
run: bunx prettier --check "**/*.{ts,tsx,js,jsx,json,md}"
continue-on-error: true
- name: Run Biome lint
run: bun run lint
continue-on-error: true
check-narration:
name: Narration Leakage Check
runs-on: ubuntu-latest
continue-on-error: true # Optional but available
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- name: Run Narration Guardrail
run: |
cd packages/api-server
bash scripts/check-narration-leakage.sh
typecheck:
name: TypeScript Type Check
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- name: Install dependencies
run: bun install --frozen-lockfile
- name: TypeScript type check
run: bun run typecheck
lint-patterns:
name: Lint Effect Patterns
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- name: Install dependencies
run: bun install --frozen-lockfile
- name: Lint Effect patterns
run: bun run packages/ep-cli/dist/index.js lint content/new/src/*.ts
continue-on-error: true
test-toolkit:
name: Unit Tests - Toolkit
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- name: Install dependencies
run: bun install --frozen-lockfile
- name: Run toolkit tests with coverage
run: cd packages/toolkit && bun run test:coverage
env:
CI: true
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
if: github.event_name == 'push'
with:
files: ./packages/toolkit/coverage/coverage-final.json
flags: toolkit
name: toolkit-coverage
fail_ci_if_error: false
- name: Upload coverage artifacts
uses: actions/upload-artifact@v7
with:
name: toolkit-coverage
path: packages/toolkit/coverage/
retention-days: 7
build-toolkit:
name: Build - Toolkit
runs-on: ubuntu-latest
needs: [lint, typecheck, test-toolkit]
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- name: Install dependencies
run: bun install --frozen-lockfile
- name: Build toolkit
run: cd packages/toolkit && bun run build
- name: Emit JSON schemas
run: cd packages/toolkit && bun run build:schemas
- name: Verify schema output
run: |
if [ ! -f "packages/toolkit/dist/schemas/generate-request.json" ]; then
echo "Error: JSON schemas not generated"
exit 1
fi
- name: Upload build artifacts
uses: actions/upload-artifact@v7
with:
name: toolkit-dist
path: packages/toolkit/dist/
retention-days: 7
build-mcp-server:
name: Build - MCP Server
runs-on: ubuntu-latest
needs: [lint, typecheck, build-toolkit]
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- name: Install dependencies
run: bun install --frozen-lockfile
- name: Download toolkit build artifact
uses: actions/download-artifact@v8
with:
name: toolkit-dist
path: packages/toolkit/dist/
- name: Build MCP server
run: cd packages/api-server && bun run build
env:
SKIP_ENV_VALIDATION: true
- name: Upload build artifacts
uses: actions/upload-artifact@v7
with:
name: mcp-server-dist
path: packages/api-server/.next/
retention-days: 7
test-ep-cli:
name: Release Gate - ep-cli
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- name: Install dependencies
run: bun install --frozen-lockfile
- name: Build ep-cli dependencies
run: |
bun run --filter @effect-patterns/ep-shared-services build
bun run --filter @effect-patterns/toolkit build
- name: Typecheck ep-cli
run: bun run --filter @effect-patterns/ep-cli typecheck
- name: Test ep-cli
run: bun run --filter @effect-patterns/ep-cli test -- --reporter=dot
- name: Build ep-cli
run: bun run --filter @effect-patterns/ep-cli build
- name: Smoke test ep-cli executable
run: |
test -s packages/ep-cli/dist/index.js
test-ep-admin:
name: Release Gate - ep-admin
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- name: Install dependencies
run: bun install --frozen-lockfile
- name: Build ep-admin dependencies
run: |
bun run --filter @effect-patterns/ep-shared-services build
bun run --filter @effect-patterns/toolkit build
bun run --filter @effect-patterns/pipeline-state build
- name: Typecheck ep-admin
run: bun run --filter @effect-patterns/ep-admin typecheck
- name: Test ep-admin
run: bun run --filter @effect-patterns/ep-admin test -- --reporter=dot
- name: Run ep-admin coverage
run: cd packages/ep-admin && bun run test:coverage
- name: Verify ep-admin coverage thresholds
run: |
node <<'EOF'
const fs = require("node:fs");
const summaryPath = "packages/ep-admin/coverage/coverage-summary.json";
if (!fs.existsSync(summaryPath)) {
console.error(`Missing coverage summary: ${summaryPath}`);
process.exit(1);
}
const summary = JSON.parse(fs.readFileSync(summaryPath, "utf8"));
const total = summary.total ?? {};
const checks = [
["lines", 85],
["statements", 85],
["functions", 85],
["branches", 70],
];
let failed = false;
for (const [metric, min] of checks) {
const pct = total?.[metric]?.pct;
if (typeof pct !== "number") {
console.error(`Coverage metric '${metric}' is missing`);
failed = true;
continue;
}
if (pct < min) {
console.error(`Coverage ${metric} ${pct}% is below required ${min}%`);
failed = true;
} else {
console.log(`Coverage ${metric} ${pct}% meets required ${min}%`);
}
}
if (failed) {
process.exit(1);
}
EOF
- name: Smoke test ep-admin command surface
run: |
set -euo pipefail
run_ep_admin() {
bun packages/ep-admin/src/index.ts "$@"
}
run_ep_admin --help > /tmp/ep-admin-help.txt
grep -q "Top-level commands:" /tmp/ep-admin-help.txt
NO_COLOR=1 run_ep_admin --help > /tmp/ep-admin-help-nocolor.txt
run_ep_admin auth --help > /dev/null
run_ep_admin publish --help > /dev/null
run_ep_admin pattern --help > /dev/null
run_ep_admin data --help > /dev/null
run_ep_admin db --help > /dev/null
run_ep_admin dev --help > /dev/null
run_ep_admin ops --help > /dev/null
run_ep_admin config --help > /dev/null
run_ep_admin system --help > /dev/null
run_ep_admin release --help > /dev/null
tmpdir="$(mktemp -d)"
export EP_ADMIN_AUTH_CONFIG_FILE="$tmpdir/config/auth.json"
export EP_ADMIN_AUTH_SESSION_FILE="$tmpdir/state/session.json"
run_ep_admin auth init \
--passphrase "ci-passphrase-123" \
--confirm-passphrase "ci-passphrase-123" \
--service-token "ci-token-123" \
--json > /tmp/ep-admin-auth-init.json
EP_ADMIN_SERVICE_TOKEN="ci-token-123" \
run_ep_admin ops rotate-api-key --json > /tmp/ep-admin-ops.json
node <<'EOF'
const fs = require("node:fs");
const payload = JSON.parse(fs.readFileSync("/tmp/ep-admin-ops.json", "utf8"));
if (!payload.ok || payload.action !== "rotate-api-key") {
console.error("Unexpected ops rotate-api-key payload", payload);
process.exit(1);
}
EOF
set +e
EP_ADMIN_SERVICE_TOKEN="ci-token-123" \
run_ep_admin ops mcp list-rulez > /tmp/ep-admin-typo.out 2>&1
typo_status=$?
set -e
if [ "$typo_status" -eq 0 ]; then
echo "Expected typo command to fail, but it succeeded"
exit 1
fi
grep -q "Did you mean: ep-admin ops mcp list-rules" /tmp/ep-admin-typo.out
grep -q "Run: ep-admin ops mcp --help" /tmp/ep-admin-typo.out
rm -rf "$tmpdir"
- name: Upload ep-admin coverage artifacts
uses: actions/upload-artifact@v7
with:
name: ep-admin-coverage
path: packages/ep-admin/coverage/
retention-days: 7
test-integration:
name: Integration Tests - MCP Server
runs-on: ubuntu-latest
needs: [build-toolkit, build-mcp-server]
continue-on-error: true # Optional but available - catches env drift
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- name: Install dependencies
run: bun install --frozen-lockfile
- name: Download toolkit build artifact
uses: actions/download-artifact@v8
with:
name: toolkit-dist
path: packages/toolkit/dist/
- name: Run integration tests
run: cd packages/api-server && bun run test:integration
env:
PATTERN_API_KEY: test-api-key-for-ci
TEST_BASE_URL: http://localhost:3000
- name: Build MCP stdio for protocol tests
run: cd packages/mcp-transport && bun run mcp:build
- name: Start API server for MCP protocol tests
run: |
cd packages/api-server
PORT=3000 bun run dev > ../../mcp-server.log 2>&1 &
echo $! > ../../mcp-server.pid
sleep 2
if ! kill -0 "$(cat ../../mcp-server.pid)" 2>/dev/null; then
echo "MCP API server exited before readiness check"
cat ../../mcp-server.log || true
exit 1
fi
env:
PATTERN_API_KEY: test-api-key-for-ci
OTLP_ENDPOINT: http://localhost:4318/v1/traces
NODE_ENV: test
- name: Wait for API server to be ready
run: |
timeout 90 bash -c 'until curl -fsS http://localhost:3000/api/health > /dev/null; do sleep 2; done'
- name: Run MCP protocol tests (tool surface + structured output)
run: cd packages/mcp-transport && bun run test:mcp:ci
env:
PATTERN_API_KEY: test-api-key-for-ci
MCP_ENV: local
- name: Dump MCP server logs on failure
if: failure()
run: |
if [ -f mcp-server.log ]; then
cat mcp-server.log
fi
- name: Stop server
if: always()
run: |
if [ -f mcp-server.pid ]; then
kill $(cat mcp-server.pid) || true
fi
rm -f mcp-server.pid mcp-server.log
coverage-report:
name: Coverage Report
runs-on: ubuntu-latest
needs: [test-toolkit, test-ep-admin]
if: github.event_name == 'pull_request'
steps:
- name: Download toolkit coverage artifacts
uses: actions/download-artifact@v8
with:
name: toolkit-coverage
- name: Display toolkit coverage summary
run: |
if [ -f coverage-summary.json ]; then
cat coverage-summary.json
fi
- name: Download ep-admin coverage artifacts
uses: actions/download-artifact@v8
with:
name: ep-admin-coverage
path: ep-admin-coverage
- name: Display ep-admin coverage summary
run: |
if [ -f ep-admin-coverage/coverage-summary.json ]; then
cat ep-admin-coverage/coverage-summary.json
else
echo "Missing ep-admin coverage summary"
exit 1
fi
# All checks must pass
ci-success:
name: CI Success
runs-on: ubuntu-latest
needs:
[
lint,
check-narration,
typecheck,
test-toolkit,
test-ep-cli,
test-ep-admin,
build-toolkit,
build-mcp-server,
test-integration,
]
if: always()
steps:
- name: Check all jobs status
run: |
if [[ "${{ contains(needs.*.result, 'failure') }}" == "true" ]]; then
echo "One or more CI jobs failed"
exit 1
fi
if [[ "${{ contains(needs.*.result, 'cancelled') }}" == "true" ]]; then
echo "One or more CI jobs were cancelled"
exit 1
fi
echo "All CI jobs passed successfully!"