@@ -254,6 +254,9 @@ jobs:
254
254
if : ${{ !github.event.pull_request.head.repo.fork && steps.cts-e2e.outcome == 'failure' }}
255
255
run : yarn cli cts run javascript ${{ fromJSON(needs.setup.outputs.JAVASCRIPT_DATA).toRun }} --no-client --no-requests
256
256
257
+ - name : Run benchmarks
258
+ run : yarn cli cts run javascript ${{ fromJSON(needs.setup.outputs.JAVASCRIPT_DATA).toRun }} --benchmark --no-client --no-requests --no-e2e
259
+
257
260
- name : Generate code snippets for documentation
258
261
run : yarn cli snippets javascript ${{ fromJSON(needs.setup.outputs.JAVASCRIPT_DATA).toRun }}
259
262
@@ -348,6 +351,9 @@ jobs:
348
351
if : ${{ !github.event.pull_request.head.repo.fork && steps.cts-e2e.outcome == 'failure' }}
349
352
run : yarn cli cts run ${{ matrix.client.language }} ${{ matrix.client.toRun }} --no-client --no-requests
350
353
354
+ - name : Run benchmarks
355
+ run : yarn cli cts run ${{ matrix.client.language }} ${{ matrix.client.toRun }} --benchmark --no-client --no-requests --no-e2e
356
+
351
357
- name : Generate code snippets for documentation
352
358
run : yarn cli snippets ${{ matrix.client.language }} ${{ matrix.client.toRun }}
353
359
@@ -474,6 +480,26 @@ jobs:
474
480
- name : Generate documentation specs with code snippets
475
481
run : yarn cli build specs ${{ fromJSON(needs.setup.outputs.SPECS_MATRIX).toRun }} --docs
476
482
483
+ - name : Read benchmark results
484
+ id : benchmark
485
+ run : |
486
+ # merge all benchmark results into a single json, and remove the files
487
+ results=$(jq -s 'add' -c tests/output/**/benchmarkResult.json)
488
+ {
489
+ echo 'BENCHMARK_SECTION<<EOF'
490
+ echo "<details>"
491
+ echo "<summary>📊 Benchmark results</summary>"
492
+ echo "" # empty line is required to make the table work
493
+ echo "Benchmarks performed on the `search` method using a mock server, the results might not reflect the real-world performance."
494
+ # format the json to a markdown table with column "Language" and "rate"
495
+ echo "| Language | Rate |"
496
+ echo "| :------- | ---: |"
497
+ echo "$results" | jq -r 'to_entries | map([.key, .value.rate]) | sort_by(.[1]) | reverse | .[] | @tsv' | awk -F'\t' '{printf "| %-10s | %10d |\n", $1, $2}'
498
+ echo "</details>"
499
+ echo 'EOF'
500
+ } >> "$GITHUB_OUTPUT"
501
+ rm -rf tests/output/**/benchmarkResult.json
502
+
477
503
- name : Push generated code
478
504
id : pushGeneratedCode
479
505
run : yarn workspace scripts pushGeneratedCode
@@ -491,6 +517,8 @@ jobs:
491
517
492
518
_If you believe code should've been generated, please, [report the issue](https://github.com/algolia/api-clients-automation/issues/new?assignees=&labels=bug%2Ctriage&projects=&template=Bug_report.yml&title=%5Bbug%5D%3A+)._
493
519
520
+ ${{ steps.benchmark.outputs.BENCHMARK_SECTION }}
521
+
494
522
- name : update generation comment
495
523
uses : marocchino/sticky-pull-request-comment@v2
496
524
if : ${{ steps.pushGeneratedCode.outputs.GENERATED_COMMIT != '' }}
@@ -505,6 +533,8 @@ jobs:
505
533
| 🍃 Generated commit | [`${{ steps.pushGeneratedCode.outputs.GENERATED_COMMIT }}`](${{ github.event.pull_request.base.repo.html_url }}/commit/${{ steps.pushGeneratedCode.outputs.GENERATED_COMMIT }}) |
506
534
| 🌲 Generated branch | [`generated/${{ github.head_ref }}`](${{ github.event.pull_request.base.repo.html_url }}/tree/generated/${{ github.head_ref }}) |
507
535
536
+ ${{ steps.benchmark.outputs.BENCHMARK_SECTION }}
537
+
508
538
- name : Build website
509
539
if : ${{ github.ref == 'refs/heads/main' || github.base_ref == 'main' }}
510
540
run : yarn website:build
0 commit comments