-
Notifications
You must be signed in to change notification settings - Fork 0
315 lines (267 loc) · 11 KB
/
ci.yml
File metadata and controls
315 lines (267 loc) · 11 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
name: StringRay CI/CD
on:
push:
branches: [master]
pull_request:
branches: [master]
workflow_dispatch:
schedule:
- cron: "0 8 * * *" # Daily at 8 AM UTC
env:
NODE_VERSION: "20.x"
jobs:
# ═══════════════════════════════════════════════════════
# Docs Build Validation
# ═══════════════════════════════════════════════════════
docs-build:
name: Docs Build
runs-on: ubuntu-latest
if: ${{ github.event_name == 'pull_request' || contains(github.event.head_commit.message, 'docs') }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: "npm"
cache-dependency-path: docs-site/package-lock.json
- name: Install docs dependencies
run: cd docs-site && npm ci
- name: Build docs site
run: cd docs-site && npm run build
- name: Upload docs artifact
if: success()
uses: actions/upload-artifact@v4
with:
name: docs-preview
path: docs-site/build/
retention-days: 7
# ═══════════════════════════════════════════════════════
# Quality Checks
# ═══════════════════════════════════════════════════════
quality:
name: Quality Checks
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: "npm"
- name: Install dependencies
run: npm ci --ignore-scripts
- name: TypeScript check
run: npm run typecheck
- name: ESLint
run: npm run lint
# ═══════════════════════════════════════════════════════
# Unit Tests
# ═══════════════════════════════════════════════════════
test-unit:
name: Unit Tests
runs-on: ubuntu-latest
needs: quality
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: "npm"
- name: Install dependencies
run: npm ci
- name: Build
run: npm run build:all
- name: Run unit tests
run: npm test
# ═══════════════════════════════════════════════════════
# Pipeline Tests (gated: schedule, needs-pipeline, or ci:full)
# ═══════════════════════════════════════════════════════
test-pipeline:
name: Pipeline Tests
runs-on: ubuntu-latest
needs: test-unit
if: |
github.event_name == 'schedule' ||
contains(github.event.pull_request.labels.*.name, 'needs-pipeline') ||
contains(github.event.pull_request.labels.*.name, 'ci:full')
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: "npm"
- name: Install dependencies
run: npm ci
- name: Build
run: npm run build:all
- name: Run pipeline tests
run: npm run test:pipelines
# ═══════════════════════════════════════════════════════
# Consumer Package Test (gated: schedule, needs-pipeline, or ci:full)
# ═══════════════════════════════════════════════════════
test-package:
name: Package Installation
runs-on: ubuntu-latest
needs: test-pipeline
if: |
github.event_name == 'schedule' ||
contains(github.event.pull_request.labels.*.name, 'needs-pipeline') ||
contains(github.event.pull_request.labels.*.name, 'ci:full')
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: "npm"
- name: Install dependencies
run: npm ci
- name: Build package
run: |
npm run build:all
npm pack
- name: Create test project
run: |
mkdir -p test-install
cd test-install
npm init -y
npm install ../strray-ai-*.tgz
- name: Run postinstall
run: |
cd test-install
rm -f ~/.hermes # Ensure Hermes isn't detected in CI
node node_modules/strray-ai/scripts/node/postinstall.cjs
- name: Validate postinstall
env:
CI: "true"
run: |
cd test-install
# Skip full validation in CI - just verify package was installed
ls node_modules/strray-ai/package.json || exit 1
echo "✅ Package installed successfully"
- name: Validate MCP
env:
CI: "true"
run: |
cd test-install
node node_modules/strray-ai/scripts/mjs/validate-mcp-connectivity.cjs || true
# ═══════════════════════════════════════════════════════
# Security Audit (gated: schedule, needs-pipeline, or ci:full)
# ═══════════════════════════════════════════════════════
security:
name: Security Audit
runs-on: ubuntu-latest
needs: test-package
if: |
github.event_name == 'schedule' ||
contains(github.event.pull_request.labels.*.name, 'needs-pipeline') ||
contains(github.event.pull_request.labels.*.name, 'ci:full')
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: "npm"
- name: Install dependencies
run: npm ci
- name: Security audit
run: npm audit --audit-level=high || true
# ═══════════════════════════════════════════════════════
# Codex Enforcement Gate
# ═══════════════════════════════════════════════════════
enforcement:
name: Codex Enforcement
runs-on: ubuntu-latest
needs: [quality, test-unit]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: "npm"
- name: Install dependencies
run: npm ci --ignore-scripts
- name: Build
run: npm run build
- name: Run Codex Enforcement Check
run: |
echo "Running codex-check against codebase..."
node dist/core/bridge.mjs codex-check --operation write --focus "full" || true
- name: Check enforcement violations
run: |
VIOLATIONS=$(grep -c "violation\|blocked\|failed" .opencode/logs/activity.log 2>/dev/null || echo "0")
echo "Enforcement violations found: $VIOLATIONS"
if [ "$VIOLATIONS" -gt "0" ]; then
echo "⚠️ Codex violations detected - review .opencode/logs/activity.log"
fi
# ═══════════════════════════════════════════════════════
# CI/CD Health Monitor (runs after all jobs)
# ═══════════════════════════════════════════════════════
ci-health:
name: CI Health Monitor
runs-on: ubuntu-latest
needs: [ci-summary, docs-build]
if: always()
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: "npm"
- name: Run health monitor
run: node scripts/node/ci-cd-auto-fix.cjs
- name: Auto-generate reflection on failure
if: failure()
run: |
echo "CI failed - auto-generating reflection stub"
node scripts/node/auto-reflection-generator.mjs --trigger ci-failure --title "CI failure investigation"
# Commit the reflection stub
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add docs/reflections/auto-ci-*.md 2>/dev/null || true
git commit -m "docs: auto-generated reflection stub for CI failure" 2>/dev/null || true
git push 2>/dev/null || true
- name: Upload health report
uses: actions/upload-artifact@v4
with:
name: ci-health-report
path: .opencode/logs/ci-cd-monitor-report.json
# ═══════════════════════════════════════════════════════
# CI Summary Job (single required status check)
# ═══════════════════════════════════════════════════════
ci-summary:
name: CI Summary
runs-on: ubuntu-latest
needs: [quality, test-unit, enforcement]
if: always()
steps:
- name: Check required jobs status
run: |
echo "Quality: ${{ needs.quality.result }}"
echo "Unit Tests: ${{ needs.test-unit.result }}"
echo "Codex Enforcement: ${{ needs.enforcement.result }}"
if [ "${{ needs.quality.result }}" != "success" ] || \
[ "${{ needs.test-unit.result }}" != "success" ] || \
[ "${{ needs.enforcement.result }}" != "success" ]; then
echo "❌ One or more required jobs failed"
exit 1
fi
echo "✅ All required CI checks passed"