-
Notifications
You must be signed in to change notification settings - Fork 9
452 lines (441 loc) · 18.9 KB
/
Copy pathbenchmarks.yml
File metadata and controls
452 lines (441 loc) · 18.9 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
name: Benchmarks
on:
push:
branches: [main]
pull_request:
branches: [main]
types: [opened, synchronize, reopened, labeled, unlabeled]
merge_group:
types: [checks_requested]
schedule:
- cron: "41 4 * * 3"
workflow_dispatch:
concurrency:
group: benchmarks-${{ github.workflow }}-${{ github.ref }}
# A newer PR commit supersedes stale evidence; Benchmark Validation still
# runs after dependency cancellation and rejects missing evidence.
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
permissions:
actions: read
contents: read
jobs:
plan:
name: Plan Benchmarks
runs-on: ubuntu-latest
timeout-minutes: 8
outputs:
run-benchmark-check: ${{ steps.plan.outputs.run-benchmark-check }}
run-benchmark-record-schema: ${{ steps.plan.outputs.run-benchmark-record-schema }}
run-benchmark-inventory: ${{ steps.plan.outputs.run-benchmark-inventory }}
run-benchmark-host-validation: ${{ steps.plan.outputs.run-benchmark-host-validation }}
benchmark-host-validation-matrix: ${{ steps.plan.outputs.benchmark-host-validation-matrix }}
run-benchmark-oracle: ${{ steps.plan.outputs.run-benchmark-oracle }}
benchmark-oracle-matrix: ${{ steps.plan.outputs.benchmark-oracle-matrix }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
persist-credentials: false
- uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
with:
python-version: "3.12"
- uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1
with:
version: "0.11.28"
- name: Restore benchmark timing history
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: .benchmark-timings.json
key: benchmark-timings-unmatched
restore-keys: benchmark-timings-
- id: plan
name: Classify benchmark changes
env:
EVENT_NAME: ${{ github.event_name }}
BASE_SHA: >-
${{ github.event.pull_request.base.sha ||
github.event.merge_group.base_sha ||
github.event.before }}
HEAD_SHA: >-
${{ github.event.pull_request.head.sha ||
github.event.merge_group.head_sha ||
github.sha }}
FORCE_FULL: ${{ contains(github.event.pull_request.labels.*.name, 'ci:benchmark-full') }}
run: |
set -eu
planner_args=(--event "$EVENT_NAME" --head "$HEAD_SHA")
changed_paths=()
case "$EVENT_NAME" in
schedule|workflow_dispatch)
planner_args=(--event "$EVENT_NAME" --force-full --head "$HEAD_SHA")
;;
pull_request|merge_group|push)
if [ "$FORCE_FULL" = "true" ] || [ -z "$BASE_SHA" ] || [[ "$BASE_SHA" =~ ^0+$ ]]; then
planner_args=(--event "$EVENT_NAME" --force-full --head "$HEAD_SHA")
else
planner_args=(--event "$EVENT_NAME" --base "$BASE_SHA" --head "$HEAD_SHA")
mapfile -d '' changed_paths < <(
git diff --name-only -z "$BASE_SHA" "$HEAD_SHA"
)
fi
;;
*) exit 2 ;;
esac
if [ -f .benchmark-timings.json ]; then
planner_args+=(--timings-file .benchmark-timings.json)
fi
plan_dir="$RUNNER_TEMP/jacobian-benchmark-plan"
mkdir -p "$plan_dir"
uvx --from harbor==0.20.0 --with tomli-w==1.2.0 \
python .github/scripts/plan-benchmarks \
"${planner_args[@]}" --output "$plan_dir/plan.json" \
--github-output "$GITHUB_OUTPUT" -- "${changed_paths[@]}"
printf '%s\n' "${changed_paths[@]}" > "$plan_dir/changed-paths.txt"
{
echo "## Benchmark plan"
echo
echo '```json'
cat "$plan_dir/plan.json"
echo '```'
} >> "$GITHUB_STEP_SUMMARY"
- name: Upload benchmark plan
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: benchmark-plan
path: ${{ runner.temp }}/jacobian-benchmark-plan/plan.json
retention-days: 14
- name: Prepare benchmark pytest timing hint
if: steps.plan.outputs.run-benchmark-host-validation == 'true'
env:
GH_TOKEN: ${{ github.token }}
run: |
.github/scripts/manage-test-timings prepare \
--suite benchmark \
--output .ci/benchmark-test-durations.json
- name: Upload benchmark pytest timing hint
if: steps.plan.outputs.run-benchmark-host-validation == 'true'
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: benchmark-test-durations-input
path: .ci/benchmark-test-durations.json
include-hidden-files: true
retention-days: 1
static:
name: Benchmark Static Quality
needs: plan
if: needs.plan.outputs.run-benchmark-check == 'true'
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
with:
python-version: "3.12"
- uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1
with:
version: "0.11.28"
- name: Check benchmark Python, verifier, and validation code
run: uv run --locked python tools/check_benchmark_static.py
contracts:
name: Benchmark Contracts, Adapters, Records & Digests
needs: plan
if: needs.plan.outputs.run-benchmark-record-schema == 'true'
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
with:
python-version: "3.12"
- uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1
with:
version: "0.11.28"
- name: Validate benchmark contracts, adapters, schemas, records, and digests
run: make harbor-contracts harbor-adapter-checks
host_validation:
name: Host Verifiers (${{ matrix.name }})
needs: plan
if: needs.plan.outputs.run-benchmark-host-validation == 'true'
runs-on: ubuntu-latest
timeout-minutes: 15
strategy:
fail-fast: false
max-parallel: 4
matrix:
include: ${{ fromJSON(needs.plan.outputs.benchmark-host-validation-matrix) }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
with:
python-version: "3.12"
- uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1
with:
version: "0.11.28"
- name: Download benchmark timing hint
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: benchmark-test-durations-input
path: .ci
- name: Download benchmark plan
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: benchmark-plan
path: ${{ runner.temp }}/benchmark-plan
- name: Run selected host-side verifier regressions
env:
HOST_ENTRY: ${{ toJSON(matrix) }}
run: |
uv run --locked python -m benchmarks.tooling.host_validation run-entry \
--entry-json "$HOST_ENTRY" \
--plan "${{ runner.temp }}/benchmark-plan/plan.json" \
--execution-sha "${{ github.sha }}" \
--timings .ci/benchmark-test-durations.json \
--durations-output "${{ runner.temp }}/benchmark-host-timing/durations/benchmark-test-durations.json" \
--receipt-dir "${{ runner.temp }}/benchmark-host-timing" \
--total-workers 8 --max-parallel 4 --store-durations
- name: Upload host timing receipt
if: always()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: benchmark-host-timing-${{ matrix.name }}
path: ${{ runner.temp }}/benchmark-host-timing/**/pytest-receipt.json
if-no-files-found: error
retention-days: 90
- name: Upload benchmark shard durations
if: matrix.splits > 0 && !cancelled()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
continue-on-error: true
with:
name: benchmark-duration-shard-${{ matrix.group }}
path: ${{ runner.temp }}/benchmark-host-timing/durations/benchmark-test-durations.json
include-hidden-files: true
retention-days: 1
inventory:
name: Benchmark Inventory Validation
needs: plan
if: needs.plan.outputs.run-benchmark-inventory == 'true'
runs-on: ubuntu-latest
timeout-minutes: 25
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
with:
python-version: "3.12"
- uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1
with:
version: "0.11.28"
- name: Build and validate the content-bound benchmark inventory
run: make benchmark-inventory
oracle:
name: Benchmark Oracle (${{ matrix.dataset }}/${{ matrix.shard }})
needs: [plan, static, contracts]
if: >-
${{ always() &&
needs.plan.result == 'success' &&
needs.static.result == 'success' &&
needs.plan.outputs.run-benchmark-oracle == 'true' &&
needs.contracts.result == 'success' }}
runs-on: ubuntu-latest
timeout-minutes: 30
strategy:
fail-fast: false
max-parallel: 4
matrix:
include: ${{ fromJSON(needs.plan.outputs.benchmark-oracle-matrix) }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
with:
python-version: "3.12"
- uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1
with:
version: "0.11.28"
- name: Run exact task Oracle
env:
DATASET: ${{ matrix.dataset }}
TASKS: ${{ join(matrix.tasks, ' ') }}
run: make harbor-oracle-task DATASET="$DATASET" TASKS="$TASKS"
- name: Upload Oracle evidence
if: always()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: benchmark-oracle-${{ matrix.dataset }}-${{ matrix.shard }}
path: |
benchmarks/results/${{ matrix.dataset }}-oracle
benchmarks/results/${{ matrix.dataset }}-oracle/jacobian-augmented-task-digests.*.json
benchmarks/results/${{ matrix.dataset }}-oracle/**/oracle-evidence.json
if-no-files-found: ignore
retention-days: ${{ github.event_name == 'pull_request' && 14 || 90 }}
validation:
name: Benchmark Validation
# This required aggregate must run after cancellation so the validator can
# turn cancelled dependencies into a failing check instead of a skipped,
# branch-protection-passing job.
if: ${{ always() }}
needs: [plan, static, contracts, host_validation, inventory, oracle]
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
with:
python-version: "3.12"
- name: Download benchmark plan
if: needs.plan.result == 'success'
continue-on-error: true
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: benchmark-plan
path: ${{ runner.temp }}/benchmark-validation/plan
- name: Download host shard receipts
if: needs.plan.outputs.run-benchmark-host-validation == 'true'
continue-on-error: true
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
pattern: benchmark-host-timing-*
path: ${{ runner.temp }}/benchmark-validation/host
- name: Download host timing input
if: needs.plan.outputs.run-benchmark-host-validation == 'true'
continue-on-error: true
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: benchmark-test-durations-input
path: ${{ runner.temp }}/benchmark-validation/timing
- name: Require planned benchmark validation
env:
PLAN_RESULT: ${{ needs.plan.result }}
PLAN_CHECK: ${{ needs.plan.outputs.run-benchmark-check }}
RECORD_SCHEMA_FLAG: ${{ needs.plan.outputs.run-benchmark-record-schema }}
INVENTORY_FLAG: ${{ needs.plan.outputs.run-benchmark-inventory }}
HOST_VALIDATION_FLAG: ${{ needs.plan.outputs.run-benchmark-host-validation }}
ORACLE_FLAG: ${{ needs.plan.outputs.run-benchmark-oracle }}
STATIC_RESULT: ${{ needs.static.result }}
CONTRACTS_RESULT: ${{ needs.contracts.result }}
HOST_VALIDATION_RESULT: ${{ needs.host_validation.result }}
INVENTORY_RESULT: ${{ needs.inventory.result }}
ORACLE_RESULT: ${{ needs.oracle.result }}
run: |
python -m benchmarks.tooling.benchmark_validation \
--plan-result "$PLAN_RESULT" \
--plan "${{ runner.temp }}/benchmark-validation/plan/plan.json" \
--execution-sha "${{ github.sha }}" \
--receipt-root "${{ runner.temp }}/benchmark-validation/host" \
--timings "${{ runner.temp }}/benchmark-validation/timing/benchmark-test-durations.json" \
--lane "static:${PLAN_CHECK:-false}:${STATIC_RESULT:-cancelled}" \
--lane "contracts:${RECORD_SCHEMA_FLAG:-false}:${CONTRACTS_RESULT:-cancelled}" \
--lane "host-validation:${HOST_VALIDATION_FLAG:-false}:${HOST_VALIDATION_RESULT:-cancelled}" \
--lane "inventory:${INVENTORY_FLAG:-false}:${INVENTORY_RESULT:-cancelled}" \
--lane "oracle:${ORACLE_FLAG:-false}:${ORACLE_RESULT:-cancelled}"
timings:
name: Publish Benchmark Timings
needs: [plan, host_validation, oracle, validation]
if: >-
${{ always() &&
needs.plan.outputs.run-benchmark-host-validation == 'true' &&
needs.host_validation.result == 'success' &&
needs.validation.result == 'success' &&
(needs.plan.outputs.run-benchmark-oracle != 'true' ||
needs.oracle.result == 'success') }}
runs-on: ubuntu-latest
timeout-minutes: 8
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
with:
python-version: "3.12"
- uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1
with:
version: "0.11.28"
- name: Restore previous timing history
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: .benchmark-timings.json
key: benchmark-timings-unmatched
restore-keys: benchmark-timings-
- name: Download host timing receipts
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
pattern: benchmark-host-timing-*
path: timing-artifacts
- name: Download benchmark shard durations
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
continue-on-error: true
with:
pattern: benchmark-duration-shard-*
path: .ci/shards
- name: Download Oracle artifacts
if: needs.plan.outputs.run-benchmark-oracle == 'true'
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
pattern: benchmark-oracle-*
path: timing-artifacts
- name: Collect and compare shard timings
env:
ORACLE_MATRIX: ${{ needs.plan.outputs.benchmark-oracle-matrix }}
HOST_MATRIX: ${{ needs.plan.outputs.benchmark-host-validation-matrix }}
run: |
uv run --locked python -m benchmarks.tooling.benchmark_timings \
--root timing-artifacts \
--output .benchmark-timings.json \
--previous .benchmark-timings.json \
--oracle-matrix-json "$ORACLE_MATRIX" \
--host-matrix-json "$HOST_MATRIX" \
--report-output benchmark-timing-report.json \
--summary-output "$GITHUB_STEP_SUMMARY"
- id: benchmark-durations
name: Merge complete full-suite pytest timings
run: |
set -eu
inputs=()
for shard in 1 2 3 4; do
path=".ci/shards/benchmark-duration-shard-${shard}/benchmark-test-durations.json"
if [ ! -f "$path" ]; then
echo "complete=false" >> "$GITHUB_OUTPUT"
exit 0
fi
inputs+=(--input "$path")
done
.github/scripts/manage-test-timings merge \
--suite benchmark \
"${inputs[@]}" \
--output .ci/benchmark-test-durations.json \
--source-sha "${{ github.sha }}" \
--python-version "3.12"
echo "complete=true" >> "$GITHUB_OUTPUT"
- name: Upload timing evidence
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: benchmark-timings-${{ github.sha }}
path: |
.benchmark-timings.json
benchmark-timing-report.json
if-no-files-found: error
retention-days: 90
- name: Publish benchmark pytest timing hint
if: steps.benchmark-durations.outputs.complete == 'true'
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: benchmark-test-durations
path: .ci/benchmark-test-durations.json
include-hidden-files: true
retention-days: 90
- name: Save timing history for future main-branch plans
if: github.ref == 'refs/heads/main'
uses: actions/cache/save@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
with:
path: .benchmark-timings.json
key: benchmark-timings-${{ github.run_id }}