-
Notifications
You must be signed in to change notification settings - Fork 68
229 lines (189 loc) · 6.29 KB
/
Copy pathdocs-ingestion-ci.yml
File metadata and controls
229 lines (189 loc) · 6.29 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
name: Docs Ingestion CI
on:
pull_request:
branches: [main]
paths:
- 'docs-ingestion/**'
- 'docs-embeddings/**'
- 'api-references/**'
- 'content/**'
push:
branches: [main]
paths:
- 'docs-ingestion/**'
- 'docs-embeddings/**'
- 'api-references/**'
jobs:
build-and-test:
name: Build & Test
runs-on: ubuntu-latest
defaults:
run:
working-directory: docs-ingestion
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: docs-ingestion/package-lock.json
- name: Install dependencies
run: npm ci
- name: Build
run: npm run build
# ── E. Test suite ──
- name: Run tests
run: npm test
normalize-api-specs:
name: API Spec Normalization
runs-on: ubuntu-latest
defaults:
run:
working-directory: docs-ingestion
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: docs-ingestion/package-lock.json
- name: Install dependencies
run: npm ci
# ── A. Normalization run ──
- name: Run API spec normalization
run: npm run normalize-api-specs
- name: Verify output directory exists
run: |
if [ ! -d "../.api-reference-normalized" ]; then
echo "FAIL: .api-reference-normalized/ directory does not exist"
exit 1
fi
echo "PASS: Directory exists"
- name: Verify file count
run: |
count=$(find ../.api-reference-normalized -name '*.md' | wc -l | tr -d ' ')
echo "Found $count normalized files"
if [ "$count" -lt 200 ]; then
echo "FAIL: Expected at least 200 files, got $count"
exit 1
fi
echo "PASS: File count ($count) >= 200"
# ── B. Determinism check ──
- name: Copy first run output
run: cp -r ../.api-reference-normalized /tmp/api-ref-norm-run1
- name: Run normalization again
run: npm run normalize-api-specs
- name: Verify determinism
run: |
diff_output=$(diff -r ../.api-reference-normalized /tmp/api-ref-norm-run1 2>&1) || true
if [ -n "$diff_output" ]; then
echo "FAIL: Normalization is not deterministic:"
echo "$diff_output" | head -20
exit 1
fi
echo "PASS: Output is deterministic"
# ── C. Token limit compliance ──
- name: Check token limits
run: npm run check-token-limits
# ── F. Git ignored state check ──
- name: Verify .api-reference-normalized is gitignored
run: |
cd ..
if git ls-files --error-unmatch .api-reference-normalized/ 2>/dev/null; then
echo "FAIL: .api-reference-normalized/ is tracked by git"
exit 1
fi
echo "PASS: .api-reference-normalized/ is not tracked"
- name: Verify .docs-normalized is gitignored
run: |
cd ..
if git ls-files --error-unmatch .docs-normalized/ 2>/dev/null; then
echo "FAIL: .docs-normalized/ is tracked by git"
exit 1
fi
echo "PASS: .docs-normalized/ is not tracked"
ingestion-smoke-test:
name: Ingestion Smoke Test
runs-on: ubuntu-latest
needs: [build-and-test, normalize-api-specs]
defaults:
run:
working-directory: docs-ingestion
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: docs-ingestion/package-lock.json
- name: Install dependencies
run: npm ci
- name: Build
run: npm run build
# Generate the normalized API specs (required for smoke test)
- name: Normalize API specs
run: npm run normalize-api-specs
# Normalize MDX if content/ exists
- name: Normalize MDX (if content exists)
run: |
if [ -d "../content" ]; then
npm run normalize-mdx
else
echo "No content/ directory — skipping MDX normalization"
fi
# ── D. Ingestion smoke test ──
- name: Run ingestion smoke test
run: npm run smoke-test-ingestion
embedding-dry-run:
name: Embedding Dry Run
runs-on: ubuntu-latest
needs: [ingestion-smoke-test]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: docs-ingestion/package-lock.json
# Build ingestion pipeline and produce chunks.json
- name: Install ingestion dependencies
working-directory: docs-ingestion
run: npm ci
- name: Build ingestion
working-directory: docs-ingestion
run: npm run build
- name: Normalize API specs
working-directory: docs-ingestion
run: npm run normalize-api-specs
- name: Normalize MDX (if content exists)
working-directory: docs-ingestion
run: |
if [ -d "../content" ]; then
npm run normalize-mdx
else
echo "No content/ directory — skipping MDX normalization"
fi
- name: Run ingestion pipeline
working-directory: docs-ingestion
run: node dist/index.js
- name: Verify chunks.json exists
run: |
if [ ! -f "docs-ingestion/output/chunks.json" ]; then
echo "FAIL: chunks.json not produced"
exit 1
fi
echo "PASS: chunks.json exists"
# Build embeddings pipeline and run dry-run
- name: Install embedding dependencies
working-directory: docs-embeddings
run: npm ci
- name: Build embeddings
working-directory: docs-embeddings
run: npm run build
# ── E. Embedding dry run ──
- name: Run embedding dry run
working-directory: docs-embeddings
env:
DRY_RUN: 'true'
INGESTION_OUTPUT_PATH: ${{ github.workspace }}/docs-ingestion/output/chunks.json
run: node dist/index.js --dry-run