Skip to content

Commit ccc51d5

Browse files
committed
ci: Ensure benchmark required check always reports status
1 parent fb4f9c8 commit ccc51d5

File tree

1 file changed

+48
-13
lines changed

1 file changed

+48
-13
lines changed

.github/workflows/benchmark.yml

Lines changed: 48 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -215,46 +215,72 @@ jobs:
215215
needs: changes
216216
if: >
217217
github.event_name == 'workflow_dispatch' ||
218-
(github.event_name == 'push' && github.ref == 'refs/heads/main') ||
219-
needs.changes.outputs.perf-pr == 'true' ||
220-
needs.changes.outputs.e2e-scripts == 'true' ||
221-
contains(github.event.pull_request.labels.*.name, 'performance')
218+
github.event_name == 'pull_request' ||
219+
(github.event_name == 'push' && github.ref == 'refs/heads/main')
222220
223221
steps:
224222
- name: Checkout repository
225223
uses: actions/checkout@v4
226224
with:
227225
fetch-depth: 0
228226

227+
- name: Decide whether to run benchmarks
228+
id: should-run
229+
run: |
230+
if [[ "${{ github.event_name }}" == "push" && "${{ github.ref }}" == "refs/heads/main" ]]; then
231+
echo "run=true" >> "$GITHUB_OUTPUT"
232+
elif [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
233+
if [[ "${{ inputs.run_e2e_benchmark }}" == "true" ]]; then
234+
echo "run=true" >> "$GITHUB_OUTPUT"
235+
else
236+
echo "run=false" >> "$GITHUB_OUTPUT"
237+
fi
238+
elif [[ "${{ needs.changes.outputs.perf-pr }}" == "true" || "${{ needs.changes.outputs.e2e-scripts }}" == "true" || "${{ contains(github.event.pull_request.labels.*.name, 'performance') }}" == "true" ]]; then
239+
echo "run=true" >> "$GITHUB_OUTPUT"
240+
else
241+
echo "run=false" >> "$GITHUB_OUTPUT"
242+
fi
243+
244+
- name: Skip benchmark execution
245+
if: steps.should-run.outputs.run != 'true'
246+
run: |
247+
echo "No benchmark run needed for this PR; required check passes."
248+
229249
- name: Clone js-framework-benchmark
250+
if: steps.should-run.outputs.run == 'true'
230251
run: |
231252
# Remove uninitialized submodule placeholder directory
232253
rm -rf js-framework-benchmark
233254
# Clone upstream benchmark infrastructure (shallow for speed)
234255
git clone --depth 1 https://github.com/krausest/js-framework-benchmark.git js-framework-benchmark
235256
236257
- name: Setup .NET
258+
if: steps.should-run.outputs.run == 'true'
237259
uses: actions/setup-dotnet@v4
238260
with:
239261
dotnet-version: '10.0.x'
240262

241263
- name: Install WASM workloads
264+
if: steps.should-run.outputs.run == 'true'
242265
run: dotnet workload install wasm-experimental wasm-tools
243266

244267
- name: Setup Node.js
268+
if: steps.should-run.outputs.run == 'true'
245269
uses: actions/setup-node@v4
246270
with:
247271
node-version: '22'
248272

249273
# Build the benchmark WASM app from the repo's own project
250274
- name: Build Abies benchmark WASM app
275+
if: steps.should-run.outputs.run == 'true'
251276
run: |
252277
dotnet publish Picea.Abies.Benchmark.Wasm/Picea.Abies.Benchmark.Wasm.csproj -c Release
253278
254279
# Set up the framework entry in the js-framework-benchmark directory.
255280
# The upstream server's isFrameworkDir() requires BOTH package.json AND
256281
# package-lock.json to exist for framework discovery via the /ls endpoint.
257282
- name: Setup Abies framework in benchmark
283+
if: steps.should-run.outputs.run == 'true'
258284
run: |
259285
# Ensure framework directory structure exists
260286
mkdir -p js-framework-benchmark/frameworks/keyed/abies/bundled-dist/wwwroot
@@ -311,6 +337,7 @@ jobs:
311337
312338
# Cache npm dependencies
313339
- name: Cache npm dependencies
340+
if: steps.should-run.outputs.run == 'true'
314341
uses: actions/cache@v4
315342
with:
316343
path: ~/.npm
@@ -320,6 +347,7 @@ jobs:
320347
321348
# Cache Chrome browser for Selenium
322349
- name: Cache Chrome for Testing
350+
if: steps.should-run.outputs.run == 'true'
323351
uses: actions/cache@v4
324352
with:
325353
path: ~/.cache/selenium
@@ -328,6 +356,7 @@ jobs:
328356
selenium-chrome-${{ runner.os }}-
329357
330358
- name: Install benchmark dependencies
359+
if: steps.should-run.outputs.run == 'true'
331360
run: |
332361
cd js-framework-benchmark
333362
npm ci
@@ -337,6 +366,7 @@ jobs:
337366
npm run compile
338367
339368
- name: Start benchmark server
369+
if: steps.should-run.outputs.run == 'true'
340370
run: |
341371
cd js-framework-benchmark
342372
npm start &
@@ -359,6 +389,7 @@ jobs:
359389
# package.json causes zero frameworks to match silently (exit 0,
360390
# no results, compare script fails).
361391
- name: Verify framework discovery
392+
if: steps.should-run.outputs.run == 'true'
362393
run: |
363394
echo "=== Checking /ls endpoint for framework discovery ==="
364395
LS_RESPONSE=$(curl -s http://localhost:8080/ls)
@@ -376,6 +407,7 @@ jobs:
376407
fi
377408
378409
- name: Run E2E benchmarks (all CPU benchmarks)
410+
if: steps.should-run.outputs.run == 'true'
379411
run: |
380412
cd js-framework-benchmark/webdriver-ts
381413
npm run bench -- --headless --framework keyed/abies --benchmark 01_run1k
@@ -389,14 +421,15 @@ jobs:
389421
npm run bench -- --headless --framework keyed/abies --benchmark 09_clear1k
390422
391423
- name: Run Memory benchmarks
424+
if: steps.should-run.outputs.run == 'true'
392425
run: |
393426
cd js-framework-benchmark/webdriver-ts
394427
npm run bench -- --headless --framework keyed/abies --benchmark 21_ready-memory
395428
npm run bench -- --headless --framework keyed/abies --benchmark 22_run-memory
396429
npm run bench -- --headless --framework keyed/abies --benchmark 25_clear-memory
397430
398431
- name: Fetch baseline from gh-pages (if not in repo)
399-
if: ${{ !hashFiles('benchmark-results/baseline.json') }}
432+
if: steps.should-run.outputs.run == 'true' && ${{ !hashFiles('benchmark-results/baseline.json') }}
400433
continue-on-error: true
401434
run: |
402435
# Try to fetch baseline from gh-pages branch
@@ -408,6 +441,7 @@ jobs:
408441
fi
409442
410443
- name: Compare against baseline
444+
if: steps.should-run.outputs.run == 'true'
411445
id: regression-check
412446
continue-on-error: true
413447
run: |
@@ -418,7 +452,7 @@ jobs:
418452
--framework abies
419453
420454
- name: Report benchmark status
421-
if: always()
455+
if: always() && steps.should-run.outputs.run == 'true'
422456
run: |
423457
if [[ "${{ steps.regression-check.outcome }}" == "failure" ]]; then
424458
echo "❌ Performance regression detected (>5%)"
@@ -428,6 +462,7 @@ jobs:
428462
fi
429463
430464
- name: Convert E2E results to benchmark format
465+
if: steps.should-run.outputs.run == 'true'
431466
run: |
432467
python3 scripts/convert-e2e-results.py \
433468
--results-dir js-framework-benchmark/webdriver-ts/results \
@@ -437,7 +472,7 @@ jobs:
437472
438473
- name: Check if gh-pages exists
439474
id: gh-pages-check
440-
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
475+
if: steps.should-run.outputs.run == 'true' && github.event_name == 'push' && github.ref == 'refs/heads/main'
441476
run: |
442477
if git ls-remote --exit-code --heads origin gh-pages > /dev/null 2>&1; then
443478
echo "exists=true" >> $GITHUB_OUTPUT
@@ -447,7 +482,7 @@ jobs:
447482
448483
- name: Store E2E benchmark trends to gh-pages (main only)
449484
uses: benchmark-action/github-action-benchmark@v1
450-
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && steps.gh-pages-check.outputs.exists == 'true'
485+
if: steps.should-run.outputs.run == 'true' && github.event_name == 'push' && github.ref == 'refs/heads/main' && steps.gh-pages-check.outputs.exists == 'true'
451486
with:
452487
name: "1. E2E Benchmark (js-framework-benchmark)"
453488
tool: customSmallerIsBetter
@@ -463,7 +498,7 @@ jobs:
463498

464499
- name: Store E2E memory benchmark trends to gh-pages (main only)
465500
uses: benchmark-action/github-action-benchmark@v1
466-
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && steps.gh-pages-check.outputs.exists == 'true'
501+
if: steps.should-run.outputs.run == 'true' && github.event_name == 'push' && github.ref == 'refs/heads/main' && steps.gh-pages-check.outputs.exists == 'true'
467502
with:
468503
name: "1. E2E Benchmark: Memory (js-framework-benchmark)"
469504
tool: customSmallerIsBetter
@@ -486,7 +521,7 @@ jobs:
486521
# on:push workflows (CD, E2E, etc.).
487522
# ============================================================================
488523
- name: Update README benchmark tables (main only)
489-
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
524+
if: steps.should-run.outputs.run == 'true' && github.event_name == 'push' && github.ref == 'refs/heads/main'
490525
run: |
491526
python3 scripts/update-readme-benchmarks.py \
492527
--results-dir js-framework-benchmark/webdriver-ts/results \
@@ -495,7 +530,7 @@ jobs:
495530
--framework abies
496531
497532
- name: Create PR for README benchmark updates (main only)
498-
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
533+
if: steps.should-run.outputs.run == 'true' && github.event_name == 'push' && github.ref == 'refs/heads/main'
499534
uses: peter-evans/create-pull-request@v6
500535
with:
501536
token: ${{ secrets.GITHUB_TOKEN }}
@@ -511,7 +546,7 @@ jobs:
511546
README.md
512547
513548
- name: Copy results to workspace for upload
514-
if: always()
549+
if: always() && steps.should-run.outputs.run == 'true'
515550
run: |
516551
mkdir -p ./e2e-results
517552
cp -r js-framework-benchmark/webdriver-ts/results/* ./e2e-results/ 2>/dev/null || true
@@ -520,7 +555,7 @@ jobs:
520555
521556
- name: Upload E2E benchmark results
522557
uses: actions/upload-artifact@v6
523-
if: always()
558+
if: always() && steps.should-run.outputs.run == 'true'
524559
with:
525560
name: e2e-benchmark-results
526561
path: ./e2e-results/

0 commit comments

Comments
 (0)