Repository navigation
486 lines (438 loc) · 19.5 KB
/
Copy patheval-refresh.yml
File metadata and controls
486 lines (438 loc) · 19.5 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
name: Refresh eval results
on:
workflow_dispatch:
inputs:
experiments: &experiments
description: "Comma-separated experiment names to run within each selected eval suite"
type: string
required: false
default: ""
eval: &eval
description: "Comma-separated eval ids to run (overrides suite)"
type: string
required: false
default: ""
suite: &suite
description: "Comma-separated suites to run (evals/<suite> with experiments/<suite>)"
type: string
required: false
default: ""
runs: &runs
description: "Independent scored runs per experiment/eval pair"
type: string
default: "3"
timeout_sec: &timeout_sec
description: "Timeout per run in seconds"
type: string
default: "720"
sandbox_concurrency: &sandbox_concurrency
description: "Maximum Vercel Sandboxes running at once"
type: string
default: "250"
cli_stable_version: &cli_stable_version
description: "Pin the cli suite's stable CLI version instead of resolving npm's latest dist-tag (blank to resolve)"
type: string
required: false
default: ""
cli_beta_version: &cli_beta_version
description: "Pin the cli suite's beta CLI version instead of resolving npm's beta dist-tag (blank to resolve)"
type: string
required: false
default: ""
cli_next_version: &cli_next_version
description: "Pin the cli suite's next CLI version instead of resolving npm's next dist-tag (blank to resolve)"
type: string
required: false
default: ""
workflow_call:
inputs:
experiments: *experiments
eval: *eval
suite: *suite
runs: *runs
timeout_sec: *timeout_sec
sandbox_concurrency: *sandbox_concurrency
cli_stable_version: *cli_stable_version
cli_beta_version: *cli_beta_version
cli_next_version: *cli_next_version
pull_request:
types: [opened, synchronize, labeled]
permissions:
contents: read
pull-requests: read
actions: read
concurrency:
group: eval-refresh-${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.event.pull_request.number || github.ref }}
# Supersede an in-flight run when a new commit is pushed to the same PR, but
# never cancel a workflow_dispatch run.
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
prepare:
if: >-
github.event_name == 'workflow_dispatch' ||
github.event_name == 'schedule' ||
(github.event_name == 'pull_request' &&
contains(github.event.pull_request.labels.*.name, 'run-evals-changed') &&
github.event.pull_request.head.repo.full_name == github.repository &&
(github.event.action != 'labeled' ||
github.event.label.name == 'run-evals-changed'))
runs-on: ubuntu-26.04
outputs:
pairs: ${{ steps.discover.outputs.pairs }}
runs: ${{ steps.inputs.outputs.runs }}
timeout_sec: ${{ steps.inputs.outputs.timeout_sec }}
sandbox_concurrency: ${{ steps.inputs.outputs.sandbox_concurrency }}
filter_changed: ${{ steps.inputs.outputs.filter_changed }}
cli_stable_version: ${{ steps.inputs.outputs.cli_stable_version }}
cli_beta_version: ${{ steps.inputs.outputs.cli_beta_version }}
cli_next_version: ${{ steps.inputs.outputs.cli_next_version }}
steps:
- name: Prepare inputs
id: inputs
shell: bash
run: |
set -euo pipefail
if [ "${{ github.event_name }}" != "pull_request" ]; then
experiments_override="${{ inputs.experiments }}"
eval_id="${{ inputs.eval }}"
suite="${{ inputs.suite }}"
runs="${{ inputs.runs }}"
timeout_sec="${{ inputs.timeout_sec }}"
sandbox_concurrency="${{ inputs.sandbox_concurrency }}"
cli_stable_version="${{ inputs.cli_stable_version }}"
cli_beta_version="${{ inputs.cli_beta_version }}"
cli_next_version="${{ inputs.cli_next_version }}"
if [ -z "$suite" ] && [ -z "$eval_id" ]; then
echo "::error::Set suite or eval to choose which evals to run."
exit 1
fi
else
experiments_override=""
eval_id=""
suite="benchmark,regression,docs,cli"
runs="3"
timeout_sec="720"
sandbox_concurrency="250"
cli_stable_version=""
cli_beta_version=""
cli_next_version=""
fi
suite_json="$(jq -Rc 'split(",") | map(gsub("^\\s+|\\s+$"; "")) | map(select(length > 0))' <<< "$suite")"
filter_changed="false"
if [ "${{ github.event_name }}" = "pull_request" ]; then
filter_changed="true"
fi
{
echo "experiments_override=$experiments_override"
echo "eval=$eval_id"
echo "suite=$suite_json"
echo "runs=$runs"
echo "timeout_sec=$timeout_sec"
echo "sandbox_concurrency=$sandbox_concurrency"
echo "filter_changed=$filter_changed"
echo "cli_stable_version=$cli_stable_version"
echo "cli_beta_version=$cli_beta_version"
echo "cli_next_version=$cli_next_version"
} >> "$GITHUB_OUTPUT"
- name: Checkout
uses: actions/checkout@9f698171ed81b15d1823a05fc7211befd50c8ae0 # v6.0.3
with:
ref: ${{ github.event_name == 'pull_request' && github.head_ref || github.ref }}
- name: Install pnpm
uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v5.0.0
- name: Setup Node.js
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version-file: .node-version
cache: pnpm
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Discover eval pairs
id: discover
env:
GH_TOKEN: ${{ github.token }}
shell: bash
run: |
set -euo pipefail
touch .env
suite_json='${{ steps.inputs.outputs.suite }}'
eval_ids="${{ steps.inputs.outputs.eval }}"
if [ -n "$eval_ids" ]; then
matching=()
while IFS= read -r id; do
compgen -G "evals/*/$id" > /dev/null && matching+=("$id")
done < <(jq -Rr 'split(",") | map(gsub("^\\s+|\\s+$"; "")) | .[]' <<< "$eval_ids")
else
matching=()
for dir in evals/*/*/; do
[ -d "$dir" ] || continue
id=$(basename "$dir")
[ -f "$dir/PROMPT.md" ] || continue
suite_val=$(basename "$(dirname "$dir")")
if jq -e --arg s "$suite_val" 'index($s) != null' <<< "$suite_json" > /dev/null 2>&1; then
matching+=("$id")
fi
done
fi
if [ "${{ steps.inputs.outputs.filter_changed }}" = "true" ]; then
changed_evals=$(gh pr diff ${{ github.event.pull_request.number }} --name-only \
| grep '^evals/' | cut -d/ -f3 | sort -u || true)
if [ -z "$changed_evals" ]; then
echo "No eval directories changed in this PR — nothing to run"
echo "pairs=[]" >> "$GITHUB_OUTPUT"
exit 0
fi
echo "Changed eval dirs: $changed_evals"
filtered=()
for id in "${matching[@]}"; do
if echo "$changed_evals" | grep -qx "$id"; then
filtered+=("$id")
fi
done
matching=("${filtered[@]+"${filtered[@]}"}")
fi
if [ "${#matching[@]}" -eq 0 ]; then
echo "Changed evals don't match requested suites: $suite_json"
echo "pairs=[]" >> "$GITHUB_OUTPUT"
exit 0
fi
pairs='[]'
experiments_override="$(jq -Rc 'split(",") | map(gsub("^\\s+|\\s+$"; "")) | map(select(length > 0))' <<< "${{ steps.inputs.outputs.experiments_override }}")"
checked_suites=" "
for id in "${matching[@]}"; do
eval_suite=$(basename "$(dirname "$(compgen -G "evals/*/$id")")")
if [ "$experiments_override" != "[]" ] && [[ "$checked_suites" != *" $eval_suite "* ]]; then
available="$(pnpm --silent eval -- list --suite "$eval_suite" | jq -c 'map(split("/")[1])')"
missing="$(jq -r --argjson available "$available" '. - $available | join(",")' <<< "$experiments_override")"
if [ -n "$missing" ]; then
echo "Experiments not found in $eval_suite: $missing" >&2
exit 1
fi
checked_suites+="$eval_suite "
fi
experiments_json="$(pnpm --silent eval -- list --suite "$eval_suite" --eval "$id" | jq -c --argjson want "$experiments_override" 'map(split("/")[1]) | if $want == [] then . else map(select(IN($want[]))) end')"
while IFS= read -r experiment; do
pairs="$(jq -c \
--arg eval_id "$id" \
--arg experiment "$experiment" \
--arg eval_suite "$eval_suite" \
'. + [{eval_id: $eval_id, experiment: $experiment, eval_suite: $eval_suite}]' \
<<< "$pairs")"
done < <(jq -r '.[]' <<< "$experiments_json")
done
if [ "$experiments_override" != "[]" ]; then
for suite in $checked_suites; do
matched="$(jq -c --arg suite "$suite" '[.[] | select(.eval_suite == $suite) | .experiment] | unique' <<< "$pairs")"
unmatched="$(jq -r --argjson matched "$matched" '. - $matched | join(",")' <<< "$experiments_override")"
if [ -n "$unmatched" ]; then
echo "Experiments that match no selected evals in $suite: $unmatched" >&2
exit 1
fi
done
fi
if [ "$(jq 'length' <<< "$pairs")" -eq 0 ]; then
echo "No experiment and eval pairs matched" >&2
exit 1
fi
echo "pairs=$pairs" >> "$GITHUB_OUTPUT"
run-evals:
needs: prepare
if: needs.prepare.outputs.pairs != '[]'
runs-on: ubuntu-26.04
# 60 min gives ~2x margin over the slowest observed run:
# https://github.com/supabase/evals/actions/runs/31802584549
timeout-minutes: 60
env:
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
AI_GATEWAY_API_KEY: ${{ secrets.AI_GATEWAY_API_KEY }}
XAI_API_KEY: ${{ secrets.XAI_API_KEY }}
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
VERCEL_TEAM_ID: ${{ secrets.VERCEL_TEAM_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
SPARK_API_URL: ${{ secrets.SPARK_API_URL }}
CLOUDFLARE_WARP_CLIENT_ID: ${{ secrets.CLOUDFLARE_WARP_CLIENT_ID }}
CLOUDFLARE_WARP_CLIENT_SECRET: ${{ secrets.CLOUDFLARE_WARP_CLIENT_SECRET }}
SUPABASE_CLI_STABLE_VERSION: ${{ needs.prepare.outputs.cli_stable_version }}
SUPABASE_CLI_BETA_VERSION: ${{ needs.prepare.outputs.cli_beta_version }}
SUPABASE_CLI_NEXT_VERSION: ${{ needs.prepare.outputs.cli_next_version }}
steps:
- name: Checkout
uses: actions/checkout@9f698171ed81b15d1823a05fc7211befd50c8ae0 # v6.0.3
with:
ref: ${{ github.event_name == 'pull_request' && github.head_ref || github.ref }}
- name: Install pnpm
uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v5.0.0
- name: Setup Node.js
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version-file: .node-version
cache: pnpm
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Write eval environment
shell: bash
run: |
set -euo pipefail
{
echo "ANTHROPIC_API_KEY=${ANTHROPIC_API_KEY}"
echo "OPENAI_API_KEY=${OPENAI_API_KEY}"
echo "AI_GATEWAY_API_KEY=${AI_GATEWAY_API_KEY}"
echo "XAI_API_KEY=${XAI_API_KEY}"
echo "SUPABASE_CLI_STABLE_VERSION=${SUPABASE_CLI_STABLE_VERSION}"
echo "SUPABASE_CLI_BETA_VERSION=${SUPABASE_CLI_BETA_VERSION}"
echo "SUPABASE_CLI_NEXT_VERSION=${SUPABASE_CLI_NEXT_VERSION}"
} > .env
- name: Run evals
env:
EVAL_PAIRS: ${{ needs.prepare.outputs.pairs }}
EVAL_REVISION: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
shell: bash
run: |
set -euo pipefail
pnpm --filter @supabase-evals/framework eval:vercel -- \
--pairs-json "$EVAL_PAIRS" \
--revision "$EVAL_REVISION" \
--runs "${{ needs.prepare.outputs.runs }}" \
--timeout-sec "${{ needs.prepare.outputs.timeout_sec }}" \
--concurrency "${{ needs.prepare.outputs.sandbox_concurrency }}"
- name: Upload raw results
if: always()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: raw-results
path: results/downloaded/
overwrite: true
if-no-files-found: warn
retention-days: 3
publish-results:
needs: [prepare, run-evals]
# Publish completed runs even when the eval job fails partway through.
if: "always() && needs.run-evals.result != 'skipped' && needs.prepare.outputs.pairs != '[]'"
runs-on: ubuntu-26.04
steps:
- name: Checkout
uses: actions/checkout@9f698171ed81b15d1823a05fc7211befd50c8ae0 # v6.0.3
with:
ref: ${{ github.event_name == 'pull_request' && github.head_ref || github.ref }}
- name: Install pnpm
uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v5.0.0
- name: Setup Node.js
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version-file: .node-version
cache: pnpm
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Download raw results
# If every pair failed, run-evals never uploads a raw-results artifact
# at all, so this action errors. Audit pair results below already
# handles a missing/empty results/downloaded correctly (every pair
# reports missing), so don't let a total failure hide behind this.
continue-on-error: true
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: raw-results
path: results/downloaded
- name: Extract raw workspaces
# Workspaces arrive tarred so upload-artifact never sees agent-written filenames.
shell: bash
run: |
set -euo pipefail
if [ -d results/downloaded ]; then
find results/downloaded -name 'workspace.tgz' -print0 | while IFS= read -r -d '' archive; do
workspace="$(dirname "$archive")/workspace"
mkdir -p "$workspace"
tar -xzf "$archive" -C "$workspace"
rm "$archive"
done
fi
- name: Audit pair results
id: audit
shell: bash
run: |
set -euo pipefail
pairs='${{ needs.prepare.outputs.pairs }}'
total="$(jq 'length' <<< "$pairs")"
# A pair needs every requested run, not just a directory, since a
# partial pair would otherwise skew the average against its neighbours.
expected="${{ needs.prepare.outputs.runs }}"
required="$(jq -cn --argjson expected "$expected" '[range(1; $expected + 1)]')"
missing=()
while IFS= read -r key; do
dir="results/downloaded/raw-results-$key"
actual='[]'
if [ -d "$dir" ]; then
actual="$(find "$dir" -mindepth 3 -maxdepth 3 -path '*/run-*/result.json' -print \
| jq -Rsc '[splits("\n") | select(length > 0) | capture("/run-(?<run>[0-9]+)/result.json$").run | tonumber] | sort')"
fi
found="$(jq 'length' <<< "$actual")"
[ "$actual" = "$required" ] || missing+=("$key ($found/$expected runs)")
done < <(jq -r '.[] | "\(.eval_suite)__\(.experiment)__\(.eval_id)"' <<< "$pairs")
echo "count=${#missing[@]}" >> "$GITHUB_OUTPUT"
if [ "${#missing[@]}" -eq "$total" ]; then
echo "::warning::No results published: all $total eval pairs are missing runs (run-evals likely hit its timeout or failed partway). This run needs a follow-up to complete the refresh."
{
echo "## :warning: No results published"
echo ""
echo "All $total eval pairs never finished, likely because \`run-evals\` hit its timeout or failed partway through:"
echo ""
echo '```'
printf '%s\n' "${missing[@]}"
echo '```'
} >> "$GITHUB_STEP_SUMMARY"
elif [ "${#missing[@]}" -gt 0 ]; then
echo "::warning::Publishing PARTIAL results: ${#missing[@]} of $total eval pairs are missing runs (run-evals likely hit its timeout or failed partway). This run needs a follow-up to complete the refresh."
{
echo "## :warning: Partial results published"
echo ""
echo "${#missing[@]} of $total eval pairs are missing runs, likely because \`run-evals\` hit its timeout or failed partway through. These pairs are missing runs:"
echo ""
echo '```'
printf '%s\n' "${missing[@]}"
echo '```'
echo ""
echo "Re-run this workflow to fill in the missing pairs."
} >> "$GITHUB_STEP_SUMMARY"
fi
- name: Collect results
shell: bash
run: |
set -euo pipefail
mkdir -p results
pairs='${{ needs.prepare.outputs.pairs }}'
while IFS= read -r ref; do
folder="${ref%%/*}"
experiment="${ref#*/}"
mkdir -p "results/$folder/$experiment"
for artifact_dir in "results/downloaded/raw-results-${folder}__${experiment}__"*/; do
[ -d "$artifact_dir" ] && cp -R "$artifact_dir"/. "results/$folder/$experiment"/
done
done < <(jq -r '.[] | "\(.eval_suite)/\(.experiment)"' <<< "$pairs" | sort -u)
- name: Find the PRs for this branch
if: github.event_name == 'workflow_dispatch'
continue-on-error: true
env:
GH_TOKEN: ${{ github.token }}
run: |
urls=$(gh pr list --head "$GITHUB_REF_NAME" --state open --json url,isCrossRepository --jq '.[] | select(.isCrossRepository == false) | .url' | paste -sd ' ' -)
echo "PR_URLS=$urls" >> "$GITHUB_ENV"
- name: Upload results to Braintrust
env:
BRAINTRUST_API_KEY: ${{ secrets.BRAINTRUST_API_KEY }}
BRAINTRUST_PROJECT_ID: ${{ secrets.BRAINTRUST_PROJECT_ID }}
run: |
if [ -z "$BRAINTRUST_API_KEY" ] || [ -z "$BRAINTRUST_PROJECT_ID" ]; then
echo "::error::Braintrust credentials are required to upload results."
exit 1
fi
pnpm upload-braintrust --runs "${{ needs.prepare.outputs.runs }}"
- name: Require complete results
# Runs last so partial results still publish, but the job still fails.
if: >-
always() &&
steps.audit.outcome == 'success' &&
steps.audit.outputs.count != '0'
run: |
echo "::error::${{ steps.audit.outputs.count }} eval pair(s) are missing runs. This run needs a follow-up to complete the refresh."
exit 1