Skip to content

Commit 2131bef

Browse files
committed
Add option to run benchmarks on PRs
1 parent f3c8886 commit 2131bef

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

.github/workflows/benchmark.yml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ name: Benchmark Main
33
on:
44
push:
55
branches: [ main ]
6+
pull_request:
7+
types: [opened, synchronize, reopened, labeled]
68
workflow_dispatch:
79

810
permissions:
@@ -17,6 +19,7 @@ jobs:
1719
container:
1820
image: ubuntu:24.04@sha256:353675e2a41babd526e2b837d7ec780c2a05bca0164f7ea5dbbd433d21d166fc
1921
timeout-minutes: 20 # since there is only a single bare metal runner across all repos
22+
if: github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'run benchmarks')
2023
steps:
2124
- name: Install Git
2225
run: |
@@ -37,7 +40,8 @@ jobs:
3740

3841
- name: Set up gradle
3942
uses: gradle/actions/setup-gradle@ed408507eac070d1f99cc633dbcf757c94c7933a # v4.4.3
40-
- name: Run jmh
43+
44+
- name: Build jmh jar
4145
run: ./gradlew jmhJar
4246

4347
- name: Run Benchmark
@@ -46,9 +50,11 @@ jobs:
4650
java -jar libs/opentelemetry-sdk-trace-*-jmh.jar -rf json SpanBenchmark SpanPipelineBenchmark ExporterBenchmark
4751
4852
- name: Use CLA approved github bot
53+
if: github.event_name != 'pull_request'
4954
run: .github/scripts/use-cla-approved-github-bot.sh
5055

5156
- name: Store benchmark results
57+
if: github.event_name != 'pull_request'
5258
uses: benchmark-action/github-action-benchmark@4bdcce38c94cec68da58d012ac24b7b1155efe8b # v1.20.7
5359
with:
5460
tool: 'jmh'
@@ -57,3 +63,10 @@ jobs:
5763
github-token: ${{ secrets.GITHUB_TOKEN }}
5864
benchmark-data-dir-path: "benchmarks"
5965
auto-push: true
66+
67+
- name: Upload benchmark results
68+
if: github.event_name == 'pull_request'
69+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
70+
with:
71+
name: jmh-result.json
72+
path: sdk/trace/build/jmh-result.json

0 commit comments

Comments
 (0)