-
Notifications
You must be signed in to change notification settings - Fork 338
506 lines (432 loc) · 17.6 KB
/
ci.yml
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
503
504
505
506
name: Evals
on:
pull_request:
types:
- opened
- synchronize
- labeled
- unlabeled
env:
EVAL_MODELS: "gpt-4o,gpt-4o-mini,claude-3-5-sonnet-latest"
EVAL_CATEGORIES: "observe,act,combination,extract,text_extract"
concurrency:
group: ${{ github.ref }}
cancel-in-progress: true
jobs:
determine-evals:
runs-on: ubuntu-latest
outputs:
run-extract: ${{ steps.check-labels.outputs.run-extract }}
run-act: ${{ steps.check-labels.outputs.run-act }}
run-observe: ${{ steps.check-labels.outputs.run-observe }}
run-text-extract: ${{ steps.check-labels.outputs.run-text-extract }}
steps:
- id: check-labels
run: |
# Default to running all tests on main branch
if [[ "${{ github.ref }}" == "refs/heads/main" ]]; then
echo "Running all tests for main branch"
echo "run-extract=true" >> $GITHUB_OUTPUT
echo "run-act=true" >> $GITHUB_OUTPUT
echo "run-observe=true" >> $GITHUB_OUTPUT
echo "run-text-extract=true" >> $GITHUB_OUTPUT
exit 0
fi
# Check for specific labels
echo "run-extract=${{ contains(github.event.pull_request.labels.*.name, 'extract') }}" >> $GITHUB_OUTPUT
echo "run-act=${{ contains(github.event.pull_request.labels.*.name, 'act') }}" >> $GITHUB_OUTPUT
echo "run-observe=${{ contains(github.event.pull_request.labels.*.name, 'observe') }}" >> $GITHUB_OUTPUT
echo "run-text-extract=${{ contains(github.event.pull_request.labels.*.name, 'text-extract') }}" >> $GITHUB_OUTPUT
run-lint:
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
- name: Install dependencies
run: |
rm -rf node_modules
rm -f package-lock.json
npm install
- name: Run Lint
run: npm run lint
run-build:
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
- name: Install dependencies
run: |
rm -rf node_modules
rm -f package-lock.json
npm install
- name: Run Build
run: npm run build
run-e2e-tests:
needs: [run-lint, run-build]
runs-on: ubuntu-latest
timeout-minutes: 50
env:
HEADLESS: true
steps:
- name: Check out repository code
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
- name: Install dependencies
run: |
rm -rf node_modules
rm -f package-lock.json
npm install
- name: Install Playwright browsers
run: npm exec playwright install --with-deps
- name: Build Stagehand
run: npm run build
- name: Run E2E Tests (Deterministic Playwright)
run: npm run e2e
run-e2e-bb-tests:
needs: [run-e2e-tests]
runs-on: ubuntu-latest
timeout-minutes: 50
if: >
github.event_name == 'push' ||
(github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository)
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
BROWSERBASE_API_KEY: ${{ secrets.BROWSERBASE_API_KEY }}
BROWSERBASE_PROJECT_ID: ${{ secrets.BROWSERBASE_PROJECT_ID }}
HEADLESS: true
steps:
- name: Check out repository code
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
- name: Install dependencies
run: |
rm -rf node_modules
rm -f package-lock.json
npm install
- name: Install Playwright browsers
run: npm exec playwright install --with-deps
- name: Build Stagehand
run: npm run build
- name: Run E2E Tests (browserbase)
run: npm run e2e:bb
run-combination-evals:
needs: [run-e2e-bb-tests, run-e2e-tests, determine-evals]
runs-on: ubuntu-latest
timeout-minutes: 40
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
BRAINTRUST_API_KEY: ${{ secrets.BRAINTRUST_API_KEY }}
BROWSERBASE_API_KEY: ${{ secrets.BROWSERBASE_API_KEY }}
BROWSERBASE_PROJECT_ID: ${{ secrets.BROWSERBASE_PROJECT_ID }}
HEADLESS: true
EVAL_ENV: browserbase
steps:
- name: Check out repository code
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
- name: Install dependencies
run: |
rm -rf node_modules
rm -f package-lock.json
npm install
- name: Build Stagehand
run: npm run build
- name: Install Playwright browsers
run: npm exec playwright install --with-deps
- name: Run Combination Evals
run: npm run evals category combination
- name: Log Combination Evals Performance
run: |
experimentName=$(jq -r '.experimentName' eval-summary.json)
echo "View results at https://www.braintrust.dev/app/Browserbase/p/stagehand/experiments/${experimentName}"
if [ -f eval-summary.json ]; then
combination_score=$(jq '.categories.combination' eval-summary.json)
echo "Combination category score: $combination_score%"
exit 0
else
echo "Eval summary not found for combination category. Failing CI."
exit 1
fi
run-act-evals:
needs: [run-combination-evals, determine-evals]
runs-on: ubuntu-latest
timeout-minutes: 25
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
BRAINTRUST_API_KEY: ${{ secrets.BRAINTRUST_API_KEY }}
BROWSERBASE_API_KEY: ${{ secrets.BROWSERBASE_API_KEY }}
BROWSERBASE_PROJECT_ID: ${{ secrets.BROWSERBASE_PROJECT_ID }}
HEADLESS: true
EVAL_ENV: browserbase
steps:
- name: Check out repository code
uses: actions/checkout@v4
- name: Check for 'act' label
id: label-check
run: |
if [ "${{ needs.determine-evals.outputs.run-act }}" != "true" ]; then
echo "has_label=false" >> $GITHUB_OUTPUT
echo "No label for ACT. Exiting with success."
else
echo "has_label=true" >> $GITHUB_OUTPUT
fi
- name: Set up Node.js
if: needs.determine-evals.outputs.run-act == 'true'
uses: actions/setup-node@v4
with:
node-version: "20"
- name: Install dependencies
if: needs.determine-evals.outputs.run-act == 'true'
run: |
rm -rf node_modules
rm -f package-lock.json
npm install
- name: Build Stagehand
if: needs.determine-evals.outputs.run-act == 'true'
run: npm run build
- name: Install Playwright browsers
if: needs.determine-evals.outputs.run-act == 'true'
run: npm exec playwright install --with-deps
- name: Run Act Evals
if: needs.determine-evals.outputs.run-act == 'true'
run: npm run evals category act
- name: Log Act Evals Performance
if: needs.determine-evals.outputs.run-act == 'true'
run: |
experimentName=$(jq -r '.experimentName' eval-summary.json)
echo "View results at https://www.braintrust.dev/app/Browserbase/p/stagehand/experiments/${experimentName}"
if [ -f eval-summary.json ]; then
act_score=$(jq '.categories.act' eval-summary.json)
echo "Act category score: $act_score%"
if (( $(echo "$act_score < 80" | bc -l) )); then
echo "Act category score is below 80%. Failing CI."
exit 1
fi
else
echo "Eval summary not found for act category. Failing CI."
exit 1
fi
run-extract-evals:
needs: [run-act-evals, determine-evals]
runs-on: ubuntu-latest
timeout-minutes: 50
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
BRAINTRUST_API_KEY: ${{ secrets.BRAINTRUST_API_KEY }}
BROWSERBASE_API_KEY: ${{ secrets.BROWSERBASE_API_KEY }}
BROWSERBASE_PROJECT_ID: ${{ secrets.BROWSERBASE_PROJECT_ID }}
HEADLESS: true
EVAL_ENV: browserbase
steps:
- name: Check out repository code
uses: actions/checkout@v4
- name: Check for 'extract' label
id: label-check
run: |
if [ "${{ needs.determine-evals.outputs.run-extract }}" != "true" ]; then
echo "has_label=false" >> $GITHUB_OUTPUT
echo "No label for EXTRACT. Exiting with success."
else
echo "has_label=true" >> $GITHUB_OUTPUT
fi
- name: Set up Node.js
if: needs.determine-evals.outputs.run-extract == 'true'
uses: actions/setup-node@v4
with:
node-version: "20"
- name: Install dependencies
if: needs.determine-evals.outputs.run-extract == 'true'
run: |
rm -rf node_modules
rm -f package-lock.json
npm install
- name: Build Stagehand
if: needs.determine-evals.outputs.run-extract == 'true'
run: npm run build
- name: Install Playwright browsers
if: needs.determine-evals.outputs.run-extract == 'true'
run: npm exec playwright install --with-deps
# 1. Run extract category with domExtract
- name: Run Extract Evals (domExtract)
if: needs.determine-evals.outputs.run-extract == 'true'
run: npm run evals category extract -- --extract-method=domExtract
- name: Save Extract Dom Results
if: needs.determine-evals.outputs.run-extract == 'true'
run: mv eval-summary.json eval-summary-extract-dom.json
# 2. Then run extract category with textExtract
- name: Run Extract Evals (textExtract)
if: needs.determine-evals.outputs.run-extract == 'true'
run: npm run evals category extract -- --extract-method=textExtract
- name: Save Extract Text Results
if: needs.determine-evals.outputs.run-extract == 'true'
run: mv eval-summary.json eval-summary-extract-text.json
# 3. Log and Compare Extract Evals Performance
- name: Log and Compare Extract Evals Performance
if: needs.determine-evals.outputs.run-extract == 'true'
run: |
experimentNameDom=$(jq -r '.experimentName' eval-summary-extract-dom.json)
dom_score=$(jq '.categories.extract' eval-summary-extract-dom.json)
echo "DomExtract Extract category score: $dom_score%"
echo "View domExtract results: https://www.braintrust.dev/app/Browserbase/p/stagehand/experiments/${experimentNameDom}"
experimentNameText=$(jq -r '.experimentName' eval-summary-extract-text.json)
text_score=$(jq '.categories.extract' eval-summary-extract-text.json)
echo "TextExtract Extract category score: $text_score%"
echo "View textExtract results: https://www.braintrust.dev/app/Browserbase/p/stagehand/experiments/${experimentNameText}"
# If domExtract <80% fail CI
if (( $(echo "$dom_score < 80" | bc -l) )); then
echo "DomExtract extract category score is below 80%. Failing CI."
exit 1
fi
run-text-extract-evals:
needs: [run-extract-evals, determine-evals]
runs-on: ubuntu-latest
timeout-minutes: 120
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
BRAINTRUST_API_KEY: ${{ secrets.BRAINTRUST_API_KEY }}
BROWSERBASE_API_KEY: ${{ secrets.BROWSERBASE_API_KEY }}
BROWSERBASE_PROJECT_ID: ${{ secrets.BROWSERBASE_PROJECT_ID }}
HEADLESS: true
EVAL_ENV: browserbase
steps:
- name: Check out repository code
uses: actions/checkout@v4
- name: Check for 'text-extract' label
id: label-check
run: |
if [ "${{ needs.determine-evals.outputs.run-text-extract }}" != "true" ]; then
echo "has_label=false" >> $GITHUB_OUTPUT
echo "No label for TEXT-EXTRACT. Exiting with success."
else
echo "has_label=true" >> $GITHUB_OUTPUT
fi
- name: Set up Node.js
if: needs.determine-evals.outputs.run-text-extract == 'true'
uses: actions/setup-node@v4
with:
node-version: "20"
- name: Install dependencies
if: needs.determine-evals.outputs.run-text-extract == 'true'
run: |
rm -rf node_modules
rm -f package-lock.json
npm install
- name: Install Playwright browsers
if: needs.determine-evals.outputs.run-text-extract == 'true'
run: npm exec playwright install --with-deps
- name: Build Stagehand
if: needs.determine-evals.outputs.run-text-extract == 'true'
run: npm run build
# 1. Run text_extract category with textExtract first
- name: Run text_extract Evals (textExtract)
if: needs.determine-evals.outputs.run-text-extract == 'true'
run: npm run evals category text_extract -- --extract-method=textExtract
- name: Save text_extract Text Results
if: needs.determine-evals.outputs.run-text-extract == 'true'
run: mv eval-summary.json eval-summary-text_extract-text.json
# 2. Then run text_extract category with domExtract
- name: Run text_extract Evals (domExtract)
if: needs.determine-evals.outputs.run-text-extract == 'true'
run: npm run evals category text_extract -- --extract-method=domExtract
- name: Save text_extract Dom Results
if: needs.determine-evals.outputs.run-text-extract == 'true'
run: mv eval-summary.json eval-summary-text_extract-dom.json
# 3. Log and Compare text_extract Evals Performance
- name: Log and Compare text_extract Evals Performance
if: needs.determine-evals.outputs.run-text-extract == 'true'
run: |
experimentNameText=$(jq -r '.experimentName' eval-summary-text_extract-text.json)
text_score=$(jq '.categories.text_extract' eval-summary-text_extract-text.json)
echo "TextExtract text_extract category score: $text_score%"
echo "View textExtract results: https://www.braintrust.dev/app/Browserbase/p/stagehand/experiments/${experimentNameText}"
experimentNameDom=$(jq -r '.experimentName' eval-summary-text_extract-dom.json)
dom_score=$(jq '.categories.text_extract' eval-summary-text_extract-dom.json)
echo "DomExtract text_extract category score: $dom_score%"
echo "View domExtract results: https://www.braintrust.dev/app/Browserbase/p/stagehand/experiments/${experimentNameDom}"
# If text_score <80% fail CI
if (( $(echo "$text_score < 80" | bc -l) )); then
echo "textExtract text_extract category score is below 80%. Failing CI."
exit 1
fi
run-observe-evals:
needs: [run-text-extract-evals, determine-evals]
runs-on: ubuntu-latest
timeout-minutes: 25
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
BRAINTRUST_API_KEY: ${{ secrets.BRAINTRUST_API_KEY }}
BROWSERBASE_API_KEY: ${{ secrets.BROWSERBASE_API_KEY }}
BROWSERBASE_PROJECT_ID: ${{ secrets.BROWSERBASE_PROJECT_ID }}
HEADLESS: true
EVAL_ENV: browserbase
steps:
- name: Check out repository code
uses: actions/checkout@v4
- name: Check for 'observe' label
id: label-check
run: |
if [ "${{ needs.determine-evals.outputs.run-observe }}" != "true" ]; then
echo "has_label=false" >> $GITHUB_OUTPUT
echo "No label for OBSERVE. Exiting with success."
else
echo "has_label=true" >> $GITHUB_OUTPUT
fi
- name: Set up Node.js
if: needs.determine-evals.outputs.run-observe == 'true'
uses: actions/setup-node@v4
with:
node-version: "20"
- name: Install dependencies
if: needs.determine-evals.outputs.run-observe == 'true'
run: |
rm -rf node_modules
rm -f package-lock.json
npm install
- name: Install Playwright browsers
if: needs.determine-evals.outputs.run-observe == 'true'
run: npm exec playwright install --with-deps
- name: Build Stagehand
if: needs.determine-evals.outputs.run-observe == 'true'
run: npm run build
- name: Run Observe Evals
if: needs.determine-evals.outputs.run-observe == 'true'
run: npm run evals category observe
- name: Log Observe Evals Performance
if: needs.determine-evals.outputs.run-observe == 'true'
run: |
experimentName=$(jq -r '.experimentName' eval-summary.json)
echo "View results at https://www.braintrust.dev/app/Browserbase/p/stagehand/experiments/${experimentName}"
if [ -f eval-summary.json ]; then
observe_score=$(jq '.categories.observe' eval-summary.json)
echo "Observe category score: $observe_score%"
if (( $(echo "$observe_score < 80" | bc -l) )); then
echo "Observe category score is below 80%. Failing CI."
exit 1
fi
else
echo "Eval summary not found for observe category. Failing CI."
exit 1
fi