Skip to content

Commit 086ff4a

Browse files
committed
ci: compare PR benchmarks with base
Signed-off-by: Gregor Zeitlinger <gregor.zeitlinger@grafana.com>
1 parent 4a6958a commit 086ff4a

2 files changed

Lines changed: 275 additions & 23 deletions

File tree

.github/workflows/pr-benchmarks.yml

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,15 @@ jobs:
2121
runs-on: ubuntu-24.04
2222
permissions:
2323
contents: read # checkout only
24+
env:
25+
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
26+
PR_NUMBER: ${{ github.event.pull_request.number }}
2427
steps:
25-
- name: Checkout PR head
28+
- name: Checkout PR base
2629
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
2730
with:
28-
repository: ${{ github.event.pull_request.head.repo.full_name }}
29-
ref: ${{ github.event.pull_request.head.sha }}
31+
repository: ${{ github.repository }}
32+
ref: ${{ github.event.pull_request.base.sha }}
3033
persist-credentials: false
3134
fetch-depth: 0
3235

@@ -45,17 +48,33 @@ jobs:
4548
${{ runner.os }}-pr-bench-maven-
4649
${{ runner.os }}-maven-
4750
48-
- name: Run JMH benchmarks
51+
- name: Run base JMH benchmarks
52+
run: |
53+
mise run benchmark:ci-json
54+
mv benchmark-results.json /tmp/base-benchmark-results.json
55+
56+
- name: Checkout PR head
57+
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
58+
with:
59+
repository: ${{ github.event.pull_request.head.repo.full_name }}
60+
ref: ${{ github.event.pull_request.head.sha }}
61+
persist-credentials: false
62+
fetch-depth: 0
63+
64+
- name: Run head JMH benchmarks
4965
run: mise run benchmark:ci-json
5066

5167
- name: Generate benchmark summary
5268
run: |
5369
mise run benchmark:generate-summary \
5470
--input benchmark-results.json \
71+
--baseline /tmp/base-benchmark-results.json \
5572
--output-dir benchmark-results \
56-
--commit-sha "${{ github.event.pull_request.head.sha }}"
73+
--commit-sha "${{ github.event.pull_request.head.sha }}" \
74+
--baseline-sha "${{ github.event.pull_request.base.sha }}"
5775
env:
5876
GITHUB_REPOSITORY: ${{ github.event.pull_request.head.repo.full_name }}
77+
GITHUB_BASE_REPOSITORY: ${{ github.repository }}
5978

6079
- name: Prepare PR comment summary
6180
run: |
@@ -64,13 +83,13 @@ jobs:
6483
- name: Upload PR benchmark results
6584
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
6685
with:
67-
name: pr-benchmark-results-pr-${{ github.event.pull_request.number }}-${{ github.event.pull_request.head.sha }}
86+
name: pr-benchmark-results-pr-${{ env.PR_NUMBER }}-${{ env.HEAD_SHA }}
6887
path: benchmark-results
6988
retention-days: 5
7089

7190
- name: Upload PR benchmark comment
7291
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
7392
with:
74-
name: pr-benchmark-comment-pr-${{ github.event.pull_request.number }}-${{ github.event.pull_request.head.sha }}
93+
name: pr-benchmark-comment-pr-${{ env.PR_NUMBER }}-${{ env.HEAD_SHA }}
7594
path: pr-benchmark-comment.md
7695
retention-days: 5

0 commit comments

Comments
 (0)