-
Notifications
You must be signed in to change notification settings - Fork 8
303 lines (260 loc) · 9.68 KB
/
benchmark-reusable.yml
File metadata and controls
303 lines (260 loc) · 9.68 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
name: Reusable Benchmark Workflow
on:
workflow_call:
inputs:
matrix:
description: 'JSON matrix with agent/model/eval combinations'
required: true
type: string
package_urls:
description: 'Package URLs from publish step'
required: true
type: string
permissions:
contents: read
actions: read
jobs:
prepare-analysis:
name: Prepare Judge Analysis Matrix
runs-on: blacksmith-4vcpu-ubuntu-2404
outputs:
evals: ${{ steps.compute.outputs.evals }}
steps:
- name: Extract unique evaluations
id: compute
env:
MATRIX_JSON: ${{ inputs.matrix }}
run: |
set -euo pipefail
evals=$(jq -c '.include | unique_by(.eval) | map({ eval: .eval, safe: (.eval | gsub("/"; "-")) })' <<<"$MATRIX_JSON")
if [ -z "${evals}" ] || [ "${evals}" = "null" ]; then
echo "No evaluations found in matrix definition." >&2
evals="[]"
fi
echo "Analysis eval matrix: ${evals}"
echo "evals=${evals}" >> "$GITHUB_OUTPUT"
benchmark:
name: Benchmark ${{ matrix.agent }} / ${{ matrix.model }} / ${{ matrix.eval }}
runs-on: blacksmith-4vcpu-ubuntu-2404
permissions:
contents: read
actions: read
environment: production
strategy:
fail-fast: false
matrix: ${{ fromJSON(inputs.matrix) }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Bun
uses: oven-sh/setup-bun@v1
with:
bun-version: 1.2.21
- name: Install dependencies
run: bun install --frozen-lockfile
- name: Install OpenCode CLI
run: bun add -g opencode-ai@dev @openai/codex-sdk
- name: Determine benchmark job URL
id: job_url
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BENCHMARK_AGENT: ${{ matrix.agent }}
BENCHMARK_MODEL: ${{ matrix.model }}
BENCHMARK_EVAL: ${{ matrix.eval }}
run: |
set -euo pipefail
job_pattern="Benchmark ${BENCHMARK_AGENT} / ${BENCHMARK_MODEL} / ${BENCHMARK_EVAL}"
job_url="$(bun run scripts/determine-job-url.ts --pattern "${job_pattern}")"
echo "Job URL: ${job_url}"
echo "GITHUB_BENCHMARK_JOB_URL=${job_url}" >> "$GITHUB_ENV"
echo "url=${job_url}" >> "$GITHUB_OUTPUT"
- name: Run openreval benchmark
uses: nick-fields/retry@v2
env:
OPENCODE_API_KEY: ${{ secrets.OPENCODE_API_KEY }}
CODEX_API_KEY: ${{ secrets.CODEX_API_KEY }}
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_BENCHMARK_JOB_URL: ${{ steps.job_url.outputs.url }}
URLS: ${{ inputs.package_urls }}
BENCHMARK_EVAL: ${{ matrix.eval }}
BENCHMARK_MODEL: ${{ matrix.model }}
BENCHMARK_AGENT: ${{ matrix.agent }}
with:
max_attempts: 3
timeout_minutes: 90
retry_on: error
command: |
set -euo pipefail
PACKAGE_URL="$(printf '%s\n' "${URLS}" | awk 'NF {print $1; exit}')"
if [ -z "${BENCHMARK_EVAL}" ]; then
echo "Matrix entry missing evaluation identifier." >&2
exit 1
fi
if [ -z "${BENCHMARK_MODEL}" ]; then
echo "Matrix entry missing model identifier." >&2
exit 1
fi
if [ -z "${BENCHMARK_AGENT}" ]; then
echo "Matrix entry missing agent identifier." >&2
exit 1
fi
if [ -z "${PACKAGE_URL}" ]; then
echo "No package URL found in publish outputs." >&2
exit 1
fi
PACKAGE_SPEC="orvl@${PACKAGE_URL}"
OUTPUT_FILE="benchmark.json"
COMMAND="bunx \"${PACKAGE_SPEC}\" \"${BENCHMARK_AGENT}\" --eval \"${BENCHMARK_EVAL}\" --model \"${BENCHMARK_MODEL}\" --output \"${OUTPUT_FILE}\""
echo "Executing: ${COMMAND}"
bunx "${PACKAGE_SPEC}" "${BENCHMARK_AGENT}" --eval "${BENCHMARK_EVAL}" --model "${BENCHMARK_MODEL}" --output "${OUTPUT_FILE}"
- name: Log benchmark summary
if: always()
run: |
set -euo pipefail
if [ -f benchmark.json ]; then
echo "=== Benchmark Summary ==="
jq -r '.summary // "No summary available"' benchmark.json
echo "========================"
else
echo "benchmark.json not found, skipping summary log"
fi
- name: Prepare artifact name
id: artifact
env:
BENCHMARK_AGENT: ${{ matrix.agent }}
BENCHMARK_MODEL: ${{ matrix.model }}
BENCHMARK_EVAL: ${{ matrix.eval }}
run: |
set -euo pipefail
agent="${BENCHMARK_AGENT//\//-}"
model="${BENCHMARK_MODEL//\//-}"
eval="${BENCHMARK_EVAL//\//-}"
echo "name=benchmark-${agent}-${model}-${eval}" >> "$GITHUB_OUTPUT"
- name: Upload benchmark artifact
uses: actions/upload-artifact@v4
with:
name: ${{ steps.artifact.outputs.name }}
path: benchmark.json
eval-analysis:
name: Judge Analysis - ${{ matrix.eval }}
runs-on: blacksmith-4vcpu-ubuntu-2404
needs:
- benchmark
- prepare-analysis
if: needs.prepare-analysis.outputs.evals != '[]'
environment: production
strategy:
fail-fast: false
matrix:
include: ${{ fromJSON(needs.prepare-analysis.outputs.evals) }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Bun
uses: oven-sh/setup-bun@v1
with:
bun-version: 1.2.21
- name: Install dependencies
run: bun install --frozen-lockfile
- name: Download benchmark artifacts for eval
uses: actions/download-artifact@v4
with:
path: eval-benchmarks
pattern: benchmark-*-*-${{ matrix.safe }}
- name: Merge benchmark exports
id: merge
run: |
set -euo pipefail
if [ ! -d eval-benchmarks ] || ! find eval-benchmarks -type f -name '*.json' -print -quit | grep -q .; then
echo "No benchmark artifacts found for eval ${{ matrix.eval }}; skipping analysis."
echo "has_data=false" >> "$GITHUB_OUTPUT"
exit 0
fi
bun run scripts/merge-benchmark-exports.ts eval-benchmarks merged-benchmark.json
echo "Merged benchmark export ready for analysis."
echo "has_data=true" >> "$GITHUB_OUTPUT"
- name: Run judges analysis
if: steps.merge.outputs.has_data == 'true'
id: analysis
env:
OPENCODE_API_KEY: ${{ secrets.OPENCODE_API_KEY }}
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
CODEX_API_KEY: ${{ secrets.CODEX_API_KEY }}
run: |
set -euo pipefail
bun run scripts/analysis.ts merged-benchmark.json > analysis.txt
cat analysis.txt
- name: Determine analysis job URL
if: steps.merge.outputs.has_data == 'true'
id: analysis_url
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
MATRIX_EVAL: ${{ matrix.eval }}
MATRIX_SAFE: ${{ matrix.safe }}
run: |
set -euo pipefail
job_pattern="Judge Analysis - ${MATRIX_EVAL}"
job_url="$(bun run scripts/determine-job-url.ts --pattern "${job_pattern}")"
step_url="${job_url}#step:7:0"
jq -n \
--arg eval "${MATRIX_EVAL}" \
--arg safe "${MATRIX_SAFE}" \
--arg url "${step_url}" \
'{eval: $eval, safe: $safe, url: $url}' > analysis-info.json
- name: Upload analysis artifact
if: steps.merge.outputs.has_data == 'true'
uses: actions/upload-artifact@v4
with:
name: analysis-${{ matrix.safe }}
path: |
analysis.txt
analysis-info.json
notify:
runs-on: blacksmith-4vcpu-ubuntu-2404
needs:
- benchmark
- eval-analysis
if: needs.benchmark.result == 'success'
environment: production
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Bun
uses: oven-sh/setup-bun@v1
with:
bun-version: 1.2.21
- name: Install dependencies
run: bun install --frozen-lockfile
- name: Download benchmark artifacts
uses: actions/download-artifact@v4
with:
path: benchmarks
- name: Download analysis artifacts
uses: actions/download-artifact@v4
with:
path: analysis
pattern: analysis-*
- name: Merge benchmark exports
run: bun run scripts/merge-benchmark-exports.ts benchmarks merged-benchmark.json
- name: Build analysis link map
run: |
set -euo pipefail
mkdir -p analysis
mapfile -d '' info_files < <(find analysis -type f -name 'analysis-info.json' -print0 2>/dev/null || true)
if [ "${#info_files[@]}" -eq 0 ]; then
echo "[]" > analysis/analysis-links.json
else
jq -s 'map({eval: .eval, url: .url, safe: .safe})' "${info_files[@]}" > analysis/analysis-links.json
fi
- name: Send Discord notification
env:
DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }}
ANALYSIS_LINKS_FILE: ${{ github.workspace }}/analysis/analysis-links.json
run: |
set -euo pipefail
if [ ! -f merged-benchmark.json ]; then
echo "merged-benchmark.json not found; skipping Discord notification." >&2
exit 0
fi
bun run scripts/discord-sample.ts merged-benchmark.json